Namespace
Drupal\Tests\cache_example\Functional
File
-
modules/cache_example/tests/src/Functional/CacheExampleTest.php
View source
<?php
namespace Drupal\Tests\cache_example\Functional;
use Drupal\Tests\BrowserTestBase;
class CacheExampleTest extends BrowserTestBase {
protected $defaultTheme = 'stark';
protected static $modules = [
'cache_example',
];
protected $profile = 'minimal';
public function testCacheExampleMenu() {
$assert = $this->assertSession();
$this->drupalGet('');
$assert->statusCodeEquals(200);
$assert->linkByHrefExists('examples/cache-example');
$this->drupalGet('examples/cache-example');
$assert->statusCodeEquals(200);
}
public function testCacheExampleBasic() {
$assert = $this->assertSession();
$admin_user = $this->drupalCreateUser([
'administer site configuration',
]);
$this->drupalLogin($admin_user);
$this->drupalGet('examples/cache-example');
$assert->pageTextContains('Source: actual file search');
$this->drupalGet('examples/cache-example');
$assert->pageTextContains('Source: cached');
$this->drupalGet('examples/cache-example');
$this->submitForm([], 'Explicitly remove cached file count');
$assert->pageTextContains('Source: actual file search');
$assert->pageTextContains('Cache item does not exist');
$this->drupalGet('examples/cache-example');
$this->submitForm([
'expiration' => -10,
], 'Create a cache item with this expiration');
$assert->pageTextContains('Cache_item is invalid');
$this->drupalGet('examples/cache-example');
$this->submitForm([
'cache_clear_type' => 'expire',
], 'Clear or expire cache');
$assert->pageTextContains('Cache item does not exist');
$this->drupalGet('examples/cache-example');
$this->submitForm([
'expiration' => 'never_remove',
], 'Create a cache item with this expiration');
$assert->pageTextContains('Cache item exists and is set to expire at Never expires');
$this->drupalGet('examples/cache-example');
$this->submitForm([
'cache_clear_type' => 'expire',
], 'Clear or expire cache');
$assert->pageTextContains('Cache item exists and is set to expire at Never expires');
$this->drupalGet('examples/cache-example');
$this->submitForm([
'cache_clear_type' => 'remove_tag',
], 'Clear or expire cache');
$assert->pageTextContains('Cache_item is invalid');
$this->drupalGet('examples/cache-example');
$this->submitForm([
'cache_clear_type' => 'remove_all',
], 'Clear or expire cache');
$assert->pageTextContains('Cache item does not exist');
}
}
Classes