Commit 09b998f1 authored by webchick's avatar webchick
Browse files

Issue #1777430 by Crell, sun, tim.plunkett: Fixed Allow for ContainerAware controllers.

parent 3d2aad9e
......@@ -60,5 +60,7 @@ protected function createController($controller) {
if ($controller[0] instanceof ContainerAwareInterface) {
$controller[0]->setContainer($this->container);
}
return $controller;
}
}
<?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.');
}
}
<?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() {}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment