2
2
3
3
declare (strict_types=1 );
4
4
5
+ use Carbon \Carbon ;
6
+
5
7
class QueryTest extends TestCase
6
8
{
7
9
protected static $ started = false ;
@@ -18,12 +20,12 @@ public function setUp(): void
18
20
User::create (['name ' => 'Tommy Toe ' , 'age ' => 33 , 'title ' => 'user ' ]);
19
21
User::create (['name ' => 'Yvonne Yoe ' , 'age ' => 35 , 'title ' => 'admin ' ]);
20
22
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 '] );
23
+ Birthday::create (['name ' => 'Mark Moe ' , 'birthday ' => Carbon:: parse ( '2020-04-10 10 :53:11 ' )-> toDateTimeString () );
24
+ Birthday::create (['name ' => 'Jane Doe ' , 'birthday ' => Carbon:: parse ( '2021-05-12 10:53:12 ' )-> toDateTimeString () );
25
+ Birthday::create (['name ' => 'Harry Hoe ' , 'birthday ' => Carbon:: parse ( '2021-05-11 10:53:13 ' )-> toDateTimeString () );
26
+ Birthday::create (['name ' => 'Robert Doe ' , 'birthday ' => Carbon:: parse ( '2021-05-12 10:53:14 ' )-> toDateTimeString () );
27
+ Birthday::create (['name ' => 'Mark Moe ' , 'birthday ' => Carbon:: parse ( '2021-05-12 10:53:15 ' )-> toDateTimeString () );
28
+ Birthday::create (['name ' => 'Mark Moe ' , 'birthday ' => Carbon:: parse ( ' 2021 -05-12 10:53:16 ')-> toDateTimeString () );
27
29
}
28
30
29
31
public function tearDown (): void
@@ -181,40 +183,40 @@ public function testWhereDate(): void
181
183
182
184
public function testWhereDay (): void
183
185
{
184
- $ day = Birthday::whereDay ('day ' , ' 12 ' )->get ();
186
+ $ day = Birthday::whereDay ('birthday ' , 12 )->get ();
185
187
$ this ->assertCount (4 , $ day );
186
188
187
- $ day = Birthday::whereDay ('day ' , ' 11 ' )->get ();
189
+ $ day = Birthday::whereDay ('birthday ' , 11 )->get ();
188
190
$ this ->assertCount (1 , $ day );
189
191
}
190
192
191
193
public function testWhereMonth (): void
192
194
{
193
- $ month = Birthday::whereMonth ('month ' , ' 04 ' )->get ();
195
+ $ month = Birthday::whereMonth ('birthday ' , 4 )->get ();
194
196
$ this ->assertCount (1 , $ month );
195
197
196
- $ month = Birthday::whereMonth ('month ' , ' 05 ' )->get ();
198
+ $ month = Birthday::whereMonth ('birthday ' , 5 )->get ();
197
199
$ this ->assertCount (5 , $ month );
198
200
}
199
201
200
202
public function testWhereYear (): void
201
203
{
202
- $ year = Birthday::whereYear ('year ' , ' 2021 ' )->get ();
204
+ $ year = Birthday::whereYear ('birthday ' , 2021 )->get ();
203
205
$ this ->assertCount (4 , $ year );
204
206
205
- $ year = Birthday::whereYear ('year ' , ' 2022 ' )->get ();
207
+ $ year = Birthday::whereYear ('birthday ' , 2022 )->get ();
206
208
$ this ->assertCount (1 , $ year );
207
209
208
- $ year = Birthday::whereYear ('year ' , '< ' , ' 2021 ' )->get ();
210
+ $ year = Birthday::whereYear ('birthday ' , '< ' , 2021 )->get ();
209
211
$ this ->assertCount (1 , $ year );
210
212
}
211
213
212
214
public function testWhereTime (): void
213
215
{
214
- $ time = Birthday::whereTime ('time ' , '10:53:11 ' )->get ();
216
+ $ time = Birthday::whereTime ('birthday ' , '10:53:11 ' )->get ();
215
217
$ this ->assertCount (1 , $ time );
216
218
217
- $ time = Birthday::whereTime ('time ' , '>= ' , '10:53:14 ' )->get ();
219
+ $ time = Birthday::whereTime ('birthday ' , '>= ' , '10:53:14 ' )->get ();
218
220
$ this ->assertCount (3 , $ time );
219
221
}
220
222
0 commit comments