Procházet zdrojové kódy

fix isGranted check - tests

Quentin Somazzi před 9 roky
rodič
revize
3e7ed9b4c9
1 změnil soubory, kde provedl 23 přidání a 0 odebrání
  1. 23 0
      Tests/Controller/CRUDControllerTest.php

+ 23 - 0
Tests/Controller/CRUDControllerTest.php

@@ -894,6 +894,29 @@ class CRUDControllerTest extends \PHPUnit_Framework_TestCase
         $this->assertSame($expected, $response->getTargetUrl());
     }
 
+    public function testRedirectToWithObject()
+    {
+        $this->admin->expects($this->any())
+            ->method('hasActiveSubclass')
+            ->will($this->returnValue(false));
+
+        $object = new \stdClass();
+
+        $this->admin->expects($this->at(0))
+            ->method('hasRoute')
+            ->with($this->equalTo('edit'))
+            ->will($this->returnValue(true));
+
+        $this->admin->expects($this->any())
+            ->method('isGranted')
+            ->with($this->equalTo(strtoupper('edit')), $object)
+            ->will($this->returnValue(false));
+
+        $response = $this->protectedTestedMethods['redirectTo']->invoke($this->controller, $object, $this->request);
+        $this->assertInstanceOf('Symfony\Component\HttpFoundation\RedirectResponse', $response);
+        $this->assertSame('list', $response->getTargetUrl());
+    }
+
     public function getRedirectToTests()
     {
         return array(