@@ -58,7 +58,7 @@ public function test_create_and_update_model(): void
5858 $ this ->assertSame ('baz ' , $ foo ->bar );
5959 $ this ->assertInstanceOf (Id::class, $ foo ->id );
6060
61- $ foo = Foo::find ($ foo ->id );
61+ $ foo = Foo::get ($ foo ->id );
6262
6363 $ this ->assertSame ('baz ' , $ foo ->bar );
6464 $ this ->assertInstanceOf (Id::class, $ foo ->id );
@@ -67,7 +67,7 @@ public function test_create_and_update_model(): void
6767 bar: 'boo ' ,
6868 );
6969
70- $ foo = Foo::find ($ foo ->id );
70+ $ foo = Foo::get ($ foo ->id );
7171
7272 $ this ->assertSame ('boo ' , $ foo ->bar );
7373 }
@@ -109,7 +109,7 @@ public function test_complex_query(): void
109109
110110 $ book = $ book ->save ();
111111
112- $ book = Book::find ($ book ->id , relations: ['author ' ]);
112+ $ book = Book::get ($ book ->id , relations: ['author ' ]);
113113
114114 $ this ->assertEquals (1 , $ book ->id ->id );
115115 $ this ->assertSame ('Book Title ' , $ book ->title );
@@ -273,7 +273,7 @@ public function test_has_many_through_relation(): void
273273 (new ThroughModel (parent: $ parent , child: $ childA ))->save ();
274274 (new ThroughModel (parent: $ parent , child: $ childB ))->save ();
275275
276- $ parent = ParentModel::find ($ parent ->id , ['through.child ' ]);
276+ $ parent = ParentModel::get ($ parent ->id , ['through.child ' ]);
277277
278278 $ this ->assertSame ('A ' , $ parent ->through [1 ]->child ->name );
279279 $ this ->assertSame ('B ' , $ parent ->through [2 ]->child ->name );
@@ -290,7 +290,7 @@ public function test_empty_has_many_relation(): void
290290
291291 $ parent = (new ParentModel (name: 'parent ' ))->save ();
292292
293- $ parent = ParentModel::find ($ parent ->id , ['through.child ' ]);
293+ $ parent = ParentModel::get ($ parent ->id , ['through.child ' ]);
294294
295295 $ this ->assertInstanceOf (ParentModel::class, $ parent );
296296 $ this ->assertEmpty ($ parent ->through );
@@ -313,8 +313,8 @@ public function test_has_one_relation(): void
313313
314314 (new ThroughModel (parent: $ parent , child: $ childA , child2: $ childB ))->save ();
315315
316- $ child = ChildModel::find ($ childA ->id , ['through.parent ' ]);
317- $ child2 = ChildModel::find ($ childB ->id , ['through2.parent ' ]);
316+ $ child = ChildModel::get ($ childA ->id , ['through.parent ' ]);
317+ $ child2 = ChildModel::get ($ childB ->id , ['through2.parent ' ]);
318318
319319 $ this ->assertSame ('parent ' , $ child ->through ->parent ->name );
320320 $ this ->assertSame ('parent ' , $ child2 ->through2 ->parent ->name );
@@ -337,8 +337,8 @@ public function test_invalid_has_one_relation(): void
337337
338338 (new ThroughModel (parent: $ parent , child: $ childA , child2: $ childB ))->save ();
339339
340- $ child = ChildModel::find ($ childA ->id , ['through.parent ' ]);
341- $ child2 = ChildModel::find ($ childB ->id , ['through2.parent ' ]);
340+ $ child = ChildModel::get ($ childA ->id , ['through.parent ' ]);
341+ $ child2 = ChildModel::get ($ childB ->id , ['through2.parent ' ]);
342342
343343 $ this ->assertSame ('parent ' , $ child ->through ->parent ->name );
344344 $ this ->assertSame ('parent ' , $ child2 ->through2 ->parent ->name );
@@ -462,8 +462,8 @@ public function test_delete(): void
462462
463463 $ foo ->delete ();
464464
465- $ this ->assertNull (Foo::find ($ foo ->getId ()));
466- $ this ->assertNotNull (Foo::find ($ bar ->getId ()));
465+ $ this ->assertNull (Foo::get ($ foo ->getId ()));
466+ $ this ->assertNotNull (Foo::get ($ bar ->getId ()));
467467 }
468468
469469 public function test_property_with_carbon_type (): void
@@ -499,4 +499,27 @@ enum: CasterEnum::BAR,
499499 $ this ->assertSame (['a ' , 'b ' , 'c ' ], $ model ->array );
500500 $ this ->assertSame (CasterEnum::BAR , $ model ->enum );
501501 }
502+
503+ public function test_find (): void
504+ {
505+ $ this ->migrate (
506+ CreateMigrationsTable::class,
507+ CreateATable::class,
508+ CreateBTable::class,
509+ CreateCTable::class,
510+ );
511+
512+ (new C (name: 'one ' ))->save ();
513+ (new C (name: 'two ' ))->save ();
514+
515+ /** @var C[] */
516+ $ valid = C::find (name: 'one ' )->all ();
517+
518+ $ this ->assertCount (1 , $ valid );
519+ $ this ->assertSame ($ valid [0 ]->name , 'one ' );
520+
521+ $ invalid = C::find (name: 'three ' )->all ();
522+
523+ $ this ->assertCount (0 , $ invalid );
524+ }
502525}
0 commit comments