@@ -18,12 +18,19 @@ public function setUp(): void
18
18
User::create (['name ' => 'Tommy Toe ' , 'age ' => 33 , 'title ' => 'user ' ]);
19
19
User::create (['name ' => 'Yvonne Yoe ' , 'age ' => 35 , 'title ' => 'admin ' ]);
20
20
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 ' ]);
21
27
}
22
28
23
29
public function tearDown (): void
24
30
{
25
31
User::truncate ();
26
32
Scoped::truncate ();
33
+ Birthday::truncate ();
27
34
parent ::tearDown ();
28
35
}
29
36
@@ -163,6 +170,54 @@ public function testWhereNotNull(): void
163
170
$ this ->assertCount (8 , $ users );
164
171
}
165
172
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
+
166
221
public function testOrder (): void
167
222
{
168
223
$ user = User::whereNotNull ('age ' )->orderBy ('age ' , 'asc ' )->first ();
0 commit comments