Add tests that verify the truth of #1343

Plugins should be able to call NavigationManager::addSideMenuItems() without error
This commit is contained in:
Samuel Georges 2015-08-08 12:28:15 +10:00
parent 904db06f5e
commit 5c3dd4f145
1 changed files with 54 additions and 0 deletions

View File

@ -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);
}
}