Security update for Core, with self-updated composer
[yaffs-website] / vendor / symfony / http-kernel / Tests / Controller / ControllerResolverTest.php
index 58ca07fc5361b0ba0113767cc80a24521d9dedf6..190e15ad67bca18f6c81f8c0e9cc15a81e6bfe4a 100644 (file)
@@ -113,12 +113,17 @@ class ControllerResolverTest extends TestCase
     }
 
     /**
-     * @dataProvider      getUndefinedControllers
-     * @expectedException \InvalidArgumentException
+     * @dataProvider getUndefinedControllers
      */
-    public function testGetControllerOnNonUndefinedFunction($controller)
+    public function testGetControllerOnNonUndefinedFunction($controller, $exceptionName = null, $exceptionMessage = null)
     {
         $resolver = $this->createControllerResolver();
+        if (method_exists($this, 'expectException')) {
+            $this->expectException($exceptionName);
+            $this->expectExceptionMessage($exceptionMessage);
+        } else {
+            $this->setExpectedException($exceptionName, $exceptionMessage);
+        }
 
         $request = Request::create('/');
         $request->attributes->set('_controller', $controller);
@@ -128,13 +133,20 @@ class ControllerResolverTest extends TestCase
     public function getUndefinedControllers()
     {
         return array(
-            array('foo'),
-            array('oof::bar'),
-            array('stdClass'),
-            array('Symfony\Component\HttpKernel\Tests\Controller\ControllerResolverTest::bar'),
+            array(1, 'InvalidArgumentException', 'Unable to find controller "1".'),
+            array('foo', 'InvalidArgumentException', 'Unable to find controller "foo".'),
+            array('oof::bar', 'InvalidArgumentException', 'Class "oof" does not exist.'),
+            array('stdClass', 'InvalidArgumentException', 'Unable to find controller "stdClass".'),
+            array('Symfony\Component\HttpKernel\Tests\Controller\ControllerTest::staticsAction', 'InvalidArgumentException', 'The controller for URI "/" is not callable. Expected method "staticsAction" on class "Symfony\Component\HttpKernel\Tests\Controller\ControllerTest", did you mean "staticAction"?'),
+            array('Symfony\Component\HttpKernel\Tests\Controller\ControllerTest::privateAction', 'InvalidArgumentException', 'The controller for URI "/" is not callable. Method "privateAction" on class "Symfony\Component\HttpKernel\Tests\Controller\ControllerTest" should be public and non-abstract'),
+            array('Symfony\Component\HttpKernel\Tests\Controller\ControllerTest::protectedAction', 'InvalidArgumentException', 'The controller for URI "/" is not callable. Method "protectedAction" on class "Symfony\Component\HttpKernel\Tests\Controller\ControllerTest" should be public and non-abstract'),
+            array('Symfony\Component\HttpKernel\Tests\Controller\ControllerTest::undefinedAction', 'InvalidArgumentException', 'The controller for URI "/" is not callable. Expected method "undefinedAction" on class "Symfony\Component\HttpKernel\Tests\Controller\ControllerTest". Available methods: "publicAction", "staticAction"'),
         );
     }
 
+    /**
+     * @group legacy
+     */
     public function testGetArguments()
     {
         $resolver = $this->createControllerResolver();
@@ -184,15 +196,11 @@ class ControllerResolverTest extends TestCase
         $request->attributes->set('foobar', 'foobar');
         $controller = array(new self(), 'controllerMethod3');
 
-        if (\PHP_VERSION_ID === 50316) {
-            $this->markTestSkipped('PHP 5.3.16 has a major bug in the Reflection sub-system');
-        } else {
-            try {
-                $resolver->getArguments($request, $controller);
-                $this->fail('->getArguments() throws a \RuntimeException exception if it cannot determine the argument value');
-            } catch (\Exception $e) {
-                $this->assertInstanceOf('\RuntimeException', $e, '->getArguments() throws a \RuntimeException exception if it cannot determine the argument value');
-            }
+        try {
+            $resolver->getArguments($request, $controller);
+            $this->fail('->getArguments() throws a \RuntimeException exception if it cannot determine the argument value');
+        } catch (\Exception $e) {
+            $this->assertInstanceOf('\RuntimeException', $e, '->getArguments() throws a \RuntimeException exception if it cannot determine the argument value');
         }
 
         $request = Request::create('/');
@@ -202,6 +210,7 @@ class ControllerResolverTest extends TestCase
 
     /**
      * @requires PHP 5.6
+     * @group legacy
      */
     public function testGetVariadicArguments()
     {
@@ -226,6 +235,7 @@ class ControllerResolverTest extends TestCase
 
     /**
      * @expectedException \RuntimeException
+     * @group legacy
      */
     public function testIfExceptionIsThrownWhenMissingAnArgument()
     {
@@ -239,6 +249,7 @@ class ControllerResolverTest extends TestCase
 
     /**
      * @requires PHP 7.1
+     * @group legacy
      */
     public function testGetNullableArguments()
     {
@@ -254,6 +265,7 @@ class ControllerResolverTest extends TestCase
 
     /**
      * @requires PHP 7.1
+     * @group legacy
      */
     public function testGetNullableArgumentsWithDefaults()
     {
@@ -298,3 +310,22 @@ class ControllerResolverTest extends TestCase
 function some_controller_function($foo, $foobar)
 {
 }
+
+class ControllerTest
+{
+    public function publicAction()
+    {
+    }
+
+    private function privateAction()
+    {
+    }
+
+    protected function protectedAction()
+    {
+    }
+
+    public static function staticAction()
+    {
+    }
+}