Parcourir la source

Merge pull request #3344 from qsomazzi/tests

Fix isGranted check - tests U
Oskar Stark il y a 9 ans
Parent
commit
26a81b5e0c
1 fichiers modifiés avec 23 ajouts et 0 suppressions
  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(