Breadcrumb404Test.php in Drupal 9
File
core/tests/Drupal/FunctionalTests/Breadcrumb/Breadcrumb404Test.php
View source
<?php
namespace Drupal\FunctionalTests\Breadcrumb;
use Drupal\Tests\block\Traits\BlockCreationTrait;
use Drupal\Tests\BrowserTestBase;
class Breadcrumb404Test extends BrowserTestBase {
use BlockCreationTrait;
protected static $modules = [
'system',
'block',
];
protected $defaultTheme = 'stark';
public function testBreadcrumbOn404Pages() {
$this
->placeBlock('system_breadcrumb_block', [
'id' => 'breadcrumb',
]);
$this
->drupalGet('/not-found-1');
$base_count = count($this
->getBreadcrumbCacheEntries());
$this
->drupalGet('/not-found-2');
$next_count = count($this
->getBreadcrumbCacheEntries());
$this
->assertEquals($base_count, $next_count);
$this
->drupalGet('/not-found-3');
$next_count = count($this
->getBreadcrumbCacheEntries());
$this
->assertEquals($base_count, $next_count);
}
protected function getBreadcrumbCacheEntries() {
$database = \Drupal::database();
$cache_entries = $database
->select('cache_render')
->fields('cache_render')
->condition('cid', $database
->escapeLike('entity_view:block:breadcrumb') . '%', 'LIKE')
->execute()
->fetchAllAssoc('cid');
return $cache_entries;
}
}