13
13
14
14
namespace Laudis \Neo4j \Tests \Unit ;
15
15
16
- use ArrayIterator ;
17
16
use BadMethodCallException ;
18
17
use InvalidArgumentException ;
19
18
use function json_encode ;
20
19
use JsonException ;
21
20
use Laudis \Neo4j \Types \AbstractCypherObject ;
22
21
use PHPUnit \Framework \TestCase ;
23
22
23
+ /**
24
+ * @extends AbstractCypherObject<string, mixed>
25
+ * @psalm-immutable
26
+ */
27
+ final class BogusCypherObject extends AbstractCypherObject
28
+ {
29
+ public function toArray (): array
30
+ {
31
+ return [];
32
+ }
33
+ }
34
+
35
+ /**
36
+ * @extends AbstractCypherObject<string, mixed>
37
+ * @psalm-immutable
38
+ */
39
+ final class BogusCypherObjectFilled extends AbstractCypherObject
40
+ {
41
+ public function toArray (): array
42
+ {
43
+ return [
44
+ 'a ' => 'b ' ,
45
+ 'c ' => 'd ' ,
46
+ ];
47
+ }
48
+ }
49
+
24
50
final class CypherTypeTest extends TestCase
25
51
{
26
52
/**
@@ -30,12 +56,7 @@ final class CypherTypeTest extends TestCase
30
56
*/
31
57
public function testEmpty (): void
32
58
{
33
- $ empty = new class () extends AbstractCypherObject {
34
- public function getIterator ()
35
- {
36
- return new ArrayIterator ([]);
37
- }
38
- };
59
+ $ empty = new BogusCypherObject ();
39
60
40
61
self ::assertEquals ('[] ' , json_encode ($ empty , JSON_THROW_ON_ERROR ));
41
62
self ::assertFalse (isset ($ empty [0 ]));
@@ -73,13 +94,7 @@ public function getIterator()
73
94
*/
74
95
public function testFilled (): void
75
96
{
76
- $ filled = new class () extends AbstractCypherObject {
77
- public function getIterator ()
78
- {
79
- yield 'a ' => 'b ' ;
80
- yield 'c ' => 'd ' ;
81
- }
82
- };
97
+ $ filled = new BogusCypherObjectFilled ();
83
98
84
99
self ::assertEquals ('{"a":"b","c":"d"} ' , json_encode ($ filled , JSON_THROW_ON_ERROR ));
85
100
0 commit comments