LanguageCookiePageCacheTest.php in Language Cookie 8
File
tests/src/Functional/LanguageCookiePageCacheTest.php
View source
<?php
namespace Drupal\Tests\language_cookie\Functional;
class LanguageCookiePageCacheTest extends LanguageCookieTestBase {
protected static $modules = [
'page_cache',
];
public function setUp() : void {
parent::setUp();
$config = $this
->config('system.performance');
$config
->set('cache.page.max_age', 300);
$config
->save();
}
public function testLanguageCookiePageCache() {
$node = $this
->drupalCreateNode([
'title' => 'Title EN',
]);
$node
->addTranslation('fr', [
'title' => 'Title FR',
]);
$node
->save();
$this
->drupalLogout();
$this
->drupalGet('node/' . $node
->id());
$this
->assertSession()
->titleEquals('Title EN | Drupal');
$this
->drupalGet('/fr/user');
$this
->drupalGet('node/' . $node
->id());
$this
->assertSession()
->titleEquals('Title FR | Drupal');
}
public function testLanguageCookieFrontPageCache() {
$node = $this
->drupalCreateNode([
'title' => 'Title EN',
]);
$node
->addTranslation('fr', [
'title' => 'Title FR',
]);
$node
->save();
$this
->config('system.site')
->set('page.front', '/node/' . $node
->id())
->save();
$this
->drupalLogout();
$this
->drupalGet('/fr/user');
$this
->drupalGet('');
$this
->assertSession()
->titleEquals('Title FR | Drupal');
}
}