Skip to content

Commit 3bd3fb4

Browse files
authored
PHPLIB-1135: Remove var_dump from tests, use print_r instead (#1081)
* Remove var_dump from tests * psalm-suppress no longer necessary var_dump output is modified by xdebug, leading to test failure during debug
1 parent cb57dc7 commit 3bd3fb4

File tree

3 files changed

+54
-58
lines changed

3 files changed

+54
-58
lines changed

examples/persistable.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
use UnexpectedValueException;
1111

1212
use function getenv;
13-
use function var_dump;
13+
use function print_r;
1414

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

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

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

108-
/** @psalm-suppress ForbiddenCode */
109-
var_dump($foundEntry);
108+
print_r($foundEntry);

examples/typemap.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
use function getenv;
1212
use function is_array;
13-
use function var_dump;
13+
use function print_r;
1414

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

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

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

119-
/** @psalm-suppress ForbiddenCode */
120-
var_dump($entry);
119+
print_r($entry);

tests/ExamplesTest.php

Lines changed: 50 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -90,32 +90,31 @@ public function dataExamples(): Generator
9090
];
9191

9292
$expectedOutput = <<<'OUTPUT'
93-
object(MongoDB\Examples\PersistableEntry)#%d (%d) {
94-
["id":"MongoDB\Examples\PersistableEntry":private]=>
95-
object(MongoDB\BSON\ObjectId)#%d (%d) {
96-
["oid"]=>
97-
string(24) "%s"
98-
}
99-
["name"]=>
100-
string(7) "alcaeus"
101-
["emails"]=>
102-
array(2) {
103-
[0]=>
104-
object(MongoDB\Examples\PersistableEmail)#%d (%d) {
105-
["type"]=>
106-
string(4) "work"
107-
["address"]=>
108-
string(19) "[email protected]"
109-
}
110-
[1]=>
111-
object(MongoDB\Examples\PersistableEmail)#%d (%d) {
112-
["type"]=>
113-
string(7) "private"
114-
["address"]=>
115-
string(18) "[email protected]"
116-
}
117-
}
118-
}
93+
MongoDB\Examples\PersistableEntry Object
94+
(
95+
[id:MongoDB\Examples\PersistableEntry:private] => MongoDB\BSON\ObjectId Object
96+
(
97+
[oid] => %s
98+
)
99+
100+
[name] => alcaeus
101+
[emails] => Array
102+
(
103+
[0] => MongoDB\Examples\PersistableEmail Object
104+
(
105+
[type] => work
106+
[address] => [email protected]
107+
)
108+
109+
[1] => MongoDB\Examples\PersistableEmail Object
110+
(
111+
[type] => private
112+
[address] => [email protected]
113+
)
114+
115+
)
116+
117+
)
119118
OUTPUT;
120119

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

126125
$expectedOutput = <<<'OUTPUT'
127-
object(MongoDB\Examples\TypeMapEntry)#%d (%d) {
128-
["id":"MongoDB\Examples\TypeMapEntry":private]=>
129-
object(MongoDB\BSON\ObjectId)#%d (%d) {
130-
["oid"]=>
131-
string(24) "%s"
132-
}
133-
["name":"MongoDB\Examples\TypeMapEntry":private]=>
134-
string(7) "alcaeus"
135-
["emails":"MongoDB\Examples\TypeMapEntry":private]=>
136-
array(2) {
137-
[0]=>
138-
object(MongoDB\Examples\TypeMapEmail)#%d (%d) {
139-
["type":"MongoDB\Examples\TypeMapEmail":private]=>
140-
string(4) "work"
141-
["address":"MongoDB\Examples\TypeMapEmail":private]=>
142-
string(19) "[email protected]"
143-
}
144-
[1]=>
145-
object(MongoDB\Examples\TypeMapEmail)#%d (%d) {
146-
["type":"MongoDB\Examples\TypeMapEmail":private]=>
147-
string(7) "private"
148-
["address":"MongoDB\Examples\TypeMapEmail":private]=>
149-
string(18) "[email protected]"
150-
}
151-
}
152-
}
126+
MongoDB\Examples\TypeMapEntry Object
127+
(
128+
[id:MongoDB\Examples\TypeMapEntry:private] => MongoDB\BSON\ObjectId Object
129+
(
130+
[oid] => %s
131+
)
132+
133+
[name:MongoDB\Examples\TypeMapEntry:private] => alcaeus
134+
[emails:MongoDB\Examples\TypeMapEntry:private] => Array
135+
(
136+
[0] => MongoDB\Examples\TypeMapEmail Object
137+
(
138+
[type:MongoDB\Examples\TypeMapEmail:private] => work
139+
[address:MongoDB\Examples\TypeMapEmail:private] => [email protected]
140+
)
141+
142+
[1] => MongoDB\Examples\TypeMapEmail Object
143+
(
144+
[type:MongoDB\Examples\TypeMapEmail:private] => private
145+
[address:MongoDB\Examples\TypeMapEmail:private] => [email protected]
146+
)
147+
148+
)
149+
150+
)
153151
OUTPUT;
154152

155153
yield 'typemap' => [

0 commit comments

Comments
 (0)