NoopSecurityHandlerTest.php 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. <?php
  2. /*
  3. * This file is part of the Sonata package.
  4. *
  5. * (c) Thomas Rabaix <thomas.rabaix@sonata-project.org>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Sonata\AdminBundle\Tests\Security\Handler;
  11. use Sonata\AdminBundle\Security\Handler\NoopSecurityHandler;
  12. use Sonata\AdminBundle\Admin\AdminInterface;
  13. class NoopSecurityHandlerTest extends \PHPUnit_Framework_TestCase
  14. {
  15. /**
  16. * @var NoopSecurityHandler
  17. */
  18. private $handler = null;
  19. public function setUp()
  20. {
  21. $this->handler = new NoopSecurityHandler();
  22. }
  23. public function testIsGranted()
  24. {
  25. $this->assertTrue($this->handler->isGranted($this->getSonataAdminObject(), array('TOTO')));
  26. $this->assertTrue($this->handler->isGranted($this->getSonataAdminObject(), 'TOTO'));
  27. }
  28. public function testBuildSecurityInformation()
  29. {
  30. $this->assertEquals(array(), $this->handler->buildSecurityInformation($this->getSonataAdminObject()));
  31. }
  32. public function testCreateObjectSecurity()
  33. {
  34. $this->assertNull($this->handler->createObjectSecurity($this->getSonataAdminObject(), new \stdClass()));
  35. }
  36. public function testDeleteObjectSecurity()
  37. {
  38. $this->assertNull($this->handler->deleteObjectSecurity($this->getSonataAdminObject(), new \stdClass()));
  39. }
  40. public function testGetBaseRole()
  41. {
  42. $this->assertEquals('', $this->handler->getBaseRole($this->getSonataAdminObject()));
  43. }
  44. /**
  45. * @return AdminInterface
  46. */
  47. private function getSonataAdminObject()
  48. {
  49. return $this->getMock('Sonata\AdminBundle\Admin\AdminInterface');
  50. }
  51. }