Skip to content

Commit 18d9a58

Browse files
authored
Reload Fixture After Test (#418)
1 parent 0497775 commit 18d9a58

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+143
-499
lines changed

tests/ActiveQueryFindTest.php

Lines changed: 2 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,13 @@ abstract class ActiveQueryFindTest extends TestCase
2020
{
2121
public function testFindAll(): void
2222
{
23-
$this->checkFixture($this->db(), 'customer', true);
24-
2523
$customerQuery = new ActiveQuery(Customer::class);
2624
$this->assertCount(1, $customerQuery->findAll(['id' => 1]));
2725
$this->assertCount(3, $customerQuery->findAll(['id' => [1, 2, 3]]));
2826
}
2927

3028
public function testFindScalar(): void
3129
{
32-
$this->checkFixture($this->db(), 'customer');
33-
3430
$customerQuery = new ActiveQuery(Customer::class);
3531

3632
/** query scalar */
@@ -41,8 +37,6 @@ public function testFindScalar(): void
4137

4238
public function testFindExists(): void
4339
{
44-
$this->checkFixture($this->db(), 'customer');
45-
4640
$customerQuery = new ActiveQuery(Customer::class);
4741

4842
$this->assertTrue($customerQuery->where(['[[id]]' => 2])->exists());
@@ -54,25 +48,21 @@ public function testFindExists(): void
5448

5549
public function testFindColumn(): void
5650
{
57-
$this->checkFixture($this->db(), 'customer');
58-
5951
$customerQuery = new ActiveQuery(Customer::class);
6052

6153
$this->assertEquals(
6254
['user1', 'user2', 'user3'],
6355
$customerQuery->select('[[name]]')->column()
6456
);
6557

66-
$this->assertEquals(
58+
$this->assertSame(
6759
['user3', 'user2', 'user1'],
6860
$customerQuery->orderBy(['[[name]]' => SORT_DESC])->select('[[name]]')->column()
6961
);
7062
}
7163

7264
public function testFindBySql(): void
7365
{
74-
$this->checkFixture($this->db(), 'customer');
75-
7666
$customerQuery = new ActiveQuery(Customer::class);
7767

7868
/** find one() */
@@ -94,8 +84,6 @@ public function testFindBySql(): void
9484

9585
public function testFindLazyViaTable(): void
9686
{
97-
$this->checkFixture($this->db(), 'order');
98-
9987
$orderQuery = new ActiveQuery(Order::class);
10088

10189
$orders = $orderQuery->findByPk(2);
@@ -108,8 +96,6 @@ public function testFindLazyViaTable(): void
10896

10997
public function testFindEagerViaTable(): void
11098
{
111-
$this->checkFixture($this->db(), 'order');
112-
11399
$orderQuery = new ActiveQuery(Order::class);
114100
$orders = $orderQuery->with('books')->orderBy('id')->all();
115101
$this->assertCount(3, $orders);
@@ -149,8 +135,6 @@ public function testFindEagerViaTable(): void
149135
*/
150136
public function testFindCompositeRelationWithJoin(): void
151137
{
152-
$this->checkFixture($this->db(), 'order_item');
153-
154138
$orderItemQuery = new ActiveQuery(OrderItem::class);
155139

156140
/** @var $orderItems OrderItem */
@@ -165,8 +149,6 @@ public function testFindCompositeRelationWithJoin(): void
165149

166150
public function testFindSimpleRelationWithJoin(): void
167151
{
168-
$this->checkFixture($this->db(), 'order');
169-
170152
$orderQuery = new ActiveQuery(Order::class);
171153

172154
$orders = $orderQuery->findByPk(1);
@@ -184,8 +166,6 @@ public function testFindSimpleRelationWithJoin(): void
184166

185167
public function testFindOneByColumnName(): void
186168
{
187-
$this->checkFixture($this->db(), 'customer');
188-
189169
$customer = new ActiveQuery(Customer::class);
190170
$customerQuery = new CustomerQuery(Customer::class);
191171

@@ -202,8 +182,6 @@ public function testFindOneByColumnName(): void
202182

203183
public function testFind(): void
204184
{
205-
$this->checkFixture($this->db(), 'customer');
206-
207185
$customerQuery = new ActiveQuery(Customer::class);
208186
$this->assertInstanceOf(ActiveQueryInterface::class, $customerQuery);
209187

@@ -264,8 +242,6 @@ public function testFind(): void
264242

265243
public function testFindAsArray(): void
266244
{
267-
$this->checkFixture($this->db(), 'customer');
268-
269245
/** asArray */
270246
$customerQuery = new ActiveQuery(Customer::class);
271247
$customer = $customerQuery->where(['id' => 2])->asArray()->one();
@@ -302,8 +278,6 @@ public function testFindAsArray(): void
302278

303279
public function testFindIndexBy(): void
304280
{
305-
$this->checkFixture($this->db(), 'customer');
306-
307281
$customerQuery = new ActiveQuery(Customer::class);
308282

309283
$customers = $customerQuery->indexBy('name')->orderBy('id')->all();
@@ -329,8 +303,6 @@ public function testFindIndexBy(): void
329303

330304
public function testFindIndexByAsArray(): void
331305
{
332-
$this->checkFixture($this->db(), 'customer');
333-
334306
$customerQuery = new ActiveQuery(Customer::class);
335307
$customers = $customerQuery->asArray()->indexBy('name')->all();
336308
$this->assertCount(3, $customers);
@@ -373,8 +345,6 @@ public function testFindIndexByAsArray(): void
373345

374346
public function testFindCount(): void
375347
{
376-
$this->checkFixture($this->db(), 'customer');
377-
378348
$customerQuery = new ActiveQuery(Customer::class);
379349
$this->assertEquals(3, $customerQuery->count());
380350
$this->assertEquals(1, $customerQuery->where(['id' => 1])->count());
@@ -391,8 +361,6 @@ public function testFindCount(): void
391361

392362
public function testFindLimit(): void
393363
{
394-
$this->checkFixture($this->db(), 'customer');
395-
396364
/** one */
397365
$customerQuery = new ActiveQuery(Customer::class);
398366
$customer = $customerQuery->orderBy('id')->one();
@@ -442,8 +410,6 @@ public function testFindLimit(): void
442410

443411
public function testFindComplexCondition(): void
444412
{
445-
$this->checkFixture($this->db(), 'customer');
446-
447413
$customerQuery = new ActiveQuery(Customer::class);
448414

449415
$this->assertEquals(
@@ -479,7 +445,7 @@ public function testFindComplexCondition(): void
479445

480446
public function testFindNullValues(): void
481447
{
482-
$this->checkFixture($this->db(), 'customer');
448+
$this->reloadFixtureAfterTest();
483449

484450
$customerQuery = new ActiveQuery(Customer::class);
485451

@@ -494,8 +460,6 @@ public function testFindNullValues(): void
494460

495461
public function testFindEager(): void
496462
{
497-
$this->checkFixture($this->db(), 'customer');
498-
499463
$customerQuery = new ActiveQuery(Customer::class);
500464
$customers = $customerQuery->with('orders')->indexBy('id')->all();
501465

@@ -531,8 +495,6 @@ public function testFindEager(): void
531495

532496
public function testFindEagerViaRelation(): void
533497
{
534-
$this->checkFixture($this->db(), 'order');
535-
536498
$orderQuery = new ActiveQuery(Order::class);
537499
$orders = $orderQuery->with('items')->orderBy('id')->all();
538500
$this->assertCount(3, $orders);
@@ -547,8 +509,6 @@ public function testFindEagerViaRelation(): void
547509

548510
public function testFindNestedRelation(): void
549511
{
550-
$this->checkFixture($this->db(), 'customer');
551-
552512
$customerQuery = new ActiveQuery(Customer::class);
553513
$customers = $customerQuery->with('orders', 'orders.items')->indexBy('id')->all();
554514

@@ -583,8 +543,6 @@ public function testFindNestedRelation(): void
583543
*/
584544
public function testFindEagerViaRelationPreserveOrder(): void
585545
{
586-
$this->checkFixture($this->db(), 'order');
587-
588546
$orderQuery = new ActiveQuery(Order::class);
589547
$orders = $orderQuery->with('itemsInOrder1')->orderBy('created_at')->all();
590548
$this->assertCount(3, $orders);
@@ -613,8 +571,6 @@ public function testFindEagerViaRelationPreserveOrder(): void
613571

614572
public function testFindEagerViaRelationPreserveOrderB(): void
615573
{
616-
$this->checkFixture($this->db(), 'order');
617-
618574
/** different order in via table. */
619575
$orderQuery = new ActiveQuery(Order::class);
620576
$orders = $orderQuery->with('itemsInOrder2')->orderBy('created_at')->all();
@@ -644,8 +600,6 @@ public function testFindEagerViaRelationPreserveOrderB(): void
644600

645601
public function testFindEmptyInCondition(): void
646602
{
647-
$this->checkFixture($this->db(), 'customer');
648-
649603
$customerQuery = new ActiveQuery(Customer::class);
650604
$customers = $customerQuery->where(['id' => [1]])->all();
651605
$this->assertCount(1, $customers);
@@ -662,8 +616,6 @@ public function testFindEmptyInCondition(): void
662616

663617
public function testFindEagerIndexBy(): void
664618
{
665-
$this->checkFixture($this->db(), 'order');
666-
667619
$orderQuery = new ActiveQuery(Order::class);
668620
$order = $orderQuery->with('itemsIndexed')->where(['id' => 1])->one();
669621
$this->assertTrue($order->isRelationPopulated('itemsIndexed'));
@@ -685,8 +637,6 @@ public function testFindEagerIndexBy(): void
685637

686638
public function testFindLazy(): void
687639
{
688-
$this->checkFixture($this->db(), 'customer');
689-
690640
$customerQuery = new ActiveQuery(Customer::class);
691641
$customer = $customerQuery->findByPk(2);
692642
$this->assertFalse($customer->isRelationPopulated('orders'));
@@ -711,8 +661,6 @@ public function testFindLazy(): void
711661

712662
public function testFindLazyVia(): void
713663
{
714-
$this->checkFixture($this->db(), 'order');
715-
716664
$orderQuery = new ActiveQuery(Order::class);
717665
$order = $orderQuery->findByPk(1);
718666

@@ -724,8 +672,6 @@ public function testFindLazyVia(): void
724672

725673
public function testFindByPkComposite(): void
726674
{
727-
$this->checkFixture($this->db(), 'order_item');
728-
729675
$query = new ActiveQuery(OrderItem::class);
730676

731677
$orderItem = $query->findByPk([1, 1]);
@@ -742,8 +688,6 @@ public function testFindByPkComposite(): void
742688

743689
public function testFindByPkWithoutPk(): void
744690
{
745-
$this->checkFixture($this->db(), 'type');
746-
747691
$query = new ActiveQuery(Type::class);
748692

749693
$this->expectException(InvalidConfigException::class);
@@ -754,8 +698,6 @@ public function testFindByPkWithoutPk(): void
754698

755699
public function testFindByPkWithJoin(): void
756700
{
757-
$this->checkFixture($this->db(), 'order');
758-
759701
$query = new ActiveQuery(Order::class);
760702

761703
$query->joinWith('items');

0 commit comments

Comments
 (0)