Skip to content

Commit

Permalink
Added unit test for navItem of page versions
Browse files Browse the repository at this point in the history
  • Loading branch information
hbugdoll authored Mar 6, 2024
1 parent 34c55fe commit fb9ecc5
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions tests/src/models/NavItemPageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace NavItemPageTest;

use cmstests\WebModelTestCase;
use luya\cms\models\NavItem;
use luya\cms\models\NavItemPage;
use luya\testsuite\fixtures\NgRestModelFixture;
use luya\testsuite\traits\CmsDatabaseTableTrait;
Expand Down Expand Up @@ -107,4 +108,44 @@ public function testRelativeViewPath()
$this->assertStringContainsString('views/cmslayouts'.DIRECTORY_SEPARATOR.'relative.php', $e->getMessage());
}
}

public function testNavItemForPageVersions()
{
$navItemFixture = $this->createCmsNavItemFixture([
1 => [
'id' => 1,
'nav_id' => 11,
'alias' => 'foobar',
'nav_item_type' => 1,
'nav_item_type_id' => 2,
]
]);

$pageFixture = $this->createCmsNavItemPageFixture([
'version1' => [
'id' => 1,
'nav_item_id' => 1,
'version_alias' => 'first',
],
'version2' => [
'id' => 2,
'nav_item_id' => 1,
'version_alias' => 'second',
]
]);

$navItem = $navItemFixture->getModel(1);
$pageVersion1 = $pageFixture->getModel('version1'); // inactive page version
$pageVersion2 = $pageFixture->getModel('version2'); // active page version

$this->assertInstanceOf(NavItem::class, $pageVersion1->navItem);
$this->assertSame(1, $pageVersion1->navItem->id);
$this->assertSame(11, $pageVersion1->navItem->nav_id);
$this->assertSame('foobar', $pageVersion1->navItem->alias);

$this->assertInstanceOf(NavItem::class, $pageVersion2->navItem);
$this->assertSame(1, $pageVersion2->navItem->id);
$this->assertSame(11, $pageVersion2->navItem->nav_id);
$this->assertSame('foobar', $pageVersion2->navItem->alias);
}
}

0 comments on commit fb9ecc5

Please sign in to comment.