Skip to content
This repository was archived by the owner on Dec 23, 2021. It is now read-only.

Do not wrap example Regex pattern with delimiters #152

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions tests/json-serialize-regex-001.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ JsonSerializable: Regex
--FILE--
<?php
$doc = [
'foo' => new MongoDB\BSON\Regex( "/foo/", "i" )
'foo' => new MongoDB\BSON\Regex( "pattern", "i" )
];

echo MongoDB\BSON\toJSON( \MongoDB\BSON\fromPHP( $doc ) ), "\n";
Expand All @@ -13,13 +13,13 @@ echo $d, "\n";
var_dump( \MongoDB\BSON\toPHP( \MongoDB\BSON\fromJSON( $d ) ) );
?>
--EXPECTF--
{ "foo" : { "$regex" : "/foo/", "$options" : "i" } }
{"foo":{"$regex":"\/foo\/","$options":"i"}}
{ "foo" : { "$regex" : "pattern", "$options" : "i" } }
{"foo":{"$regex":"pattern","$options":"i"}}
object(stdClass)#%d (%d) {
["foo"]=>
object(MongoDB\BSON\Regex)#%d (%d) {
["pattern"]=>
string(%d) "/foo/"
string(%d) "pattern"
["flags"]=>
string(%d) "i"
}
Expand Down
8 changes: 4 additions & 4 deletions tests/json-serialize-regex-002.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ JsonSerializable: Regex without flags
--FILE--
<?php
$doc = [
'foo' => new MongoDB\BSON\Regex( "/foo/" )
'foo' => new MongoDB\BSON\Regex( "pattern" )
];

echo MongoDB\BSON\toJSON( \MongoDB\BSON\fromPHP( $doc ) ), "\n";
Expand All @@ -13,13 +13,13 @@ echo $d, "\n";
var_dump( \MongoDB\BSON\toPHP( \MongoDB\BSON\fromJSON( $d ) ) );
?>
--EXPECTF--
{ "foo" : { "$regex" : "/foo/", "$options" : "" } }
{"foo":{"$regex":"\/foo\/","$options":""}}
{ "foo" : { "$regex" : "pattern", "$options" : "" } }
{"foo":{"$regex":"pattern","$options":""}}
object(stdClass)#%d (%d) {
["foo"]=>
object(MongoDB\BSON\Regex)#%d (%d) {
["pattern"]=>
string(%d) "/foo/"
string(%d) "pattern"
["flags"]=>
string(%d) ""
}
Expand Down