class IsFrontPathCacheContextTest
Same name and namespace in other branches
- 11.x core/tests/Drupal/Tests/Core/Cache/Context/IsFrontPathCacheContextTest.php \Drupal\Tests\Core\Cache\Context\IsFrontPathCacheContextTest
- 10 core/tests/Drupal/Tests/Core/Cache/Context/IsFrontPathCacheContextTest.php \Drupal\Tests\Core\Cache\Context\IsFrontPathCacheContextTest
- 9 core/tests/Drupal/Tests/Core/Cache/Context/IsFrontPathCacheContextTest.php \Drupal\Tests\Core\Cache\Context\IsFrontPathCacheContextTest
- 8.9.x core/tests/Drupal/Tests/Core/Cache/Context/IsFrontPathCacheContextTest.php \Drupal\Tests\Core\Cache\Context\IsFrontPathCacheContextTest
Tests Drupal\Core\Cache\Context\IsFrontPathCacheContext.
Attributes
#[CoversClass(IsFrontPathCacheContext::class)]
#[Group('Cache')]
Hierarchy
- class \Drupal\Tests\UnitTestCase uses \Drupal\Tests\DrupalTestCaseTrait, \Drupal\Tests\PhpUnitCompatibilityTrait, \Prophecy\PhpUnit\ProphecyTrait, \Drupal\TestTools\Extension\DeprecationBridge\ExpectDeprecationTrait, \Drupal\Tests\RandomGeneratorTrait extends \PHPUnit\Framework\TestCase
- class \Drupal\Tests\Core\Cache\Context\IsFrontPathCacheContextTest extends \Drupal\Tests\UnitTestCase
Expanded class hierarchy of IsFrontPathCacheContextTest
File
-
core/
tests/ Drupal/ Tests/ Core/ Cache/ Context/ IsFrontPathCacheContextTest.php, line 17
Namespace
Drupal\Tests\Core\Cache\ContextView source
class IsFrontPathCacheContextTest extends UnitTestCase {
/**
* Tests get context front.
*/
public function testGetContextFront() : void {
$cache_context = new IsFrontPathCacheContext($this->createPathMatcher(TRUE)
->reveal());
$this->assertSame('is_front.1', $cache_context->getContext());
}
/**
* Tests get context not front.
*/
public function testGetContextNotFront() : void {
$cache_context = new IsFrontPathCacheContext($this->createPathMatcher(FALSE)
->reveal());
$this->assertSame('is_front.0', $cache_context->getContext());
}
/**
* Creates a PathMatcherInterface prophecy.
*
* @param bool $is_front
* Whether the page is the front page.
*
* @return \Prophecy\Prophecy\ObjectProphecy<\Drupal\Core\Path\PathMatcherInterface>
* The path matcher prophecy.
*/
protected function createPathMatcher($is_front) : ObjectProphecy {
$path_matcher = $this->prophesize(PathMatcherInterface::class);
$path_matcher->isFrontPage()
->willReturn($is_front);
return $path_matcher;
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.