Ejemplo n.º 1
0
 public function testAclFiltersAwayPagesFromContainerSearch()
 {
     $acl = new Zend_Acl();
     $acl->addRole(new Zend_Acl_Role('member'));
     $acl->addRole(new Zend_Acl_Role('admin'));
     $acl->add(new Zend_Acl_Resource('protected'));
     $acl->allow('admin', 'protected');
     $this->_helper->setAcl($acl);
     $this->_helper->setRole($acl->getRole('member'));
     $oldContainer = $this->_helper->getContainer();
     $container = $this->_helper->getContainer();
     $iterator = new RecursiveIteratorIterator($container, RecursiveIteratorIterator::SELF_FIRST);
     foreach ($iterator as $page) {
         $page->resource = 'protected';
     }
     $this->_helper->setContainer($container);
     $active = $this->_helper->findOneByLabel('Home');
     $search = array('start' => 'Page 1', 'next' => 'Page 1', 'prev' => 'Page 1.1', 'chapter' => 'Home', 'section' => 'Page 1', 'subsection' => 'Page 2.2');
     $expected = array();
     $actual = array();
     foreach ($search as $type => $active) {
         $expected[$type] = false;
         $active = $this->_helper->findOneByLabel($active);
         $found = $this->_helper->findRelation($active, 'rel', $type);
         if (null === $found) {
             $actual[$type] = false;
         } elseif (is_array($found)) {
             $actual[$type] = 'array(' . count($found) . ')';
         } else {
             $actual[$type] = $found->getLabel();
         }
     }
     $this->assertEquals($expected, $actual);
 }