public function RequestDomainTest::testRequestDomain in Context 8.4
Tests the request domain condition against a path/route.
File
- tests/
src/ Kernel/ RequestDomainTest.php, line 64
Class
- RequestDomainTest
- Tests the request domain condition plugin.
Namespace
Drupal\Tests\context\KernelCode
public function testRequestDomain() {
$request = Request::create('/');
$this->requestStack
->push($request);
$domain = $request
->getHost();
/** @var \Drupal\context\Plugin\Condition\RequestDomain $condition */
$condition = $this->pluginManager
->createInstance('request_domain');
$condition
->setConfig('domains', $domain);
$this
->assertTrue($condition
->execute(), 'Domains match');
$this
->assertEquals($condition
->summary(), 'Return true on the following domains: ' . $domain, 'Domains match.');
$condition
->setConfig('domains', 'example.com');
$this
->assertFalse($condition
->execute(), 'Domains do not match');
}