public function ViewInclusionTest::testViewInclusion in Context 8.4
Tests the view inclusion condition against a view path/route.
File
- tests/
src/ Kernel/ ViewInclusionTest.php, line 65
Class
- ViewInclusionTest
- Tests the view inclusion condition plugin.
Namespace
Drupal\Tests\context\KernelCode
public function testViewInclusion() {
$request = Request::create('');
$request->attributes
->set('_route', 'view-frontpage-page_1');
$request->attributes
->set('_route_object', new Route('/node/'));
$this->requestStack
->push($request);
/** @var \Drupal\context\Plugin\Condition\ViewInclusion $condition */
$condition = $this->pluginManager
->createInstance('view_inclusion');
$condition
->setConfig('view_inclusion', [
'view-frontpage-page_1' => 'view-frontpage-page_1',
]);
$this
->assertTrue($condition
->execute(), 'The path does not match');
$condition
->setConfig('view_inclusion', [
'view-user_admin_people-page_1' => 'view-user_admin_people-page_1',
]);
$this
->assertFalse($condition
->execute(), 'The path does match');
}