@@ -36,27 +36,63 @@ public function testWithVariables(): void
36
36
{
37
37
$ stream = $ this ->getStream ();
38
38
$ writer = new StreamWriter ($ stream );
39
- $ variable = new stdClass ();
39
+ $ var = new stdClass ();
40
40
$ varDump = $ this ->getVarDump ();
41
- $ varDumpWithVariables = $ varDump ->withVariables ($ variable );
41
+ $ varDumpWithVariables = $ varDump ->withVariables ($ var );
42
42
$ this ->assertNotSame ($ varDump , $ varDumpWithVariables );
43
43
$ this ->assertEqualsCanonicalizing (
44
- [$ variable ],
44
+ [$ var ],
45
45
$ varDumpWithVariables ->variables ()
46
46
);
47
47
$ varDumpWithVariables ->process ($ writer );
48
48
$ line = strval (__LINE__ - 1 );
49
- $ hrLine = str_repeat ('- ' , 60 );
50
- $ expectedString = "\n"
51
- . $ varDump ::class . '->process() '
52
- . "\n"
53
- . $ hrLine
54
- . "\n"
55
- . __FILE__ . ': ' . $ line
56
- . "\n\n"
57
- . 'Arg#1 stdClass# ' . spl_object_id ($ variable )
58
- . "\n" . $ hrLine
59
- . "\n" ;
49
+ $ className = $ varDump ::class;
50
+ $ fileLine = __FILE__ . ': ' . $ line ;
51
+ $ objectId = spl_object_id ($ var );
52
+ $ expectedString = <<<PLAIN
53
+
54
+ {$ className }->process()
55
+ ------------------------------------------------------------
56
+ {$ fileLine }
57
+
58
+ Arg#1 stdClass# {$ objectId }
59
+ ------------------------------------------------------------
60
+
61
+ PLAIN ;
62
+ $ this ->assertSame ($ expectedString , $ writer ->__toString ());
63
+ }
64
+
65
+ public function testCircularReferenceArguments (): void
66
+ {
67
+ $ var = new stdClass ();
68
+ $ var ->circular = $ var ;
69
+ $ var ->string = 'test ' ;
70
+ $ varDump = $ this ->getVarDump ();
71
+ $ varDumpWithVariables = $ varDump ->withVariables ($ var , [$ var ]);
72
+ $ stream = $ this ->getStream ();
73
+ $ writer = new StreamWriter ($ stream );
74
+ $ varDumpWithVariables ->process ($ writer );
75
+ $ line = strval (__LINE__ - 1 );
76
+ $ className = $ varDump ::class;
77
+ $ fileLine = __FILE__ . ': ' . $ line ;
78
+ $ objectId = spl_object_id ($ var );
79
+ $ expectedString = <<<PLAIN
80
+
81
+ {$ className }->process()
82
+ ------------------------------------------------------------
83
+ {$ fileLine }
84
+
85
+ Arg#1 stdClass# {$ objectId }
86
+ public circular stdClass# {$ objectId } (circular reference # {$ objectId })
87
+ public string string test (length=4)
88
+
89
+ Arg#2 array (size=1)
90
+ 0 => stdClass# {$ objectId }
91
+ public circular stdClass# {$ objectId } (circular reference # {$ objectId })
92
+ public string string test (length=4)
93
+ ------------------------------------------------------------
94
+
95
+ PLAIN ;
60
96
$ this ->assertSame ($ expectedString , $ writer ->__toString ());
61
97
}
62
98
0 commit comments