LanguageCookieTestBase.php in Language Cookie 8
File
tests/src/Functional/LanguageCookieTestBase.php
View source
<?php
namespace Drupal\Tests\language_cookie\Functional;
use Drupal\language\Entity\ConfigurableLanguage;
use Drupal\language\Entity\ContentLanguageSettings;
use Drupal\language_cookie\Plugin\LanguageNegotiation\LanguageNegotiationCookie;
use Drupal\language_cookie_test\Plugin\LanguageNegotiation\LanguageCookieFixedNegotiation;
use Drupal\Tests\BrowserTestBase;
abstract class LanguageCookieTestBase extends BrowserTestBase {
protected static $modules = [
'language_cookie',
'content_translation',
'language_cookie_test',
'node',
'path',
'views',
];
protected $defaultTheme = 'stark';
protected function setUp() : void {
parent::setUp();
$admin = $this
->drupalCreateUser([], NULL, TRUE);
$this
->drupalLogin($admin);
$this
->drupalCreateContentType([
'type' => 'page',
]);
$this
->config('system.site')
->set('page.front', '/node')
->save();
ConfigurableLanguage::createFromLangcode('fr')
->save();
$this
->drupalGet('admin/config/regional/language/detection/url');
$this
->submitForm([
'prefix[en]' => 'en',
'prefix[fr]' => 'fr',
], 'Save configuration');
$this
->drupalGet('admin/config/regional/language/detection');
$this
->submitForm([
'language_interface[enabled][' . LanguageNegotiationCookie::METHOD_ID . ']' => 1,
'language_interface[enabled][language-url]' => 1,
'language_interface[enabled][' . LanguageCookieFixedNegotiation::METHOD_ID . ']' => 1,
], 'Save settings');
$config = ContentLanguageSettings::loadByEntityTypeBundle('node', 'page');
$config
->setDefaultLangcode('en')
->setLanguageAlterable(TRUE)
->save();
}
}