Example #1
0
 public function testShowIn()
 {
     $admin = new PostAdmin('sonata.post.admin.post', 'Acme\\NewsBundle\\Entity\\Post', 'SonataNewsBundle:PostAdmin');
     $securityHandler = $this->getMock('Sonata\\AdminBundle\\Security\\Handler\\AclSecurityHandlerInterface');
     $securityHandler->expects($this->any())->method('isGranted')->will($this->returnCallback(function (AdminInterface $adminIn, $attributes, $object = null) use($admin) {
         if ($admin == $adminIn && $attributes == array('LIST')) {
             return true;
         }
         return false;
     }));
     $admin->setSecurityHandler($securityHandler);
     $this->assertTrue($admin->showIn(Admin::CONTEXT_DASHBOARD));
     $this->assertTrue($admin->showIn(Admin::CONTEXT_MENU));
     $this->assertTrue($admin->showIn('foo'));
 }