22
33declare (strict_types=1 );
44
5+ use Carbon \Carbon ;
6+
57class QueryTest extends TestCase
68{
79 protected static $ started = false ;
@@ -18,12 +20,12 @@ public function setUp(): void
1820 User::create (['name ' => 'Tommy Toe ' , 'age ' => 33 , 'title ' => 'user ' ]);
1921 User::create (['name ' => 'Yvonne Yoe ' , 'age ' => 35 , 'title ' => 'admin ' ]);
2022 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 () );
2729 }
2830
2931 public function tearDown (): void
@@ -181,40 +183,40 @@ public function testWhereDate(): void
181183
182184 public function testWhereDay (): void
183185 {
184- $ day = Birthday::whereDay ('day ' , ' 12 ' )->get ();
186+ $ day = Birthday::whereDay ('birthday ' , 12 )->get ();
185187 $ this ->assertCount (4 , $ day );
186188
187- $ day = Birthday::whereDay ('day ' , ' 11 ' )->get ();
189+ $ day = Birthday::whereDay ('birthday ' , 11 )->get ();
188190 $ this ->assertCount (1 , $ day );
189191 }
190192
191193 public function testWhereMonth (): void
192194 {
193- $ month = Birthday::whereMonth ('month ' , ' 04 ' )->get ();
195+ $ month = Birthday::whereMonth ('birthday ' , 4 )->get ();
194196 $ this ->assertCount (1 , $ month );
195197
196- $ month = Birthday::whereMonth ('month ' , ' 05 ' )->get ();
198+ $ month = Birthday::whereMonth ('birthday ' , 5 )->get ();
197199 $ this ->assertCount (5 , $ month );
198200 }
199201
200202 public function testWhereYear (): void
201203 {
202- $ year = Birthday::whereYear ('year ' , ' 2021 ' )->get ();
204+ $ year = Birthday::whereYear ('birthday ' , 2021 )->get ();
203205 $ this ->assertCount (4 , $ year );
204206
205- $ year = Birthday::whereYear ('year ' , ' 2022 ' )->get ();
207+ $ year = Birthday::whereYear ('birthday ' , 2022 )->get ();
206208 $ this ->assertCount (1 , $ year );
207209
208- $ year = Birthday::whereYear ('year ' , '< ' , ' 2021 ' )->get ();
210+ $ year = Birthday::whereYear ('birthday ' , '< ' , 2021 )->get ();
209211 $ this ->assertCount (1 , $ year );
210212 }
211213
212214 public function testWhereTime (): void
213215 {
214- $ time = Birthday::whereTime ('time ' , '10:53:11 ' )->get ();
216+ $ time = Birthday::whereTime ('birthday ' , '10:53:11 ' )->get ();
215217 $ this ->assertCount (1 , $ time );
216218
217- $ time = Birthday::whereTime ('time ' , '>= ' , '10:53:14 ' )->get ();
219+ $ time = Birthday::whereTime ('birthday ' , '>= ' , '10:53:14 ' )->get ();
218220 $ this ->assertCount (3 , $ time );
219221 }
220222
0 commit comments