Skip to content

PHPLIB-1135: Remove var_dump from tests, use print_r instead #1081

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 26, 2023
Merged
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
5 changes: 2 additions & 3 deletions examples/persistable.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
use UnexpectedValueException;

use function getenv;
use function var_dump;
use function print_r;

require __DIR__ . '/../vendor/autoload.php';

Expand Down Expand Up @@ -105,5 +105,4 @@ public function bsonUnserialize(array $data): void

$foundEntry = $collection->findOne([]);

/** @psalm-suppress ForbiddenCode */
var_dump($foundEntry);
print_r($foundEntry);
5 changes: 2 additions & 3 deletions examples/typemap.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

use function getenv;
use function is_array;
use function var_dump;
use function print_r;

require __DIR__ . '/../vendor/autoload.php';

Expand Down Expand Up @@ -116,5 +116,4 @@ public function bsonUnserialize(array $data): void

$entry = $collection->findOne([], ['typeMap' => $typeMap]);

/** @psalm-suppress ForbiddenCode */
var_dump($entry);
print_r($entry);
102 changes: 50 additions & 52 deletions tests/ExamplesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,32 +90,31 @@ public function dataExamples(): Generator
];

$expectedOutput = <<<'OUTPUT'
object(MongoDB\Examples\PersistableEntry)#%d (%d) {
["id":"MongoDB\Examples\PersistableEntry":private]=>
object(MongoDB\BSON\ObjectId)#%d (%d) {
["oid"]=>
string(24) "%s"
}
["name"]=>
string(7) "alcaeus"
["emails"]=>
array(2) {
[0]=>
object(MongoDB\Examples\PersistableEmail)#%d (%d) {
["type"]=>
string(4) "work"
["address"]=>
string(19) "[email protected]"
}
[1]=>
object(MongoDB\Examples\PersistableEmail)#%d (%d) {
["type"]=>
string(7) "private"
["address"]=>
string(18) "[email protected]"
}
}
}
MongoDB\Examples\PersistableEntry Object
(
[id:MongoDB\Examples\PersistableEntry:private] => MongoDB\BSON\ObjectId Object
(
[oid] => %s
)

[name] => alcaeus
[emails] => Array
(
[0] => MongoDB\Examples\PersistableEmail Object
(
[type] => work
[address] => [email protected]
)

[1] => MongoDB\Examples\PersistableEmail Object
(
[type] => private
[address] => [email protected]
)

)

)
OUTPUT;

yield 'persistable' => [
Expand All @@ -124,32 +123,31 @@ public function dataExamples(): Generator
];

$expectedOutput = <<<'OUTPUT'
object(MongoDB\Examples\TypeMapEntry)#%d (%d) {
["id":"MongoDB\Examples\TypeMapEntry":private]=>
object(MongoDB\BSON\ObjectId)#%d (%d) {
["oid"]=>
string(24) "%s"
}
["name":"MongoDB\Examples\TypeMapEntry":private]=>
string(7) "alcaeus"
["emails":"MongoDB\Examples\TypeMapEntry":private]=>
array(2) {
[0]=>
object(MongoDB\Examples\TypeMapEmail)#%d (%d) {
["type":"MongoDB\Examples\TypeMapEmail":private]=>
string(4) "work"
["address":"MongoDB\Examples\TypeMapEmail":private]=>
string(19) "[email protected]"
}
[1]=>
object(MongoDB\Examples\TypeMapEmail)#%d (%d) {
["type":"MongoDB\Examples\TypeMapEmail":private]=>
string(7) "private"
["address":"MongoDB\Examples\TypeMapEmail":private]=>
string(18) "[email protected]"
}
}
}
MongoDB\Examples\TypeMapEntry Object
(
[id:MongoDB\Examples\TypeMapEntry:private] => MongoDB\BSON\ObjectId Object
(
[oid] => %s
)

[name:MongoDB\Examples\TypeMapEntry:private] => alcaeus
[emails:MongoDB\Examples\TypeMapEntry:private] => Array
(
[0] => MongoDB\Examples\TypeMapEmail Object
(
[type:MongoDB\Examples\TypeMapEmail:private] => work
[address:MongoDB\Examples\TypeMapEmail:private] => [email protected]
)

[1] => MongoDB\Examples\TypeMapEmail Object
(
[type:MongoDB\Examples\TypeMapEmail:private] => private
[address:MongoDB\Examples\TypeMapEmail:private] => [email protected]
)

)

)
OUTPUT;

yield 'typemap' => [
Expand Down