@@ -31,4 +31,131 @@ public function test_can_resolve_bindings_when_invoked(): void
3131
3232 $ this ->assertInstanceOf (Request::class, $ mergeProp ());
3333 }
34+
35+ public function test_appends_by_default (): void
36+ {
37+ $ mergeProp = new MergeProp ([]);
38+
39+ $ this ->assertTrue ($ mergeProp ->shouldAppend ());
40+ $ this ->assertFalse ($ mergeProp ->hasNestedMergePaths ());
41+ $ this ->assertSame ([], $ mergeProp ->appendPaths ());
42+ $ this ->assertSame ([], $ mergeProp ->prependPaths ());
43+ $ this ->assertSame ([], $ mergeProp ->matchesOn ());
44+ }
45+
46+ public function test_prepends (): void
47+ {
48+ $ mergeProp = (new MergeProp ([]))->prepend ();
49+
50+ $ this ->assertFalse ($ mergeProp ->shouldAppend ());
51+ $ this ->assertFalse ($ mergeProp ->hasNestedMergePaths ());
52+ $ this ->assertSame ([], $ mergeProp ->appendPaths ());
53+ $ this ->assertSame ([], $ mergeProp ->prependPaths ());
54+ $ this ->assertSame ([], $ mergeProp ->matchesOn ());
55+ }
56+
57+ public function test_appends_with_nested_merge_paths (): void
58+ {
59+ $ mergeProp = (new MergeProp ([]))->append ('data ' );
60+
61+ $ this ->assertTrue ($ mergeProp ->shouldAppend ());
62+ $ this ->assertTrue ($ mergeProp ->hasNestedMergePaths ());
63+ $ this ->assertSame (['data ' ], $ mergeProp ->appendPaths ());
64+ $ this ->assertSame ([], $ mergeProp ->prependPaths ());
65+ $ this ->assertSame ([], $ mergeProp ->matchesOn ());
66+ }
67+
68+ public function test_appends_with_nested_merge_paths_and_match_on (): void
69+ {
70+ $ mergeProp = (new MergeProp ([]))->append ('data ' , 'id ' );
71+
72+ $ this ->assertTrue ($ mergeProp ->shouldAppend ());
73+ $ this ->assertTrue ($ mergeProp ->hasNestedMergePaths ());
74+ $ this ->assertSame (['data ' ], $ mergeProp ->appendPaths ());
75+ $ this ->assertSame ([], $ mergeProp ->prependPaths ());
76+ $ this ->assertSame (['data.id ' ], $ mergeProp ->matchesOn ());
77+ }
78+
79+ public function test_prepends_with_nested_merge_paths (): void
80+ {
81+ $ mergeProp = (new MergeProp ([]))->prepend ('data ' );
82+
83+ $ this ->assertTrue ($ mergeProp ->shouldAppend ());
84+ $ this ->assertTrue ($ mergeProp ->hasNestedMergePaths ());
85+ $ this ->assertSame ([], $ mergeProp ->appendPaths ());
86+ $ this ->assertSame (['data ' ], $ mergeProp ->prependPaths ());
87+ $ this ->assertSame ([], $ mergeProp ->matchesOn ());
88+ }
89+
90+ public function test_prepends_with_nested_merge_paths_and_match_on (): void
91+ {
92+ $ mergeProp = (new MergeProp ([]))->prepend ('data ' , 'id ' );
93+
94+ $ this ->assertTrue ($ mergeProp ->shouldAppend ());
95+ $ this ->assertTrue ($ mergeProp ->hasNestedMergePaths ());
96+ $ this ->assertSame ([], $ mergeProp ->appendPaths ());
97+ $ this ->assertSame (['data ' ], $ mergeProp ->prependPaths ());
98+ $ this ->assertSame (['data.id ' ], $ mergeProp ->matchesOn ());
99+ }
100+
101+ public function test_append_with_nested_merge_paths_as_array (): void
102+ {
103+ $ mergeProp = (new MergeProp ([]))->append (['data ' , 'items ' ]);
104+
105+ $ this ->assertTrue ($ mergeProp ->shouldAppend ());
106+ $ this ->assertTrue ($ mergeProp ->hasNestedMergePaths ());
107+ $ this ->assertSame (['data ' , 'items ' ], $ mergeProp ->appendPaths ());
108+ $ this ->assertSame ([], $ mergeProp ->prependPaths ());
109+ $ this ->assertSame ([], $ mergeProp ->matchesOn ());
110+ }
111+
112+ public function test_append_with_nested_merge_paths_and_match_on_as_array (): void
113+ {
114+ $ mergeProp = (new MergeProp ([]))->append (['data ' => 'id ' , 'items ' => 'uid ' ]);
115+
116+ $ this ->assertTrue ($ mergeProp ->shouldAppend ());
117+ $ this ->assertTrue ($ mergeProp ->hasNestedMergePaths ());
118+ $ this ->assertSame (['data ' , 'items ' ], $ mergeProp ->appendPaths ());
119+ $ this ->assertSame ([], $ mergeProp ->prependPaths ());
120+ $ this ->assertSame (['data.id ' , 'items.uid ' ], $ mergeProp ->matchesOn ());
121+ }
122+
123+ public function test_prepend_with_nested_merge_paths_as_array (): void
124+ {
125+ $ mergeProp = (new MergeProp ([]))->prepend (['data ' , 'items ' ]);
126+
127+ $ this ->assertTrue ($ mergeProp ->shouldAppend ());
128+ $ this ->assertTrue ($ mergeProp ->hasNestedMergePaths ());
129+ $ this ->assertSame ([], $ mergeProp ->appendPaths ());
130+ $ this ->assertSame (['data ' , 'items ' ], $ mergeProp ->prependPaths ());
131+ $ this ->assertSame ([], $ mergeProp ->matchesOn ());
132+ }
133+
134+ public function test_prepend_with_nested_merge_paths_and_match_on_as_array (): void
135+ {
136+ $ mergeProp = (new MergeProp ([]))->prepend (['data ' => 'id ' , 'items ' => 'uid ' ]);
137+
138+ $ this ->assertTrue ($ mergeProp ->shouldAppend ());
139+ $ this ->assertTrue ($ mergeProp ->hasNestedMergePaths ());
140+ $ this ->assertSame ([], $ mergeProp ->appendPaths ());
141+ $ this ->assertSame (['data ' , 'items ' ], $ mergeProp ->prependPaths ());
142+ $ this ->assertSame (['data.id ' , 'items.uid ' ], $ mergeProp ->matchesOn ());
143+ }
144+
145+ public function test_mix_of_append_and_prepend_with_nested_merge_paths_and_match_on_as_array (): void
146+ {
147+ $ mergeProp = (new MergeProp ([]))
148+ ->append ('data ' )
149+ ->append ('users ' , 'id ' )
150+ ->append (['items ' => 'uid ' , 'posts ' ])
151+ ->prepend ('categories ' )
152+ ->prepend ('companies ' , 'id ' )
153+ ->prepend (['tags ' => 'name ' , 'comments ' ]);
154+
155+ $ this ->assertTrue ($ mergeProp ->shouldAppend ());
156+ $ this ->assertTrue ($ mergeProp ->hasNestedMergePaths ());
157+ $ this ->assertSame (['data ' , 'users ' , 'items ' , 'posts ' ], $ mergeProp ->appendPaths ());
158+ $ this ->assertSame (['categories ' , 'companies ' , 'tags ' , 'comments ' ], $ mergeProp ->prependPaths ());
159+ $ this ->assertSame (['users.id ' , 'items.uid ' , 'companies.id ' , 'tags.name ' ], $ mergeProp ->matchesOn ());
160+ }
34161}
0 commit comments