@@ -18,12 +18,19 @@ public function setUp(): void
1818 User::create (['name ' => 'Tommy Toe ' , 'age ' => 33 , 'title ' => 'user ' ]);
1919 User::create (['name ' => 'Yvonne Yoe ' , 'age ' => 35 , 'title ' => 'admin ' ]);
2020 User::create (['name ' => 'Error ' , 'age ' => null , 'title ' => null ]);
21+ Birthday::create (['name ' => 'Mark Moe ' , 'birthday ' => '2020-04-10 ' , 'day ' => '10 ' , 'month ' => '04 ' , "year " => '2020 ' , 'time ' => '10:53:11 ' ]);
22+ Birthday::create (['name ' => 'Jane Doe ' , 'birthday ' => '2021-05-12 ' , 'day ' => '12 ' , 'month ' => '05 ' , "year " => '2021 ' , 'time ' => '10:53:12 ' ]);
23+ Birthday::create (['name ' => 'Harry Hoe ' , 'birthday ' => '2021-05-11 ' , 'day ' => '11 ' , 'month ' => '05 ' , "year " => '2021 ' , 'time ' => '10:53:13 ' ]);
24+ Birthday::create (['name ' => 'Robert Doe ' , 'birthday ' => '2021-05-12 ' , 'day ' => '12 ' , 'month ' => '05 ' , "year " => '2021 ' , 'time ' => '10:53:14 ' ]);
25+ Birthday::create (['name ' => 'Mark Moe ' , 'birthday ' => '2021-05-12 ' , 'day ' => '12 ' , 'month ' => '05 ' , "year " => '2021 ' , 'time ' => '10:53:15 ' ]);
26+ Birthday::create (['name ' => 'Mark Moe ' , 'birthday ' => '2022-05-12 ' , 'day ' => '12 ' , 'month ' => '05 ' , "year " => '2022 ' , 'time ' => '10:53:16 ' ]);
2127 }
2228
2329 public function tearDown (): void
2430 {
2531 User::truncate ();
2632 Scoped::truncate ();
33+ Birthday::truncate ();
2734 parent ::tearDown ();
2835 }
2936
@@ -163,6 +170,54 @@ public function testWhereNotNull(): void
163170 $ this ->assertCount (8 , $ users );
164171 }
165172
173+ public function testWhereDate (): void
174+ {
175+ $ birthdayCount = Birthday::whereDate ('birthday ' , '2021-05-12 ' )->get ();
176+ $ this ->assertCount (3 , $ birthdayCount );
177+
178+ $ birthdayCount = Birthday::whereDate ('birthday ' , '2021-05-11 ' )->get ();
179+ $ this ->assertCount (1 , $ birthdayCount );
180+ }
181+
182+ public function testWhereDay (): void
183+ {
184+ $ day = Birthday::whereDay ('day ' , '12 ' )->get ();
185+ $ this ->assertCount (4 , $ day );
186+
187+ $ day = Birthday::whereDay ('day ' , '11 ' )->get ();
188+ $ this ->assertCount (1 , $ day );
189+ }
190+
191+ public function testWhereMonth (): void
192+ {
193+ $ month = Birthday::whereMonth ('month ' , '04 ' )->get ();
194+ $ this ->assertCount (1 , $ month );
195+
196+ $ month = Birthday::whereMonth ('month ' , '05 ' )->get ();
197+ $ this ->assertCount (5 , $ month );
198+ }
199+
200+ public function testWhereYear (): void
201+ {
202+ $ year = Birthday::whereYear ('year ' , '2021 ' )->get ();
203+ $ this ->assertCount (4 , $ year );
204+
205+ $ year = Birthday::whereYear ('year ' , '2022 ' )->get ();
206+ $ this ->assertCount (1 , $ year );
207+
208+ $ year = Birthday::whereYear ('year ' , '< ' , '2021 ' )->get ();
209+ $ this ->assertCount (1 , $ year );
210+ }
211+
212+ public function testWhereTime (): void
213+ {
214+ $ time = Birthday::whereTime ('time ' , '10:53:11 ' )->get ();
215+ $ this ->assertCount (1 , $ time );
216+
217+ $ time = Birthday::whereTime ('time ' , '>= ' , '10:53:14 ' )->get ();
218+ $ this ->assertCount (3 , $ time );
219+ }
220+
166221 public function testOrder (): void
167222 {
168223 $ user = User::whereNotNull ('age ' )->orderBy ('age ' , 'asc ' )->first ();
0 commit comments