SmartTitleFieldLayoutTest.php in Smart Title 8
File
tests/src/Functional/SmartTitleFieldLayoutTest.php
View source
<?php
namespace Drupal\Tests\smart_title\Functional;
class SmartTitleFieldLayoutTest extends SmartTitleBrowserTestBase {
protected static $modules = [
'field_layout',
];
public function testSmartTitlePlacement() {
$this
->drupalLogin($this->adminUser);
$this
->drupalPostForm('admin/structure/types/manage/test_page/display/teaser', [
'smart_title__enabled' => TRUE,
], 'Save');
$form_edit = [
'field_layout' => 'layout_twocol',
];
$this
->drupalPostForm('admin/structure/types/manage/test_page/display/teaser', $form_edit, 'Change layout');
$this
->drupalPostForm(NULL, [], 'Save');
$this
->drupalPostForm(NULL, [
'fields[smart_title][region]' => 'second',
], 'Save');
$this
->click('[name="smart_title_settings_edit"]');
$this
->drupalPostForm(NULL, [
'fields[smart_title][settings_edit_form][settings][smart_title__tag]' => 'h3',
'fields[smart_title][settings_edit_form][settings][smart_title__classes]' => 'smart-title--test',
], 'Save');
$this
->drupalGet('node');
$this
->assertSession()
->pageTextContains($this->testPageNode
->label());
$article_title = $this
->xpath($this
->cssSelectToXpath('article .layout__region--second h3.smart-title--test'));
$this
->assertEquals($this->testPageNode
->label(), $article_title[0]
->getText());
$this
->drupalGet('node');
$article_title = $this
->xpath($this
->cssSelectToXpath('article > h2'));
$this
->assertEquals($article_title, []);
$this
->drupalLogout();
$this
->drupalGet('node');
$this
->assertSession()
->pageTextContains($this->testPageNode
->label());
$article_title = $this
->xpath($this
->cssSelectToXpath('article .layout__region--second h3.smart-title--test'));
$this
->assertEquals($this->testPageNode
->label(), $article_title[0]
->getText());
$this
->drupalGet('node');
$article_title = $this
->xpath($this
->cssSelectToXpath('article > h2'));
$this
->assertEquals($article_title, []);
}
}