@@ -20,17 +20,13 @@ abstract class ActiveQueryFindTest extends TestCase
20
20
{
21
21
public function testFindAll (): void
22
22
{
23
- $ this ->checkFixture ($ this ->db (), 'customer ' , true );
24
-
25
23
$ customerQuery = new ActiveQuery (Customer::class);
26
24
$ this ->assertCount (1 , $ customerQuery ->findAll (['id ' => 1 ]));
27
25
$ this ->assertCount (3 , $ customerQuery ->findAll (['id ' => [1 , 2 , 3 ]]));
28
26
}
29
27
30
28
public function testFindScalar (): void
31
29
{
32
- $ this ->checkFixture ($ this ->db (), 'customer ' );
33
-
34
30
$ customerQuery = new ActiveQuery (Customer::class);
35
31
36
32
/** query scalar */
@@ -41,8 +37,6 @@ public function testFindScalar(): void
41
37
42
38
public function testFindExists (): void
43
39
{
44
- $ this ->checkFixture ($ this ->db (), 'customer ' );
45
-
46
40
$ customerQuery = new ActiveQuery (Customer::class);
47
41
48
42
$ this ->assertTrue ($ customerQuery ->where (['[[id]] ' => 2 ])->exists ());
@@ -54,25 +48,21 @@ public function testFindExists(): void
54
48
55
49
public function testFindColumn (): void
56
50
{
57
- $ this ->checkFixture ($ this ->db (), 'customer ' );
58
-
59
51
$ customerQuery = new ActiveQuery (Customer::class);
60
52
61
53
$ this ->assertEquals (
62
54
['user1 ' , 'user2 ' , 'user3 ' ],
63
55
$ customerQuery ->select ('[[name]] ' )->column ()
64
56
);
65
57
66
- $ this ->assertEquals (
58
+ $ this ->assertSame (
67
59
['user3 ' , 'user2 ' , 'user1 ' ],
68
60
$ customerQuery ->orderBy (['[[name]] ' => SORT_DESC ])->select ('[[name]] ' )->column ()
69
61
);
70
62
}
71
63
72
64
public function testFindBySql (): void
73
65
{
74
- $ this ->checkFixture ($ this ->db (), 'customer ' );
75
-
76
66
$ customerQuery = new ActiveQuery (Customer::class);
77
67
78
68
/** find one() */
@@ -94,8 +84,6 @@ public function testFindBySql(): void
94
84
95
85
public function testFindLazyViaTable (): void
96
86
{
97
- $ this ->checkFixture ($ this ->db (), 'order ' );
98
-
99
87
$ orderQuery = new ActiveQuery (Order::class);
100
88
101
89
$ orders = $ orderQuery ->findByPk (2 );
@@ -108,8 +96,6 @@ public function testFindLazyViaTable(): void
108
96
109
97
public function testFindEagerViaTable (): void
110
98
{
111
- $ this ->checkFixture ($ this ->db (), 'order ' );
112
-
113
99
$ orderQuery = new ActiveQuery (Order::class);
114
100
$ orders = $ orderQuery ->with ('books ' )->orderBy ('id ' )->all ();
115
101
$ this ->assertCount (3 , $ orders );
@@ -149,8 +135,6 @@ public function testFindEagerViaTable(): void
149
135
*/
150
136
public function testFindCompositeRelationWithJoin (): void
151
137
{
152
- $ this ->checkFixture ($ this ->db (), 'order_item ' );
153
-
154
138
$ orderItemQuery = new ActiveQuery (OrderItem::class);
155
139
156
140
/** @var $orderItems OrderItem */
@@ -165,8 +149,6 @@ public function testFindCompositeRelationWithJoin(): void
165
149
166
150
public function testFindSimpleRelationWithJoin (): void
167
151
{
168
- $ this ->checkFixture ($ this ->db (), 'order ' );
169
-
170
152
$ orderQuery = new ActiveQuery (Order::class);
171
153
172
154
$ orders = $ orderQuery ->findByPk (1 );
@@ -184,8 +166,6 @@ public function testFindSimpleRelationWithJoin(): void
184
166
185
167
public function testFindOneByColumnName (): void
186
168
{
187
- $ this ->checkFixture ($ this ->db (), 'customer ' );
188
-
189
169
$ customer = new ActiveQuery (Customer::class);
190
170
$ customerQuery = new CustomerQuery (Customer::class);
191
171
@@ -202,8 +182,6 @@ public function testFindOneByColumnName(): void
202
182
203
183
public function testFind (): void
204
184
{
205
- $ this ->checkFixture ($ this ->db (), 'customer ' );
206
-
207
185
$ customerQuery = new ActiveQuery (Customer::class);
208
186
$ this ->assertInstanceOf (ActiveQueryInterface::class, $ customerQuery );
209
187
@@ -264,8 +242,6 @@ public function testFind(): void
264
242
265
243
public function testFindAsArray (): void
266
244
{
267
- $ this ->checkFixture ($ this ->db (), 'customer ' );
268
-
269
245
/** asArray */
270
246
$ customerQuery = new ActiveQuery (Customer::class);
271
247
$ customer = $ customerQuery ->where (['id ' => 2 ])->asArray ()->one ();
@@ -302,8 +278,6 @@ public function testFindAsArray(): void
302
278
303
279
public function testFindIndexBy (): void
304
280
{
305
- $ this ->checkFixture ($ this ->db (), 'customer ' );
306
-
307
281
$ customerQuery = new ActiveQuery (Customer::class);
308
282
309
283
$ customers = $ customerQuery ->indexBy ('name ' )->orderBy ('id ' )->all ();
@@ -329,8 +303,6 @@ public function testFindIndexBy(): void
329
303
330
304
public function testFindIndexByAsArray (): void
331
305
{
332
- $ this ->checkFixture ($ this ->db (), 'customer ' );
333
-
334
306
$ customerQuery = new ActiveQuery (Customer::class);
335
307
$ customers = $ customerQuery ->asArray ()->indexBy ('name ' )->all ();
336
308
$ this ->assertCount (3 , $ customers );
@@ -373,8 +345,6 @@ public function testFindIndexByAsArray(): void
373
345
374
346
public function testFindCount (): void
375
347
{
376
- $ this ->checkFixture ($ this ->db (), 'customer ' );
377
-
378
348
$ customerQuery = new ActiveQuery (Customer::class);
379
349
$ this ->assertEquals (3 , $ customerQuery ->count ());
380
350
$ this ->assertEquals (1 , $ customerQuery ->where (['id ' => 1 ])->count ());
@@ -391,8 +361,6 @@ public function testFindCount(): void
391
361
392
362
public function testFindLimit (): void
393
363
{
394
- $ this ->checkFixture ($ this ->db (), 'customer ' );
395
-
396
364
/** one */
397
365
$ customerQuery = new ActiveQuery (Customer::class);
398
366
$ customer = $ customerQuery ->orderBy ('id ' )->one ();
@@ -442,8 +410,6 @@ public function testFindLimit(): void
442
410
443
411
public function testFindComplexCondition (): void
444
412
{
445
- $ this ->checkFixture ($ this ->db (), 'customer ' );
446
-
447
413
$ customerQuery = new ActiveQuery (Customer::class);
448
414
449
415
$ this ->assertEquals (
@@ -479,7 +445,7 @@ public function testFindComplexCondition(): void
479
445
480
446
public function testFindNullValues (): void
481
447
{
482
- $ this ->checkFixture ( $ this -> db (), ' customer ' );
448
+ $ this ->reloadFixtureAfterTest ( );
483
449
484
450
$ customerQuery = new ActiveQuery (Customer::class);
485
451
@@ -494,8 +460,6 @@ public function testFindNullValues(): void
494
460
495
461
public function testFindEager (): void
496
462
{
497
- $ this ->checkFixture ($ this ->db (), 'customer ' );
498
-
499
463
$ customerQuery = new ActiveQuery (Customer::class);
500
464
$ customers = $ customerQuery ->with ('orders ' )->indexBy ('id ' )->all ();
501
465
@@ -531,8 +495,6 @@ public function testFindEager(): void
531
495
532
496
public function testFindEagerViaRelation (): void
533
497
{
534
- $ this ->checkFixture ($ this ->db (), 'order ' );
535
-
536
498
$ orderQuery = new ActiveQuery (Order::class);
537
499
$ orders = $ orderQuery ->with ('items ' )->orderBy ('id ' )->all ();
538
500
$ this ->assertCount (3 , $ orders );
@@ -547,8 +509,6 @@ public function testFindEagerViaRelation(): void
547
509
548
510
public function testFindNestedRelation (): void
549
511
{
550
- $ this ->checkFixture ($ this ->db (), 'customer ' );
551
-
552
512
$ customerQuery = new ActiveQuery (Customer::class);
553
513
$ customers = $ customerQuery ->with ('orders ' , 'orders.items ' )->indexBy ('id ' )->all ();
554
514
@@ -583,8 +543,6 @@ public function testFindNestedRelation(): void
583
543
*/
584
544
public function testFindEagerViaRelationPreserveOrder (): void
585
545
{
586
- $ this ->checkFixture ($ this ->db (), 'order ' );
587
-
588
546
$ orderQuery = new ActiveQuery (Order::class);
589
547
$ orders = $ orderQuery ->with ('itemsInOrder1 ' )->orderBy ('created_at ' )->all ();
590
548
$ this ->assertCount (3 , $ orders );
@@ -613,8 +571,6 @@ public function testFindEagerViaRelationPreserveOrder(): void
613
571
614
572
public function testFindEagerViaRelationPreserveOrderB (): void
615
573
{
616
- $ this ->checkFixture ($ this ->db (), 'order ' );
617
-
618
574
/** different order in via table. */
619
575
$ orderQuery = new ActiveQuery (Order::class);
620
576
$ orders = $ orderQuery ->with ('itemsInOrder2 ' )->orderBy ('created_at ' )->all ();
@@ -644,8 +600,6 @@ public function testFindEagerViaRelationPreserveOrderB(): void
644
600
645
601
public function testFindEmptyInCondition (): void
646
602
{
647
- $ this ->checkFixture ($ this ->db (), 'customer ' );
648
-
649
603
$ customerQuery = new ActiveQuery (Customer::class);
650
604
$ customers = $ customerQuery ->where (['id ' => [1 ]])->all ();
651
605
$ this ->assertCount (1 , $ customers );
@@ -662,8 +616,6 @@ public function testFindEmptyInCondition(): void
662
616
663
617
public function testFindEagerIndexBy (): void
664
618
{
665
- $ this ->checkFixture ($ this ->db (), 'order ' );
666
-
667
619
$ orderQuery = new ActiveQuery (Order::class);
668
620
$ order = $ orderQuery ->with ('itemsIndexed ' )->where (['id ' => 1 ])->one ();
669
621
$ this ->assertTrue ($ order ->isRelationPopulated ('itemsIndexed ' ));
@@ -685,8 +637,6 @@ public function testFindEagerIndexBy(): void
685
637
686
638
public function testFindLazy (): void
687
639
{
688
- $ this ->checkFixture ($ this ->db (), 'customer ' );
689
-
690
640
$ customerQuery = new ActiveQuery (Customer::class);
691
641
$ customer = $ customerQuery ->findByPk (2 );
692
642
$ this ->assertFalse ($ customer ->isRelationPopulated ('orders ' ));
@@ -711,8 +661,6 @@ public function testFindLazy(): void
711
661
712
662
public function testFindLazyVia (): void
713
663
{
714
- $ this ->checkFixture ($ this ->db (), 'order ' );
715
-
716
664
$ orderQuery = new ActiveQuery (Order::class);
717
665
$ order = $ orderQuery ->findByPk (1 );
718
666
@@ -724,8 +672,6 @@ public function testFindLazyVia(): void
724
672
725
673
public function testFindByPkComposite (): void
726
674
{
727
- $ this ->checkFixture ($ this ->db (), 'order_item ' );
728
-
729
675
$ query = new ActiveQuery (OrderItem::class);
730
676
731
677
$ orderItem = $ query ->findByPk ([1 , 1 ]);
@@ -742,8 +688,6 @@ public function testFindByPkComposite(): void
742
688
743
689
public function testFindByPkWithoutPk (): void
744
690
{
745
- $ this ->checkFixture ($ this ->db (), 'type ' );
746
-
747
691
$ query = new ActiveQuery (Type::class);
748
692
749
693
$ this ->expectException (InvalidConfigException::class);
@@ -754,8 +698,6 @@ public function testFindByPkWithoutPk(): void
754
698
755
699
public function testFindByPkWithJoin (): void
756
700
{
757
- $ this ->checkFixture ($ this ->db (), 'order ' );
758
-
759
701
$ query = new ActiveQuery (Order::class);
760
702
761
703
$ query ->joinWith ('items ' );
0 commit comments