File tree Expand file tree Collapse file tree 2 files changed +40
-1
lines changed Expand file tree Collapse file tree 2 files changed +40
-1
lines changed Original file line number Diff line number Diff line change @@ -89,7 +89,14 @@ public function jsonSerialize()
89
89
*/
90
90
public function __toString ()
91
91
{
92
- $ string = '(new ' . get_called_class () . ') ' ;
92
+ $ string = '(new ' . get_called_class ();
93
+ if (is_string ($ this ->expectedTarget )) {
94
+ $ string .= '( ' . var_export ($ this ->expectedTarget , true ) . ') ' ;
95
+ }
96
+ elseif (is_object ($ this ->expectedTarget )) {
97
+ $ string .= '( ' . get_class ($ this ->expectedTarget ) . '# ' . spl_object_id ($ this ->expectedTarget ) . ' ) ' ;
98
+ }
99
+ $ string .= ') ' ;
93
100
94
101
foreach ($ this ->stack as $ i => $ call ) {
95
102
if (isset ($ call ['method ' ])) {
Original file line number Diff line number Diff line change @@ -18,6 +18,38 @@ public function test_toString()
18
18
);
19
19
}
20
20
21
+ /**
22
+ */
23
+ public function test_toString_with_string_target ()
24
+ {
25
+ $ nameRobert = DeferredCallChain::new_ ("Human " )
26
+ ->setName ('Muda ' )
27
+ ->setFirstName ('Robert ' )
28
+ ;
29
+
30
+ $ this ->assertEquals (
31
+ "(new JClaveau\Async\DeferredCallChain('Human'))->setName('Muda')->setFirstName('Robert') " ,
32
+ (string ) $ nameRobert
33
+ );
34
+ }
35
+
36
+ /**
37
+ */
38
+ public function test_toString_with_instance_target ()
39
+ {
40
+ $ human = new Human ;
41
+
42
+ $ nameRobert = DeferredCallChain::new_ ($ human )
43
+ ->setName ('Muda ' )
44
+ ->setFirstName ('Robert ' )
45
+ ;
46
+
47
+ $ this ->assertEquals (
48
+ "(new JClaveau\Async\DeferredCallChain( JClaveau\Async\Human# " . spl_object_id ($ human ) . " ))->setName('Muda')->setFirstName('Robert') " ,
49
+ (string ) $ nameRobert
50
+ );
51
+ }
52
+
21
53
/**
22
54
*/
23
55
public function test_invoke ()
You can’t perform that action at this time.
0 commit comments