Upgraded drupal core with security updates
[yaffs-website] / web / core / tests / Drupal / Tests / Core / Cache / Context / IsFrontPathCacheContextTest.php
1 <?php
2
3 namespace Drupal\Tests\Core\Cache\Context;
4
5 use Drupal\Core\Cache\Context\IsFrontPathCacheContext;
6 use Drupal\Core\Path\PathMatcherInterface;
7 use Drupal\Tests\UnitTestCase;
8
9 /**
10  * @coversDefaultClass \Drupal\Core\Cache\Context\IsFrontPathCacheContext
11  * @group Cache
12  */
13 class IsFrontPathCacheContextTest extends UnitTestCase {
14
15   /**
16    * @covers ::getContext
17    */
18   public function testGetContextFront() {
19     $cache_context = new IsFrontPathCacheContext($this->createPathMatcher(TRUE)->reveal());
20     $this->assertSame('is_front.1', $cache_context->getContext());
21   }
22
23   /**
24    * @covers ::getContext
25    */
26   public function testGetContextNotFront() {
27     $cache_context = new IsFrontPathCacheContext($this->createPathMatcher(FALSE)->reveal());
28     $this->assertSame('is_front.0', $cache_context->getContext());
29   }
30
31   /**
32    * Creates a PathMatcherInterface prophecy.
33    *
34    * @param bool $is_front
35    *
36    * @return \Prophecy\Prophecy\ObjectProphecy
37    */
38   protected function createPathMatcher($is_front) {
39     $path_matcher = $this->prophesize(PathMatcherInterface::class);
40     $path_matcher->isFrontPage()
41       ->willReturn($is_front);
42
43     return $path_matcher;
44   }
45
46 }