Skip to content

Commit

Permalink
Add test
Browse files Browse the repository at this point in the history
  • Loading branch information
Tigrov committed Jun 16, 2024
1 parent 42e5f25 commit 28f13f6
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions tests/Driver/Pgsql/ActiveRecordTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -472,4 +472,25 @@ public function testRelationViaArray()
$this->assertSame([1, 3], ArArrayHelper::getColumn($promotions[2]->getItems()[0]->getPromotions(), 'id'));
$this->assertSame([2, 3], ArArrayHelper::getColumn($promotions[2]->getItems()[1]->getPromotions(), 'id'));
}

public function testLazzyRelationViaArray()
{
$this->checkFixture($this->db, 'item');

$itemQuery = new ActiveQuery(Item::class, $this->db);
/** @var Item[] $items */
$items = $itemQuery->all();

$this->assertFalse($items[0]->isRelationPopulated('promotions'));
$this->assertFalse($items[1]->isRelationPopulated('promotions'));
$this->assertFalse($items[2]->isRelationPopulated('promotions'));
$this->assertFalse($items[3]->isRelationPopulated('promotions'));
$this->assertFalse($items[4]->isRelationPopulated('promotions'));

$this->assertSame([1, 3], ArArrayHelper::getColumn($items[0]->getPromotions(), 'id'));
$this->assertSame([1], ArArrayHelper::getColumn($items[1]->getPromotions(), 'id'));
$this->assertSame([2, 3], ArArrayHelper::getColumn($items[2]->getPromotions(), 'id'));
$this->assertSame([2], ArArrayHelper::getColumn($items[3]->getPromotions(), 'id'));
$this->assertSame([2], ArArrayHelper::getColumn($items[4]->getPromotions(), 'id'));
}
}

0 comments on commit 28f13f6

Please sign in to comment.