Tests the custom http kernel of drupal.
Expanded class hierarchy of HttpKernelTest
class HttpKernelTest extends UnitTestCase {
public static function getInfo() {
return array(
'name' => 'HttpKernel (Unit)',
'description' => 'Tests the HttpKernel.',
'group' => 'Routing',
);
}
/**
* Tests the forward method.
*
* @see \Drupal\Core\HttpKernel::setupSubrequest()
*/
public function testSetupSubrequest() {
$container = new ContainerBuilder();
$request = new Request();
$container
->addScope(new Scope('request'));
$container
->enterScope('request');
$container
->set('request', $request, 'request');
$dispatcher = new EventDispatcher();
$controller_resolver = new ControllerResolver($container);
$http_kernel = new HttpKernel($dispatcher, $container, $controller_resolver);
$test_controller = '\\Drupal\\Tests\\Core\\Controller\\TestController';
$random_attribute = $this
->randomName();
$subrequest = $http_kernel
->setupSubrequest($test_controller, array(
'custom_attribute' => $random_attribute,
), array(
'custom_query' => $random_attribute,
));
$this
->assertNotSame($subrequest, $request, 'The subrequest is not the same as the main request.');
$this
->assertEquals($subrequest->attributes
->get('custom_attribute'), $random_attribute, 'Attributes are set from the subrequest.');
$this
->assertEquals($subrequest->query
->get('custom_query'), $random_attribute, 'Query attributes are set from the subrequest.');
$this
->assertEquals($subrequest->attributes
->get('_controller'), $test_controller, 'Controller attribute got set.');
$subrequest = $http_kernel
->setupSubrequest(NULL, array(), array());
$this
->assertFalse($subrequest->attributes
->has('_controller'), 'Ensure that _controller is not copied when no controller was set before.');
}
}
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
HttpKernelTest:: |
public static | function |
This method exists to support the simpletest UI runner. Overrides UnitTestCase:: |
|
HttpKernelTest:: |
public | function | Tests the forward method. | |
UnitTestCase:: |
public | function | Returns a stub config factory that behaves according to the passed in array. | |
UnitTestCase:: |
public | function | Returns a stub config storage that returns the supplied configuration. | |
UnitTestCase:: |
public static | function | Generates a random string containing letters and numbers. |