浏览代码

Added test for NoopSecurityHandler buildSecurityInformation method.

Leszek 13 年之前
父节点
当前提交
6d26a4411e
共有 1 个文件被更改,包括 25 次插入4 次删除
  1. 25 4
      Tests/Security/Handler/NoopSecurityHandlerTest.php

+ 25 - 4
Tests/Security/Handler/NoopSecurityHandlerTest.php

@@ -14,11 +14,32 @@ use Sonata\AdminBundle\Security\Handler\NoopSecurityHandler;
 
 class NoopSecurityHandlerTest extends \PHPUnit_Framework_TestCase
 {
-    public function testNoop()
+    /**
+     * @var Sonata\AdminBundle\Security\Handler\NoopSecurityHandler
+     */
+    private $handler = null;
+
+    public function setUp()
     {
-        $handler = new NoopSecurityHandler;
+        $this->handler = new NoopSecurityHandler();
+    }
+
+    public function testIsGranted()
+    {
+        $this->assertTrue($this->handler->isGranted($this->getSonataAdminObject(), array('TOTO')));
+        $this->assertTrue($this->handler->isGranted($this->getSonataAdminObject(), 'TOTO'));
+    }
 
-        $this->assertTrue($handler->isGranted($this->getMock('Sonata\AdminBundle\Admin\AdminInterface'), array('TOTO')));
-        $this->assertTrue($handler->isGranted($this->getMock('Sonata\AdminBundle\Admin\AdminInterface'), 'TOTO'));
+    public function testBuildSecurityInformation()
+    {
+        $this->assertEquals(array(), $this->handler->buildSecurityInformation($this->getSonataAdminObject()));
+    }
+
+    /**
+     * @return Sonata\AdminBundle\Admin\AdminInterface
+     */
+    private function getSonataAdminObject()
+    {
+        return $this->getMock('Sonata\AdminBundle\Admin\AdminInterface');
     }
 }