Skip to content

Commit aed8384

Browse files
committed
PHPC-1230: Test that user properties in BSON objects are cloned
1 parent 108f2b7 commit aed8384

13 files changed

+46
-0
lines changed

tests/bson/bson-binary-clone-001.phpt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ $types = array(
1818
foreach($types as $type) {
1919
// Use 16-byte data to satisfy UUID requirements
2020
$binary = new MongoDB\BSON\Binary('randomBinaryData', $type);
21+
$binary->foo = 'bar';
2122

2223
$clone = clone $binary;
2324

@@ -27,6 +28,7 @@ foreach($types as $type) {
2728
unset($binary);
2829

2930
var_dump($clone);
31+
var_dump($clone->foo);
3032
}
3133
?>
3234
===DONE===
@@ -40,6 +42,7 @@ object(MongoDB\BSON\Binary)#%d (2) {
4042
["type"]=>
4143
int(0)
4244
}
45+
string(3) "bar"
4346
bool(true)
4447
bool(false)
4548
object(MongoDB\BSON\Binary)#%d (2) {
@@ -48,6 +51,7 @@ object(MongoDB\BSON\Binary)#%d (2) {
4851
["type"]=>
4952
int(1)
5053
}
54+
string(3) "bar"
5155
bool(true)
5256
bool(false)
5357
object(MongoDB\BSON\Binary)#%d (2) {
@@ -56,6 +60,7 @@ object(MongoDB\BSON\Binary)#%d (2) {
5660
["type"]=>
5761
int(2)
5862
}
63+
string(3) "bar"
5964
bool(true)
6065
bool(false)
6166
object(MongoDB\BSON\Binary)#%d (2) {
@@ -64,6 +69,7 @@ object(MongoDB\BSON\Binary)#%d (2) {
6469
["type"]=>
6570
int(3)
6671
}
72+
string(3) "bar"
6773
bool(true)
6874
bool(false)
6975
object(MongoDB\BSON\Binary)#%d (2) {
@@ -72,6 +78,7 @@ object(MongoDB\BSON\Binary)#%d (2) {
7278
["type"]=>
7379
int(4)
7480
}
81+
string(3) "bar"
7582
bool(true)
7683
bool(false)
7784
object(MongoDB\BSON\Binary)#%d (2) {
@@ -80,6 +87,7 @@ object(MongoDB\BSON\Binary)#%d (2) {
8087
["type"]=>
8188
int(5)
8289
}
90+
string(3) "bar"
8391
bool(true)
8492
bool(false)
8593
object(MongoDB\BSON\Binary)#%d (2) {
@@ -88,6 +96,7 @@ object(MongoDB\BSON\Binary)#%d (2) {
8896
["type"]=>
8997
int(128)
9098
}
99+
string(3) "bar"
91100
bool(true)
92101
bool(false)
93102
object(MongoDB\BSON\Binary)#%d (2) {
@@ -96,4 +105,5 @@ object(MongoDB\BSON\Binary)#%d (2) {
96105
["type"]=>
97106
int(133)
98107
}
108+
string(3) "bar"
99109
===DONE===

tests/bson/bson-dbpointer-clone-001.phpt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ require_once __DIR__ . '/../utils/tools.php';
88
$test = MongoDB\BSON\toPHP(MongoDB\BSON\fromJSON('{ "dbref": {"$dbPointer": {"$ref": "phongo.test", "$id" : { "$oid" : "5a2e78accd485d55b405ac12" } }} }'));
99

1010
$dbPointer = $test->dbref;
11+
$dbPointer->foo = 'bar';
1112
$clone = clone($dbPointer);
1213

1314
var_dump($clone == $dbPointer);
@@ -16,6 +17,7 @@ var_dump($clone === $dbPointer);
1617
unset($dbPointer);
1718

1819
var_dump($clone);
20+
var_dump($clone->foo);
1921
?>
2022
===DONE===
2123
<?php exit(0); ?>
@@ -28,4 +30,5 @@ object(MongoDB\BSON\DBPointer)#%d (2) {
2830
["id"]=>
2931
string(24) "5a2e78accd485d55b405ac12"
3032
}
33+
string(3) "bar"
3134
===DONE===

tests/bson/bson-decimal128-clone-001.phpt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ MongoDB\BSON\Decimal128 can be cloned
66
<?php
77

88
$decimal = new MongoDB\BSON\Decimal128('1234.5678');
9+
$decimal->foo = 'bar';
910

1011
$clone = clone $decimal;
1112

@@ -15,6 +16,7 @@ var_dump($clone === $decimal);
1516
unset($decimal);
1617

1718
var_dump($clone);
19+
var_dump($clone->foo);
1820
?>
1921
===DONE===
2022
<?php exit(0); ?>
@@ -25,4 +27,5 @@ object(MongoDB\BSON\Decimal128)#%d (1) {
2527
["dec"]=>
2628
string(9) "1234.5678"
2729
}
30+
string(3) "bar"
2831
===DONE===

tests/bson/bson-int64-clone-001.phpt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ MongoDB\BSON\Int64 can be cloned
88
require_once __DIR__ . '/../utils/tools.php';
99

1010
$int64 = unserialize('C:18:"MongoDB\BSON\Int64":47:{a:1:{s:7:"integer";s:19:"9223372036854775807";}}');
11+
$int64->foo = 'bar';
1112
$clone = clone $int64;
1213

1314
var_dump($clone == $int64);
@@ -16,6 +17,7 @@ var_dump($clone === $int64);
1617
unset($int64);
1718

1819
var_dump($clone);
20+
var_dump($clone->foo);
1921
?>
2022
===DONE===
2123
<?php exit(0); ?>
@@ -26,4 +28,5 @@ object(MongoDB\BSON\Int64)#%d (%d) {
2628
["integer"]=>
2729
string(19) "9223372036854775807"
2830
}
31+
string(3) "bar"
2932
===DONE===

tests/bson/bson-javascript-clone-001.phpt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ MongoDB\BSON\Javascript can be cloned
66
require_once __DIR__ . '/../utils/tools.php';
77

88
$javascript = new MongoDB\BSON\Javascript("function foo(bar) {var baz = bar; var bar = foo; return bar; }", ['foo' => 42]);
9+
$javascript->foo = 'bar';
910

1011
$clone = clone $javascript;
1112

@@ -15,6 +16,7 @@ var_dump($clone === $javascript);
1516
unset($javascript);
1617

1718
var_dump($clone);
19+
var_dump($clone->foo);
1820
?>
1921
===DONE===
2022
<?php exit(0); ?>
@@ -30,4 +32,5 @@ object(MongoDB\BSON\Javascript)#%d (%d) {
3032
int(42)
3133
}
3234
}
35+
string(3) "bar"
3336
===DONE===

tests/bson/bson-maxkey-clone-001.phpt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,18 @@ MongoDB\BSON\MaxKey can be cloned
66
require_once __DIR__ . '/../utils/tools.php';
77

88
$maxKey = new MongoDB\BSON\MaxKey;
9+
$maxKey->foo = 'bar';
910

1011
$clone = clone $maxKey;
1112

1213
var_dump($clone == $maxKey);
1314
var_dump($clone === $maxKey);
15+
var_dump($clone->foo);
1416
?>
1517
===DONE===
1618
<?php exit(0); ?>
1719
--EXPECT--
1820
bool(true)
1921
bool(false)
22+
string(3) "bar"
2023
===DONE===

tests/bson/bson-minkey-clone-001.phpt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,18 @@ MongoDB\BSON\MinKey can be cloned
66
require_once __DIR__ . '/../utils/tools.php';
77

88
$minKey = new MongoDB\BSON\MinKey;
9+
$minKey->foo = 'bar';
910

1011
$clone = clone $minKey;
1112

1213
var_dump($clone == $minKey);
1314
var_dump($clone === $minKey);
15+
var_dump($clone->foo);
1416
?>
1517
===DONE===
1618
<?php exit(0); ?>
1719
--EXPECT--
1820
bool(true)
1921
bool(false)
22+
string(3) "bar"
2023
===DONE===

tests/bson/bson-objectid-clone-001.phpt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ MongoDB\BSON\ObjectId can be cloned
66
require_once __DIR__ . '/../utils/tools.php';
77

88
$objectId = new MongoDB\BSON\ObjectId("53e2a1c40640fd72175d4603");
9+
$objectId->foo = 'bar';
910
$clone = clone $objectId;
1011

1112
var_dump($clone == $objectId);
@@ -14,6 +15,7 @@ var_dump($clone === $objectId);
1415
unset($objectId);
1516

1617
var_dump($clone);
18+
var_dump($clone->foo);
1719
?>
1820
===DONE===
1921
<?php exit(0); ?>
@@ -24,4 +26,5 @@ object(MongoDB\BSON\ObjectId)#%d (1) {
2426
["oid"]=>
2527
string(24) "53e2a1c40640fd72175d4603"
2628
}
29+
string(3) "bar"
2730
===DONE===

tests/bson/bson-regex-clone-001.phpt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ MongoDB\BSON\Regex can be cloned
66
require_once __DIR__ . '/../utils/tools.php';
77

88
$regexp = new MongoDB\BSON\Regex("regexp", "i");
9+
$regexp->foo = 'bar';
910

1011
$clone = clone $regexp;
1112

@@ -15,6 +16,7 @@ var_dump($clone === $regexp);
1516
unset($regexp);
1617

1718
var_dump($clone);
19+
var_dump($clone->foo);
1820
?>
1921
===DONE===
2022
<?php exit(0); ?>
@@ -27,4 +29,5 @@ object(MongoDB\BSON\Regex)#%d (2) {
2729
["flags"]=>
2830
string(1) "i"
2931
}
32+
string(3) "bar"
3033
===DONE===

tests/bson/bson-symbol-clone-001.phpt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ require_once __DIR__ . '/../utils/tools.php';
88
$test = MongoDB\BSON\toPHP(MongoDB\BSON\fromJSON('{ "symbol": {"$symbol": "test"} }'));
99

1010
$symbol = $test->symbol;
11+
$symbol->foo = 'bar';
1112

1213
$clone = clone $symbol;
1314

@@ -17,6 +18,7 @@ var_dump($clone === $symbol);
1718
unset($symbol);
1819

1920
var_dump($clone);
21+
var_dump($clone->foo);
2022
?>
2123
===DONE===
2224
<?php exit(0); ?>
@@ -27,4 +29,5 @@ object(MongoDB\BSON\Symbol)#%d (1) {
2729
["symbol"]=>
2830
string(4) "test"
2931
}
32+
string(3) "bar"
3033
===DONE===

tests/bson/bson-timestamp-clone-001.phpt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ MongoDB\BSON\Timestamp can be cloned
66
require_once __DIR__ . '/../utils/tools.php';
77

88
$timestamp = new MongoDB\BSON\Timestamp(1234, 5678);
9+
$timestamp->foo = 'bar';
910

1011
$clone = clone $timestamp;
1112

@@ -15,6 +16,7 @@ var_dump($clone === $timestamp);
1516
unset($timestamp);
1617

1718
var_dump($clone);
19+
var_dump($clone->foo);
1820
?>
1921
===DONE===
2022
<?php exit(0); ?>
@@ -27,4 +29,5 @@ object(MongoDB\BSON\Timestamp)#%d (2) {
2729
["timestamp"]=>
2830
string(4) "5678"
2931
}
32+
string(3) "bar"
3033
===DONE===

tests/bson/bson-undefined-clone-001.phpt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,18 @@ require_once __DIR__ . '/../utils/tools.php';
88
$test = MongoDB\BSON\toPHP(MongoDB\BSON\fromJSON('{ "undefined": {"$undefined": true} }'));
99

1010
$undefined = $test->undefined;
11+
$undefined->foo = 'bar';
1112

1213
$clone = clone $undefined;
1314

1415
var_dump($clone == $undefined);
1516
var_dump($clone === $undefined);
17+
var_dump($clone->foo);
1618
?>
1719
===DONE===
1820
<?php exit(0); ?>
1921
--EXPECT--
2022
bool(true)
2123
bool(false)
24+
string(3) "bar"
2225
===DONE===

tests/bson/bson-utcdatetime-clone-001.phpt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ MongoDB\BSON\UTCDateTime can be cloned
66
require_once __DIR__ . "/../utils/basic.inc";
77

88
$utcdatetime = new MongoDB\BSON\UTCDateTime("1416445411987");
9+
$utcdatetime->foo = 'bar';
910

1011
$clone = clone $utcdatetime;
1112

@@ -15,6 +16,7 @@ var_dump($clone === $utcdatetime);
1516
unset($utcdatetime);
1617

1718
var_dump($clone);
19+
var_dump($clone->foo);
1820
?>
1921
===DONE===
2022
<?php exit(0); ?>
@@ -25,4 +27,5 @@ object(MongoDB\BSON\UTCDateTime)#%d (1) {
2527
["milliseconds"]=>
2628
string(13) "1416445411987"
2729
}
30+
string(3) "bar"
2831
===DONE===

0 commit comments

Comments
 (0)