@@ -78,46 +78,49 @@ public function testApplyWhen()
7878 'missing.1 ' => 'abc ' ,
7979 'missing.2 ' => 123 ,
8080 ]);
81- $ this ->assertEquals (new MergeValue ([
82- 'missing.1 ' => (new ValueMixed (fn () => 'abc ' ))->when (fn () => false ),
83- 'missing.2 ' => (new ValueMixed (fn () => 123 ))->when (fn () => false ),
84- ]), $ actual );
81+ $ this ->assertInstanceOf (MergeValue::class, $ actual );
82+ $ this ->assertInstanceOf (ValueMixed::class, $ actual ->data ['missing.1 ' ]);
83+ $ this ->assertInstanceOf (ValueMixed::class, $ actual ->data ['missing.2 ' ]);
84+ $ this ->assertEquals ('abc ' , $ actual ->data ['missing.1 ' ]->retriever ()());
85+ $ this ->assertEquals (123 , $ actual ->data ['missing.2 ' ]->retriever ()());
8586 $ actual = Reflect::invoke ($ stub , 'applyWhen ' , true , [
8687 'present.1 ' => 'abc ' ,
8788 'present.2 ' => 123 ,
8889 ]);
89- $ this ->assertEquals (new MergeValue ([
90- 'present.1 ' => (new ValueMixed (fn () => 'abc ' ))->when (fn () => true ),
91- 'present.2 ' => (new ValueMixed (fn () => 123 ))->when (fn () => true ),
92- ]), $ actual );
90+ $ this ->assertInstanceOf (ValueMixed::class, $ actual ->data ['present.1 ' ]);
91+ $ this ->assertInstanceOf (ValueMixed::class, $ actual ->data ['present.2 ' ]);
92+ $ this ->assertEquals ('abc ' , $ actual ->data ['present.1 ' ]->retriever ()());
93+ $ this ->assertEquals (123 , $ actual ->data ['present.2 ' ]->retriever ()());
94+
9395 $ actual = Reflect::invoke ($ stub , 'applyWhen ' , true , [
94- 'present.1 ' => (new ValueMixed (fn () => 'abc ' )),
95- 'present.2 ' => (new ValueMixed (fn () => 123 )),
96- 'present.3 ' => (new RelationOne ('present ' , fn () => 'abc ' )),
97- 'present.4 ' => (new RelationOne ('present ' , fn () => 123 )),
98- 'present.5 ' => (new Relationship (UserResource::class, fn () => null )),
96+ 'present.1 ' => $ p1 = (new ValueMixed (fn () => 'abc ' )),
97+ 'present.2 ' => $ p2 = (new ValueMixed (fn () => 123 )),
98+ 'present.3 ' => $ p3 = (new RelationOne ('present ' , fn () => 'abc ' )),
99+ 'present.4 ' => $ p4 = (new RelationOne ('present ' , fn () => 123 )),
100+ 'present.5 ' => $ p5 = (new Relationship (UserResource::class, fn () => null )),
99101 ]);
100- $ this ->assertEquals (new MergeValue ([
101- 'present.1 ' => (new ValueMixed (fn () => 'abc ' ))->when (fn () => true ),
102- 'present.2 ' => (new ValueMixed (fn () => 123 ))->when (fn () => true ),
103- 'present.3 ' => (new RelationOne ('present ' , fn () => 'abc ' ))->when (fn () => true ),
104- 'present.4 ' => (new RelationOne ('present ' , fn () => 123 ))->when (fn () => true ),
105- 'present.5 ' => RelationRaw::fromRelationship (new Relationship (UserResource::class, fn () => null ))->when (fn () => true ),
106- ]), $ actual );
102+ $ this ->assertInstanceOf (MergeValue::class, $ actual );
103+ $ this ->assertEquals ($ p1 , $ actual ->data ['present.1 ' ]);
104+ $ this ->assertEquals ($ p2 , $ actual ->data ['present.2 ' ]);
105+ $ this ->assertEquals ($ p3 , $ actual ->data ['present.3 ' ]);
106+ $ this ->assertEquals ($ p4 , $ actual ->data ['present.4 ' ]);
107+ $ this ->assertInstanceOf (RelationRaw::class, $ actual ->data ['present.5 ' ]);
108+ $ this ->assertInstanceOf (Relationship::class, $ actual ->data ['present.5 ' ]->retriever ()());
109+
107110 $ actual = Reflect::invoke ($ stub , 'applyWhen ' , false , [
108- 'missing.1 ' => (new ValueMixed (fn () => 'abc ' )),
109- 'missing.2 ' => (new ValueMixed (fn () => 123 )),
110- 'missing.3 ' => (new RelationOne ('present ' , fn () => 'abc ' )),
111- 'missing.4 ' => (new RelationOne ('present ' , fn () => 123 )),
111+ 'missing.1 ' => $ p1 = (new ValueMixed (fn () => 'abc ' )),
112+ 'missing.2 ' => $ p2 = (new ValueMixed (fn () => 123 )),
113+ 'missing.3 ' => $ p3 = (new RelationOne ('present ' , fn () => 'abc ' )),
114+ 'missing.4 ' => $ p4 = (new RelationOne ('present ' , fn () => 123 )),
112115 'missing.5 ' => (new Relationship (UserResource::class, fn () => null )),
113116 ]);
114- $ this ->assertEquals ( new MergeValue ([
115- 'missing.1 ' => ( new ValueMixed ( fn () => ' abc ' ))-> when ( fn () => false ),
116- 'missing.2 ' => ( new ValueMixed ( fn () => 123 ))-> when ( fn () => false ),
117- ' missing.3 ' => ( new RelationOne ( ' present ' , fn () => ' abc ' ))-> when ( fn () => false ),
118- 'missing.4 ' => ( new RelationOne ( ' present ' , fn () => 123 ))-> when ( fn () => false ),
119- ' missing.5 ' => RelationRaw::fromRelationship ( new Relationship (UserResource:: class, fn () => null ))-> when ( fn () => false ),
120- ]) , $ actual );
117+ $ this ->assertInstanceOf ( MergeValue::class, $ actual );
118+ $ this -> assertEquals ( $ p1 , $ actual -> data [ 'missing.1 ' ]);
119+ $ this -> assertEquals ( $ p2 , $ actual -> data [ 'missing.2 ' ]);
120+ $ this -> assertEquals ( $ p3 , $ actual -> data [ ' missing.3 ' ]);
121+ $ this -> assertEquals ( $ p4 , $ actual -> data [ 'missing.4 ' ]);
122+ $ this -> assertInstanceOf ( RelationRaw::class, $ actual -> data [ ' missing.5 ' ]);
123+ $ this -> assertInstanceOf (Relationship::class , $ actual-> data [ ' missing.5 ' ]-> retriever ()() );
121124 }
122125
123126 public function testWhenHas ()
0 commit comments