1515
1616use CodeIgniter \Database \Exceptions \DataException ;
1717use CodeIgniter \Exceptions \ModelException ;
18+ use Tests \Support \Entity \UserWithCasts ;
1819use Tests \Support \Models \JobModel ;
1920use Tests \Support \Models \SecondaryModel ;
21+ use Tests \Support \Models \UserEntityWithCastsModel ;
2022use Tests \Support \Models \UserModel ;
2123
2224/**
@@ -32,6 +34,23 @@ public function testFindReturnsRow(): void
3234 $ this ->assertSame ('Musician ' , $ this ->model ->find (4 )->name );
3335 }
3436
37+ public function testFindReturnsEntityWithCasts (): void
38+ {
39+ $ this ->createModel (UserEntityWithCastsModel::class);
40+ $ this ->model ->builder ()->truncate ();
41+ $ user = new UserWithCasts ([
42+ 'name ' => 'John Smith ' ,
43+ 'email ' => ['foo@example.jp ' , 'bar@example.com ' ],
44+ 'country ' => 'US ' ,
45+ ]);
46+ $ id = $ this ->model ->insert ($ user , true );
47+
48+ $ user = $ this ->model ->find ($ id );
49+
50+ $ this ->assertSame ('John Smith ' , $ user ->name );
51+ $ this ->assertSame (['foo@example.jp ' , 'bar@example.com ' ], $ user ->email );
52+ }
53+
3554 public function testFindReturnsMultipleRows (): void
3655 {
3756 $ this ->createModel (JobModel::class);
0 commit comments