SmartTitleUITest.php in Smart Title 8
File
modules/smart_title_ui/tests/src/Functional/SmartTitleUITest.php
View source
<?php
namespace Drupal\Tests\smart_title_ui\Functional;
use Drupal\Core\Url;
use Drupal\Tests\BrowserTestBase;
class SmartTitleUITest extends BrowserTestBase {
protected $defaultTheme = 'stark';
public static $modules = [
'node',
'smart_title_ui',
'user',
];
protected function setUp() {
parent::setUp();
$this
->drupalCreateContentType([
'type' => 'test_page',
]);
}
public function testSmartTitleUserInterface() {
$config_url = Url::fromRoute('smart_title_ui.settings');
$this
->drupalGet($config_url);
$this
->assertSession()
->statusCodeEquals(403);
$this
->drupalLogin($this
->drupalCreateUser([
'administer smart title',
]));
$this
->drupalGet($config_url);
$web_assert = $this
->assertSession();
$web_assert
->statusCodeEquals(200);
$web_assert
->pageTextContains('test_page');
$smart_title_bundles = $this
->config('smart_title.settings')
->get('smart_title');
$this
->assertTrue(empty($smart_title_bundles));
$page = $this
->getSession()
->getPage();
$page
->hasUncheckedField('test_page');
$this
->drupalPostForm(NULL, [
'node_bundles[node:test_page]' => 1,
], 'Save configuration');
$page = $this
->getSession()
->getPage();
$this
->assertSession()
->pageTextContains('The configuration options have been saved.');
$page
->hasCheckedField('test_page');
$smart_title_bundles = $this
->config('smart_title.settings')
->get('smart_title');
$this
->assertTrue([
'node:test_page',
] === $smart_title_bundles);
$this
->drupalPostForm(NULL, [
'node_bundles[node:test_page]' => 0,
], 'Save configuration');
$page = $this
->getSession()
->getPage();
$this
->assertSession()
->pageTextContains('The configuration options have been saved.');
$page
->hasUncheckedField('test_page');
$smart_title_bundles = $this
->config('smart_title.settings')
->get('smart_title');
$this
->assertTrue(empty($smart_title_bundles));
}
}