projects
/
yaffs-website
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Updated Drupal to 8.6. This goes with the following updates because it's possible...
[yaffs-website]
/
web
/
core
/
modules
/
system
/
tests
/
src
/
Unit
/
Breadcrumbs
/
PathBasedBreadcrumbBuilderTest.php
diff --git
a/web/core/modules/system/tests/src/Unit/Breadcrumbs/PathBasedBreadcrumbBuilderTest.php
b/web/core/modules/system/tests/src/Unit/Breadcrumbs/PathBasedBreadcrumbBuilderTest.php
index d1eb8fb903e6d38e6d56b5db1cb3031e2ebebfce..b07f31f62f4470f3b7fa311e21baa5aedd6246a3 100644
(file)
--- a/
web/core/modules/system/tests/src/Unit/Breadcrumbs/PathBasedBreadcrumbBuilderTest.php
+++ b/
web/core/modules/system/tests/src/Unit/Breadcrumbs/PathBasedBreadcrumbBuilderTest.php
@@
-11,6
+11,7
@@
use Drupal\Core\Access\AccessResult;
use Drupal\Core\Cache\Cache;
use Drupal\Core\Link;
use Drupal\Core\Access\AccessResultAllowed;
use Drupal\Core\Cache\Cache;
use Drupal\Core\Link;
use Drupal\Core\Access\AccessResultAllowed;
+use Drupal\Core\Path\PathMatcherInterface;
use Drupal\Core\StringTranslation\TranslationInterface;
use Drupal\Core\Url;
use Drupal\Core\Utility\LinkGeneratorInterface;
use Drupal\Core\StringTranslation\TranslationInterface;
use Drupal\Core\Url;
use Drupal\Core\Utility\LinkGeneratorInterface;
@@
-84,6
+85,13
@@
class PathBasedBreadcrumbBuilderTest extends UnitTestCase {
*/
protected $currentPath;
*/
protected $currentPath;
+ /**
+ * The mocked path matcher service.
+ *
+ * @var \Drupal\Core\Path\PathMatcherInterface|\PHPUnit_Framework_MockObject_MockObject
+ */
+ protected $pathMatcher;
+
/**
* {@inheritdoc}
*
/**
* {@inheritdoc}
*
@@
-106,6
+114,8
@@
class PathBasedBreadcrumbBuilderTest extends UnitTestCase {
->disableOriginalConstructor()
->getMock();
->disableOriginalConstructor()
->getMock();
+ $this->pathMatcher = $this->getMock(PathMatcherInterface::class);
+
$this->builder = new TestPathBasedBreadcrumbBuilder(
$this->context,
$this->accessManager,
$this->builder = new TestPathBasedBreadcrumbBuilder(
$this->context,
$this->accessManager,
@@
-114,7
+124,8
@@
class PathBasedBreadcrumbBuilderTest extends UnitTestCase {
$config_factory,
$this->titleResolver,
$this->currentUser,
$config_factory,
$this->titleResolver,
$this->currentUser,
- $this->currentPath
+ $this->currentPath,
+ $this->pathMatcher
);
$this->builder->setStringTranslation($this->getStringTranslationStub());
);
$this->builder->setStringTranslation($this->getStringTranslationStub());
@@
-123,8
+134,6
@@
class PathBasedBreadcrumbBuilderTest extends UnitTestCase {
->disableOriginalConstructor()
->getMock();
$cache_contexts_manager->method('assertValidTokens')->willReturn(TRUE);
->disableOriginalConstructor()
->getMock();
$cache_contexts_manager->method('assertValidTokens')->willReturn(TRUE);
- $cache_contexts_manager->expects($this->any())
- ->method('validate_tokens');
$container = new Container();
$container->set('cache_contexts_manager', $cache_contexts_manager);
\Drupal::setContainer($container);
$container = new Container();
$container->set('cache_contexts_manager', $cache_contexts_manager);
\Drupal::setContainer($container);
@@
-136,13
+145,13
@@
class PathBasedBreadcrumbBuilderTest extends UnitTestCase {
* @covers ::build
*/
public function testBuildOnFrontpage() {
* @covers ::build
*/
public function testBuildOnFrontpage() {
- $this->
context
->expects($this->once())
- ->method('
getPathInfo
')
- ->will
($this->returnValue('/')
);
+ $this->
pathMatcher
->expects($this->once())
+ ->method('
isFrontPage
')
+ ->will
Return(TRUE
);
$breadcrumb = $this->builder->build($this->getMock('Drupal\Core\Routing\RouteMatchInterface'));
$this->assertEquals([], $breadcrumb->getLinks());
$breadcrumb = $this->builder->build($this->getMock('Drupal\Core\Routing\RouteMatchInterface'));
$this->assertEquals([], $breadcrumb->getLinks());
- $this->assertEquals(['url.path.parent'], $breadcrumb->getCacheContexts());
+ $this->assertEquals(['url.path.
is_front', 'url.path.
parent'], $breadcrumb->getCacheContexts());
$this->assertEquals([], $breadcrumb->getCacheTags());
$this->assertEquals(Cache::PERMANENT, $breadcrumb->getCacheMaxAge());
}
$this->assertEquals([], $breadcrumb->getCacheTags());
$this->assertEquals(Cache::PERMANENT, $breadcrumb->getCacheMaxAge());
}
@@
-159,7
+168,7
@@
class PathBasedBreadcrumbBuilderTest extends UnitTestCase {
$breadcrumb = $this->builder->build($this->getMock('Drupal\Core\Routing\RouteMatchInterface'));
$this->assertEquals([0 => new Link('Home', new Url('<front>'))], $breadcrumb->getLinks());
$breadcrumb = $this->builder->build($this->getMock('Drupal\Core\Routing\RouteMatchInterface'));
$this->assertEquals([0 => new Link('Home', new Url('<front>'))], $breadcrumb->getLinks());
- $this->assertEquals(['url.path.parent'], $breadcrumb->getCacheContexts());
+ $this->assertEquals(['url.path.
is_front', 'url.path.
parent'], $breadcrumb->getCacheContexts());
$this->assertEquals([], $breadcrumb->getCacheTags());
$this->assertEquals(Cache::PERMANENT, $breadcrumb->getCacheMaxAge());
}
$this->assertEquals([], $breadcrumb->getCacheTags());
$this->assertEquals(Cache::PERMANENT, $breadcrumb->getCacheMaxAge());
}
@@
-180,7
+189,7
@@
class PathBasedBreadcrumbBuilderTest extends UnitTestCase {
$this->requestMatcher->expects($this->exactly(1))
->method('matchRequest')
$this->requestMatcher->expects($this->exactly(1))
->method('matchRequest')
- ->will($this->returnCallback(function(Request $request) use ($route_1) {
+ ->will($this->returnCallback(function
(Request $request) use ($route_1) {
if ($request->getPathInfo() == '/example') {
return [
RouteObjectInterface::ROUTE_NAME => 'example',
if ($request->getPathInfo() == '/example') {
return [
RouteObjectInterface::ROUTE_NAME => 'example',
@@
-194,7
+203,11
@@
class PathBasedBreadcrumbBuilderTest extends UnitTestCase {
$breadcrumb = $this->builder->build($this->getMock('Drupal\Core\Routing\RouteMatchInterface'));
$this->assertEquals([0 => new Link('Home', new Url('<front>')), 1 => new Link('Example', new Url('example'))], $breadcrumb->getLinks());
$breadcrumb = $this->builder->build($this->getMock('Drupal\Core\Routing\RouteMatchInterface'));
$this->assertEquals([0 => new Link('Home', new Url('<front>')), 1 => new Link('Example', new Url('example'))], $breadcrumb->getLinks());
- $this->assertEquals(['url.path.parent', 'user.permissions'], $breadcrumb->getCacheContexts());
+ $this->assertEquals([
+ 'url.path.is_front',
+ 'url.path.parent',
+ 'user.permissions',
+ ], $breadcrumb->getCacheContexts());
$this->assertEquals([], $breadcrumb->getCacheTags());
$this->assertEquals(Cache::PERMANENT, $breadcrumb->getCacheMaxAge());
}
$this->assertEquals([], $breadcrumb->getCacheTags());
$this->assertEquals(Cache::PERMANENT, $breadcrumb->getCacheMaxAge());
}
@@
-216,7
+229,7
@@
class PathBasedBreadcrumbBuilderTest extends UnitTestCase {
$this->requestMatcher->expects($this->exactly(2))
->method('matchRequest')
$this->requestMatcher->expects($this->exactly(2))
->method('matchRequest')
- ->will($this->returnCallback(function(Request $request) use ($route_1, $route_2) {
+ ->will($this->returnCallback(function
(Request $request) use ($route_1, $route_2) {
if ($request->getPathInfo() == '/example/bar') {
return [
RouteObjectInterface::ROUTE_NAME => 'example_bar',
if ($request->getPathInfo() == '/example/bar') {
return [
RouteObjectInterface::ROUTE_NAME => 'example_bar',
@@
-245,7
+258,12
@@
class PathBasedBreadcrumbBuilderTest extends UnitTestCase {
new Link('Example', new Url('example')),
new Link('Bar', new Url('example_bar')),
], $breadcrumb->getLinks());
new Link('Example', new Url('example')),
new Link('Bar', new Url('example_bar')),
], $breadcrumb->getLinks());
- $this->assertEquals(['bar', 'url.path.parent', 'user.permissions'], $breadcrumb->getCacheContexts());
+ $this->assertEquals([
+ 'bar',
+ 'url.path.is_front',
+ 'url.path.parent',
+ 'user.permissions',
+ ], $breadcrumb->getCacheContexts());
$this->assertEquals(['example'], $breadcrumb->getCacheTags());
$this->assertEquals(Cache::PERMANENT, $breadcrumb->getCacheMaxAge());
}
$this->assertEquals(['example'], $breadcrumb->getCacheTags());
$this->assertEquals(Cache::PERMANENT, $breadcrumb->getCacheMaxAge());
}
@@
-272,7
+290,7
@@
class PathBasedBreadcrumbBuilderTest extends UnitTestCase {
// No path matched, though at least the frontpage is displayed.
$this->assertEquals([0 => new Link('Home', new Url('<front>'))], $breadcrumb->getLinks());
// No path matched, though at least the frontpage is displayed.
$this->assertEquals([0 => new Link('Home', new Url('<front>'))], $breadcrumb->getLinks());
- $this->assertEquals(['url.path.parent'], $breadcrumb->getCacheContexts());
+ $this->assertEquals(['url.path.
is_front', 'url.path.
parent'], $breadcrumb->getCacheContexts());
$this->assertEquals([], $breadcrumb->getCacheTags());
$this->assertEquals(Cache::PERMANENT, $breadcrumb->getCacheMaxAge());
}
$this->assertEquals([], $breadcrumb->getCacheTags());
$this->assertEquals(Cache::PERMANENT, $breadcrumb->getCacheMaxAge());
}
@@
-316,7
+334,7
@@
class PathBasedBreadcrumbBuilderTest extends UnitTestCase {
// No path matched, though at least the frontpage is displayed.
$this->assertEquals([0 => new Link('Home', new Url('<front>'))], $breadcrumb->getLinks());
// No path matched, though at least the frontpage is displayed.
$this->assertEquals([0 => new Link('Home', new Url('<front>'))], $breadcrumb->getLinks());
- $this->assertEquals(['url.path.parent'], $breadcrumb->getCacheContexts());
+ $this->assertEquals(['url.path.
is_front', 'url.path.
parent'], $breadcrumb->getCacheContexts());
$this->assertEquals([], $breadcrumb->getCacheTags());
$this->assertEquals(Cache::PERMANENT, $breadcrumb->getCacheMaxAge());
}
$this->assertEquals([], $breadcrumb->getCacheTags());
$this->assertEquals(Cache::PERMANENT, $breadcrumb->getCacheMaxAge());
}
@@
-346,7
+364,7
@@
class PathBasedBreadcrumbBuilderTest extends UnitTestCase {
$this->requestMatcher->expects($this->exactly(1))
->method('matchRequest')
$this->requestMatcher->expects($this->exactly(1))
->method('matchRequest')
- ->will($this->returnCallback(function(Request $request) use ($route_1) {
+ ->will($this->returnCallback(function
(Request $request) use ($route_1) {
if ($request->getPathInfo() == '/user/1') {
return [
RouteObjectInterface::ROUTE_NAME => 'user_page',
if ($request->getPathInfo() == '/user/1') {
return [
RouteObjectInterface::ROUTE_NAME => 'user_page',
@@
-364,7
+382,11
@@
class PathBasedBreadcrumbBuilderTest extends UnitTestCase {
$breadcrumb = $this->builder->build($this->getMock('Drupal\Core\Routing\RouteMatchInterface'));
$this->assertEquals([0 => new Link('Home', new Url('<front>')), 1 => new Link('Admin', new Url('user_page'))], $breadcrumb->getLinks());
$breadcrumb = $this->builder->build($this->getMock('Drupal\Core\Routing\RouteMatchInterface'));
$this->assertEquals([0 => new Link('Home', new Url('<front>')), 1 => new Link('Admin', new Url('user_page'))], $breadcrumb->getLinks());
- $this->assertEquals(['url.path.parent', 'user.permissions'], $breadcrumb->getCacheContexts());
+ $this->assertEquals([
+ 'url.path.is_front',
+ 'url.path.parent',
+ 'user.permissions',
+ ], $breadcrumb->getCacheContexts());
$this->assertEquals([], $breadcrumb->getCacheTags());
$this->assertEquals(Cache::PERMANENT, $breadcrumb->getCacheMaxAge());
}
$this->assertEquals([], $breadcrumb->getCacheTags());
$this->assertEquals(Cache::PERMANENT, $breadcrumb->getCacheMaxAge());
}