protected function HtmlTitleTest::setUp in HTML Title 8
Overrides BrowserTestBase::setUp
File
- tests/
src/ Functional/ HtmlTitleTest.php, line 79
Class
- HtmlTitleTest
- Tests the HTML Title module.
Namespace
Drupal\Tests\html_title\FunctionalCode
protected function setUp() : void {
parent::setUp();
$this
->drupalPlaceBlock('system_breadcrumb_block');
$this
->drupalPlaceBlock('page_title_block');
$this
->config('html_title.settings')
->set('allow_html_tags', '<br> <sub> <sup>')
->save();
$this->adminUser = $this
->createUser([], NULL, TRUE);
$this
->drupalLogin($this->adminUser);
$this
->drupalCreateContentType([
'type' => 'test',
]);
// Add FR language.
ConfigurableLanguage::createFromLangcode('fr')
->save();
// Add path_prefix based language negotiation.
$this
->config('language.negotiation')
->set('url.source', 'path_prefix')
->set('url.prefixes', [
'en' => 'en',
'fr' => 'fr',
])
->save();
// Turn on content translation for test pages.
$config = ContentLanguageSettings::loadByEntityTypeBundle('node', 'test');
$config
->setDefaultLangcode('en')
->setLanguageAlterable(TRUE)
->save();
$this->node1 = $this
->drupalCreateNode([
'title' => 'Test <sup>sup</sup>-tag',
'type' => 'test',
'path' => '/parent',
]);
$this->node2 = $this
->drupalCreateNode([
'title' => 'Test <sup>sup</sup>-tag, <sub>sub</sub>-tag and <br>br-tag',
'type' => 'test',
'path' => '/parent/child',
]);
$this->node3 = $this
->drupalCreateNode([
'title' => 'Test <sup>sup</sup>-tag, <sub>sub</sub>-tag, <br>br-tag and <p>p</p>-tag',
'type' => 'test',
]);
$translation = $this->node3
->addTranslation('fr', [
'title' => 'Test <sup>sup</sup>-tag, <sub>sub</sub>-tag, <br>br-tag and <p>p</p>-tag FR',
]);
$translation
->save();
$this->node4 = $this
->drupalCreateNode([
'title' => 'Test <p>p</p>-tag',
'type' => 'test',
]);
// Run a cron job so the nodes are indexed and shown on the search page.
$this->container
->get('cron')
->run();
$this->state = $this->container
->get('state');
}