diff --git a/core/lib/Drupal/Core/ControllerResolver.php b/core/lib/Drupal/Core/ControllerResolver.php index 0019f165ad28399b261d3897c59ddcc65dc330c8..abb988964c5939423eff8e8baabdd5e352da9786 100644 --- a/core/lib/Drupal/Core/ControllerResolver.php +++ b/core/lib/Drupal/Core/ControllerResolver.php @@ -60,5 +60,7 @@ protected function createController($controller) { if ($controller[0] instanceof ContainerAwareInterface) { $controller[0]->setContainer($this->container); } + + return $controller; } } diff --git a/core/modules/system/lib/Drupal/system/Tests/Routing/ControllerResolverTest.php b/core/modules/system/lib/Drupal/system/Tests/Routing/ControllerResolverTest.php new file mode 100644 index 0000000000000000000000000000000000000000..46ed2a3919c275f010b27df2c79453bf32927c25 --- /dev/null +++ b/core/modules/system/lib/Drupal/system/Tests/Routing/ControllerResolverTest.php @@ -0,0 +1,43 @@ +<?php + +/** + * @file + * Definition of Drupal\system\Tests\Routing\ControllerResolverTest. + */ + +namespace Drupal\system\Tests\Routing; + +use Symfony\Component\DependencyInjection\Container; +use Symfony\Component\HttpFoundation\Request; + +use Drupal\Core\ControllerResolver; +use Drupal\simpletest\UnitTestBase; + +/** + * Tests that the Drupal-extended ControllerResolver is functioning properly. + */ +class ControllerResolverTest extends UnitTestBase { + + public static function getInfo() { + return array( + 'name' => 'Controller Resolver tests', + 'description' => 'Tests that the Drupal-extended ControllerResolver is functioning properly.', + 'group' => 'Routing', + ); + } + + /** + * Confirms that a container aware controller gets returned. + */ + function testContainerAware() { + $container = new Container(); + $resolver = new ControllerResolver($container); + + $request = Request::create('/some/path'); + $request->attributes->set('_controller', '\Drupal\system\Tests\Routing\MockController::run'); + + $controller = $resolver->getController($request); + + $this->assertTrue($controller[0] instanceof MockController, 'The correct controller object was returned.'); + } +} diff --git a/core/modules/system/lib/Drupal/system/Tests/Routing/MockController.php b/core/modules/system/lib/Drupal/system/Tests/Routing/MockController.php new file mode 100644 index 0000000000000000000000000000000000000000..fe09a7b85243da37e83f374dcd8b3a4af0523113 --- /dev/null +++ b/core/modules/system/lib/Drupal/system/Tests/Routing/MockController.php @@ -0,0 +1,19 @@ +<?php + +/** + * @file + * Definition of Drupal\system\Tests\Routing\MockController. + */ + +namespace Drupal\system\Tests\Routing; + +use Symfony\Component\DependencyInjection\ContainerAware; + +/** + * Dummy class, just for testing. + */ +class MockController extends ContainerAware { + + public function run() {} + +}