diff --git a/tests/unit/backend/classes/NavigationManagerTest.php b/tests/unit/backend/classes/NavigationManagerTest.php index 2b5be5769..416972f3d 100644 --- a/tests/unit/backend/classes/NavigationManagerTest.php +++ b/tests/unit/backend/classes/NavigationManagerTest.php @@ -59,7 +59,61 @@ class NavigationManagerTest extends TestCase $manager->setContext('October.Tester', 'blog'); $items = $manager->listSideMenuItems(); + $this->assertInternalType('array', $items); $this->assertArrayHasKey('posts', $items); $this->assertArrayHasKey('categories', $items); + + $this->assertInternalType('object', $items['posts']); + $this->assertObjectHasAttribute('code', $items['posts']); + $this->assertObjectHasAttribute('owner', $items['posts']); + $this->assertEquals('posts', $items['posts']->code); + $this->assertEquals('October.Tester', $items['posts']->owner); + + $this->assertObjectHasAttribute('permissions', $items['posts']); + $this->assertInternalType('array', $items['posts']->permissions); + $this->assertCount(1, $items['posts']->permissions); + + $this->assertObjectHasAttribute('order', $items['posts']); + $this->assertObjectHasAttribute('order', $items['categories']); + $this->assertEquals(100, $items['posts']->order); + $this->assertEquals(200, $items['categories']->order); + } + + public function testAddSideMenuItems() + { + $manager = NavigationManager::instance(); + + $manager->addSideMenuItems('October.Tester', 'blog', [ + 'foo' => [ + 'label' => 'Bar', + 'icon' => 'icon-derp', + 'url' => 'http://google.com', + 'permissions' => [ + 'october.tester.access_foo', + 'october.tester.access_bar' + ] + ] + ]); + + $manager->setContext('October.Tester', 'blog'); + $items = $manager->listSideMenuItems(); + + $this->assertInternalType('array', $items); + $this->assertArrayHasKey('foo', $items); + + $this->assertInternalType('object', $items['foo']); + $this->assertObjectHasAttribute('code', $items['foo']); + $this->assertObjectHasAttribute('owner', $items['foo']); + $this->assertObjectHasAttribute('order', $items['foo']); + + $this->assertEquals(-1, $items['foo']->order); + $this->assertEquals('foo', $items['foo']->code); + $this->assertEquals('October.Tester', $items['foo']->owner); + + $this->assertObjectHasAttribute('permissions', $items['foo']); + $this->assertInternalType('array', $items['foo']->permissions); + $this->assertCount(2, $items['foo']->permissions); + $this->assertContains('october.tester.access_foo', $items['foo']->permissions); + $this->assertContains('october.tester.access_bar', $items['foo']->permissions); } } \ No newline at end of file