Skip to content
Snippets Groups Projects
Commit 09b998f1 authored by Angie Byron's avatar Angie Byron
Browse files

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

parent 3d2aad9e
No related branches found
No related tags found
2 merge requests!7452Issue #1797438. HTML5 validation is preventing form submit and not fully...,!789Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10
......@@ -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() {}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment