@@ -131,4 +131,144 @@ public function testCreateClauseExample3(): void
131131
132132 $ this ->assertSame ("CREATE (:Person), (:Animal) " , $ query );
133133 }
134+
135+ public function testDeleteClauseExample1 (): void
136+ {
137+ $ unknown = Query::node ('Person ' )->withProperties ([
138+ 'name ' => 'UNKNOWN '
139+ ]);
140+
141+ $ query = Query::new ()
142+ ->match ($ unknown )
143+ ->delete ($ unknown )
144+ ->build ();
145+
146+ $ this ->assertStringMatchesFormat ("MATCH (%s:Person {name: 'UNKNOWN'}) DELETE %s " , $ query );
147+ }
148+
149+ public function testDeleteClauseExample2 (): void
150+ {
151+ $ everything = Query::node ();
152+
153+ $ query = Query::new ()
154+ ->match ($ everything )
155+ ->delete ($ everything )
156+ ->build ();
157+
158+ $ this ->assertStringMatchesFormat ("MATCH (%s) DELETE %s " , $ query );
159+ }
160+
161+ public function testDeleteClauseExample3 (): void
162+ {
163+ $ everything = Query::node ();
164+
165+ $ query = Query::new ()
166+ ->match ($ everything )
167+ ->delete ($ everything , true )
168+ ->build ();
169+
170+ $ this ->assertStringMatchesFormat ("MATCH (%s) DETACH DELETE %s " , $ query );
171+ }
172+
173+ public function testDeleteClauseExample4 (): void
174+ {
175+ $ everything = Query::node ();
176+
177+ $ query = Query::new ()
178+ ->match ($ everything )
179+ ->detachDelete ($ everything )
180+ ->build ();
181+
182+ $ this ->assertStringMatchesFormat ("MATCH (%s) DETACH DELETE %s " , $ query );
183+ }
184+
185+ public function testDeleteClauseExample5 (): void
186+ {
187+ $ persons = Query::node ('Person ' );
188+ $ animals = Query::node ('Animal ' );
189+
190+ $ query = Query::new ()
191+ ->match ([$ persons , $ animals ])
192+ ->delete ([$ persons , $ animals ])
193+ ->build ();
194+
195+ $ this ->assertStringMatchesFormat ("MATCH (%s:Person), (%s:Animal) DELETE %s, %s " , $ query );
196+ }
197+
198+ public function testLimitClauseExample1 (): void
199+ {
200+ $ persons = Query::node ('Person ' );
201+ $ query = Query::new ()
202+ ->match ($ persons )
203+ ->returning ($ persons ->property ('name ' ))
204+ ->limit (3 )
205+ ->build ();
206+
207+ $ this ->assertStringMatchesFormat ("MATCH (%s:Person) RETURN %s.name LIMIT 3 " , $ query );
208+ }
209+
210+ public function testMatchClauseExample1 (): void
211+ {
212+ $ n = Query::node ();
213+ $ query = Query::new ()
214+ ->match ($ n )
215+ ->returning ($ n )
216+ ->build ();
217+
218+ $ this ->assertStringMatchesFormat ("MATCH (%s) RETURN %s " , $ query );
219+ }
220+
221+ public function testMatchClauseExample2 (): void
222+ {
223+ $ movie = Query::node ("Movie " );
224+ $ query = Query::new ()
225+ ->match ($ movie )
226+ ->returning ($ movie ->property ("title " ))
227+ ->build ();
228+
229+ $ this ->assertStringMatchesFormat ("MATCH (%s:Movie) RETURN %s.title " , $ query );
230+ }
231+
232+ public function testMatchClauseExample3 (): void
233+ {
234+ $ movie = Query::node ();
235+ $ query = Query::new ()
236+ ->match (Query::node ()->withProperties (['name ' => 'Oliver Stone ' ])->relationshipUni ($ movie ))
237+ ->returning ($ movie ->property ("title " ))
238+ ->build ();
239+
240+ $ this ->assertStringMatchesFormat ("MATCH ({name: 'Oliver Stone'})--(%s) RETURN %s.title " , $ query );
241+ }
242+
243+ public function testMatchClauseExample4 (): void
244+ {
245+ $ movie = Query::node ('Movie ' );
246+ $ query = Query::new ()
247+ ->match (Query::node ('Person ' )->withProperties (['name ' => 'Oliver Stone ' ])->relationshipUni ($ movie ))
248+ ->returning ($ movie ->property ("title " ))
249+ ->build ();
250+
251+ $ this ->assertStringMatchesFormat ("MATCH (:Person {name: 'Oliver Stone'})--(%s:Movie) RETURN %s.title " , $ query );
252+ }
253+
254+ public function testMatchClauseExample5 (): void
255+ {
256+ $ n = Query::node ()->addLabel ('Movie ' , 'Person ' );
257+ $ query = Query::new ()
258+ ->match ($ n )
259+ ->returning (['name ' => $ n ->property ("name " ), 'title ' => $ n ->property ("title " )])
260+ ->build ();
261+
262+ $ this ->assertStringMatchesFormat ("MATCH (%s:Movie:Person) RETURN %s.name AS name, %s.title AS title " , $ query );
263+ }
264+
265+ public function testOptionalMatchClauseExample1 (): void
266+ {
267+ $ movies = Query::node ("Movie " );
268+ $ query = Query::new ()
269+ ->optionalMatch ($ movies )
270+ ->build ();
271+
272+ $ this ->assertSame ("OPTIONAL MATCH (:Movie) " , $ query );
273+ }
134274}
0 commit comments