Skip to content

Commit d74a83f

Browse files
committed
Merge branch 'master' into remove-ActiveQuery-find
# Conflicts: # tests/ActiveQueryFindTest.php # tests/ActiveQueryTest.php # tests/RepositoryTraitTest.php
2 parents 9eed333 + 18d9a58 commit d74a83f

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
-493
lines changed

tests/ActiveQueryFindTest.php

Lines changed: 2 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@ abstract class ActiveQueryFindTest extends TestCase
2020
{
2121
public function testFindScalar(): void
2222
{
23-
$this->checkFixture($this->db(), 'customer');
24-
2523
$customerQuery = new ActiveQuery(Customer::class);
2624

2725
/** query scalar */
@@ -32,8 +30,6 @@ public function testFindScalar(): void
3230

3331
public function testFindExists(): void
3432
{
35-
$this->checkFixture($this->db(), 'customer');
36-
3733
$customerQuery = new ActiveQuery(Customer::class);
3834

3935
$this->assertTrue($customerQuery->where(['[[id]]' => 2])->exists());
@@ -45,25 +41,21 @@ public function testFindExists(): void
4541

4642
public function testFindColumn(): void
4743
{
48-
$this->checkFixture($this->db(), 'customer');
49-
5044
$customerQuery = new ActiveQuery(Customer::class);
5145

5246
$this->assertEquals(
5347
['user1', 'user2', 'user3'],
5448
$customerQuery->select('[[name]]')->column()
5549
);
5650

57-
$this->assertEquals(
51+
$this->assertSame(
5852
['user3', 'user2', 'user1'],
5953
$customerQuery->orderBy(['[[name]]' => SORT_DESC])->select('[[name]]')->column()
6054
);
6155
}
6256

6357
public function testFindLazyViaTable(): void
6458
{
65-
$this->checkFixture($this->db(), 'order');
66-
6759
$orderQuery = new ActiveQuery(Order::class);
6860

6961
$orders = $orderQuery->findByPk(2);
@@ -76,8 +68,6 @@ public function testFindLazyViaTable(): void
7668

7769
public function testFindEagerViaTable(): void
7870
{
79-
$this->checkFixture($this->db(), 'order');
80-
8171
$orderQuery = new ActiveQuery(Order::class);
8272
$orders = $orderQuery->with('books')->orderBy('id')->all();
8373
$this->assertCount(3, $orders);
@@ -117,8 +107,6 @@ public function testFindEagerViaTable(): void
117107
*/
118108
public function testFindCompositeRelationWithJoin(): void
119109
{
120-
$this->checkFixture($this->db(), 'order_item');
121-
122110
$orderItemQuery = new ActiveQuery(OrderItem::class);
123111

124112
/** @var $orderItems OrderItem */
@@ -133,8 +121,6 @@ public function testFindCompositeRelationWithJoin(): void
133121

134122
public function testFindSimpleRelationWithJoin(): void
135123
{
136-
$this->checkFixture($this->db(), 'order');
137-
138124
$orderQuery = new ActiveQuery(Order::class);
139125

140126
$orders = $orderQuery->findByPk(1);
@@ -152,8 +138,6 @@ public function testFindSimpleRelationWithJoin(): void
152138

153139
public function testFind(): void
154140
{
155-
$this->checkFixture($this->db(), 'customer');
156-
157141
$customerQuery = new ActiveQuery(Customer::class);
158142
$this->assertInstanceOf(ActiveQueryInterface::class, $customerQuery);
159143

@@ -183,8 +167,6 @@ public function testFind(): void
183167

184168
public function testFindAsArray(): void
185169
{
186-
$this->checkFixture($this->db(), 'customer');
187-
188170
/** asArray */
189171
$customerQuery = new ActiveQuery(Customer::class);
190172
$customer = $customerQuery->where(['id' => 2])->asArray()->one();
@@ -221,8 +203,6 @@ public function testFindAsArray(): void
221203

222204
public function testFindIndexBy(): void
223205
{
224-
$this->checkFixture($this->db(), 'customer');
225-
226206
$customerQuery = new ActiveQuery(Customer::class);
227207

228208
$customers = $customerQuery->indexBy('name')->orderBy('id')->all();
@@ -248,8 +228,6 @@ public function testFindIndexBy(): void
248228

249229
public function testFindIndexByAsArray(): void
250230
{
251-
$this->checkFixture($this->db(), 'customer');
252-
253231
$customerQuery = new ActiveQuery(Customer::class);
254232
$customers = $customerQuery->asArray()->indexBy('name')->all();
255233
$this->assertCount(3, $customers);
@@ -292,8 +270,6 @@ public function testFindIndexByAsArray(): void
292270

293271
public function testFindCount(): void
294272
{
295-
$this->checkFixture($this->db(), 'customer');
296-
297273
$customerQuery = new ActiveQuery(Customer::class);
298274
$this->assertEquals(3, $customerQuery->count());
299275
$this->assertEquals(1, $customerQuery->where(['id' => 1])->count());
@@ -310,8 +286,6 @@ public function testFindCount(): void
310286

311287
public function testFindLimit(): void
312288
{
313-
$this->checkFixture($this->db(), 'customer');
314-
315289
/** one */
316290
$customerQuery = new ActiveQuery(Customer::class);
317291
$customer = $customerQuery->orderBy('id')->one();
@@ -361,8 +335,6 @@ public function testFindLimit(): void
361335

362336
public function testFindComplexCondition(): void
363337
{
364-
$this->checkFixture($this->db(), 'customer');
365-
366338
$customerQuery = new ActiveQuery(Customer::class);
367339

368340
$this->assertEquals(
@@ -398,7 +370,7 @@ public function testFindComplexCondition(): void
398370

399371
public function testFindNullValues(): void
400372
{
401-
$this->checkFixture($this->db(), 'customer');
373+
$this->reloadFixtureAfterTest();
402374

403375
$customerQuery = new ActiveQuery(Customer::class);
404376

@@ -413,8 +385,6 @@ public function testFindNullValues(): void
413385

414386
public function testFindEager(): void
415387
{
416-
$this->checkFixture($this->db(), 'customer');
417-
418388
$customerQuery = new ActiveQuery(Customer::class);
419389
$customers = $customerQuery->with('orders')->indexBy('id')->all();
420390

@@ -450,8 +420,6 @@ public function testFindEager(): void
450420

451421
public function testFindEagerViaRelation(): void
452422
{
453-
$this->checkFixture($this->db(), 'order');
454-
455423
$orderQuery = new ActiveQuery(Order::class);
456424
$orders = $orderQuery->with('items')->orderBy('id')->all();
457425
$this->assertCount(3, $orders);
@@ -466,8 +434,6 @@ public function testFindEagerViaRelation(): void
466434

467435
public function testFindNestedRelation(): void
468436
{
469-
$this->checkFixture($this->db(), 'customer');
470-
471437
$customerQuery = new ActiveQuery(Customer::class);
472438
$customers = $customerQuery->with('orders', 'orders.items')->indexBy('id')->all();
473439

@@ -502,8 +468,6 @@ public function testFindNestedRelation(): void
502468
*/
503469
public function testFindEagerViaRelationPreserveOrder(): void
504470
{
505-
$this->checkFixture($this->db(), 'order');
506-
507471
$orderQuery = new ActiveQuery(Order::class);
508472
$orders = $orderQuery->with('itemsInOrder1')->orderBy('created_at')->all();
509473
$this->assertCount(3, $orders);
@@ -532,8 +496,6 @@ public function testFindEagerViaRelationPreserveOrder(): void
532496

533497
public function testFindEagerViaRelationPreserveOrderB(): void
534498
{
535-
$this->checkFixture($this->db(), 'order');
536-
537499
/** different order in via table. */
538500
$orderQuery = new ActiveQuery(Order::class);
539501
$orders = $orderQuery->with('itemsInOrder2')->orderBy('created_at')->all();
@@ -563,8 +525,6 @@ public function testFindEagerViaRelationPreserveOrderB(): void
563525

564526
public function testFindEmptyInCondition(): void
565527
{
566-
$this->checkFixture($this->db(), 'customer');
567-
568528
$customerQuery = new ActiveQuery(Customer::class);
569529
$customers = $customerQuery->where(['id' => [1]])->all();
570530
$this->assertCount(1, $customers);
@@ -581,8 +541,6 @@ public function testFindEmptyInCondition(): void
581541

582542
public function testFindEagerIndexBy(): void
583543
{
584-
$this->checkFixture($this->db(), 'order');
585-
586544
$orderQuery = new ActiveQuery(Order::class);
587545
$order = $orderQuery->with('itemsIndexed')->where(['id' => 1])->one();
588546
$this->assertTrue($order->isRelationPopulated('itemsIndexed'));
@@ -604,8 +562,6 @@ public function testFindEagerIndexBy(): void
604562

605563
public function testFindLazy(): void
606564
{
607-
$this->checkFixture($this->db(), 'customer');
608-
609565
$customerQuery = new ActiveQuery(Customer::class);
610566
$customer = $customerQuery->findByPk(2);
611567
$this->assertFalse($customer->isRelationPopulated('orders'));
@@ -630,8 +586,6 @@ public function testFindLazy(): void
630586

631587
public function testFindLazyVia(): void
632588
{
633-
$this->checkFixture($this->db(), 'order');
634-
635589
$orderQuery = new ActiveQuery(Order::class);
636590
$order = $orderQuery->findByPk(1);
637591

@@ -643,8 +597,6 @@ public function testFindLazyVia(): void
643597

644598
public function testFindByPk(): void
645599
{
646-
$this->checkFixture($this->db(), 'customer');
647-
648600
$customerQuery = new ActiveQuery(new Customer());
649601

650602
$this->assertEquals(
@@ -658,8 +610,6 @@ public function testFindByPk(): void
658610

659611
public function testFindByPkComposite(): void
660612
{
661-
$this->checkFixture($this->db(), 'order_item');
662-
663613
$query = new ActiveQuery(OrderItem::class);
664614

665615
$orderItem = $query->findByPk([1, 2]);
@@ -676,8 +626,6 @@ public function testFindByPkComposite(): void
676626

677627
public function testFindByPkWithoutPk(): void
678628
{
679-
$this->checkFixture($this->db(), 'type');
680-
681629
$query = new ActiveQuery(Type::class);
682630

683631
$this->expectException(InvalidConfigException::class);
@@ -688,8 +636,6 @@ public function testFindByPkWithoutPk(): void
688636

689637
public function testFindByPkWithJoin(): void
690638
{
691-
$this->checkFixture($this->db(), 'order');
692-
693639
$query = new ActiveQuery(Order::class);
694640

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

0 commit comments

Comments
 (0)