示例#1
0
文件: MenuTest.php 项目: travisj/zf
 public function testUseConstructedAclRolesNotFromAclObject()
 {
     $acl = $this->_getAcl();
     $this->_helper->setAcl($acl['acl']);
     $this->_helper->setRole(new Zend_Acl_Role('member'));
     $expected = $this->_getExpected('menu/acl_role_interface.html');
     $this->assertEquals($expected, $this->_helper->render());
 }
示例#2
0
 /**
  * This method tests the privileges required to see a given link
  *
  * @param string $propertyValue the value of the property for finding page
  * @param string $role          the role to test against
  * @param bool   $result        expected result
  * @param string $propertyName  if given method will try to find the given page
  *                              by this property instead of by label
  *
  * @dataProvider getAccessSampleData
  *
  * @return void
  */
 public function testNavigationAccess($propertyValue, $role, $result, $propertyName = 'label')
 {
     $acl = $this->getNavigationAcl();
     if (!$acl) {
         $this->markTestSkipped('You must override the getAcl method in order to use this test');
     }
     $page = $this->_navigation->findBy($propertyName, $propertyValue);
     $this->assertNotNull($page, sprintf("A page with %s set to %s should exists in navigation", ucfirst($propertyName), $propertyValue));
     $menu = new Zend_View_Helper_Navigation_Menu();
     $menu->setRole($role)->setAcl($acl);
     $this->assertSame($result, $menu->accept($page), "Page with label {$page->label} is not accepted for role " . ($role instanceof Zend_Acl_Role_Interface ? $role->getRoleId() : $role));
 }