View source
<?php
namespace Drupal\simplify\Tests;
use Drupal\Tests\BrowserTestBase;
class GlobalSettingsTest extends BrowserTestBase {
public static $modules = [
'simplify',
];
public static function getInfo() {
return [
'name' => 'Simplify global settings test.',
'description' => 'Test the Simplify module global settings page.',
'group' => 'Simplify',
];
}
protected function setUp() {
parent::setUp();
$admin_user = $this
->drupalCreateUser([
'administer simplify',
]);
$this
->drupalLogin($admin_user);
}
public function testSettingSaving() {
$this
->drupalGet('/admin/config/user-interface/simplify');
$this
->assertField('edit-simplify-admin', 'Admin user option is here.');
$this
->assertNoFieldChecked('edit-simplify-admin', 'Admin user option is unchecked.');
$this
->assertNoRaw('Nodes', 'Nodes options are not available.');
$this
->assertNoField('edit-simplify-nodes-global-author', 'Author option is not available.');
$this
->assertRaw('Users', 'Users options are not available.');
$this
->assertNoFieldChecked('edit-simplify-users-global-format', 'Text selection option is not available.');
$this
->assertNoRaw('Taxonomy', 'Taxonomy options are not available.');
$this
->assertNoField('edit-simplify-taxonomy-global-format', 'Text selection from taxonomy option is not available.');
$this
->assertNoRaw('Block', 'Blocks options are now available.');
$this
->assertNoField('edit-simplify-blocks-global-format', 'Text format option is not available.');
$this->container
->get('module_installer')
->install([
'node',
'book',
'taxonomy',
'block',
'comment',
'menu_ui',
'path',
], TRUE);
$this
->drupalGet('/admin/config/user-interface/simplify');
$this
->assertRaw('Nodes', 'Nodes options are now available.');
$this
->assertNoFieldChecked('edit-simplify-nodes-global-author', 'Author option is unchecked.');
$this
->assertNoFieldChecked('edit-simplify-nodes-global-format', 'Format option is unchecked.');
$this
->assertNoFieldChecked('edit-simplify-nodes-global-options', 'Publishing option is unchecked.');
$this
->assertNoFieldChecked('edit-simplify-nodes-global-revision-information', 'Revision option is unchecked.');
$this
->assertRaw('Users', 'Users options are now available.');
$this
->assertNoFieldChecked('edit-simplify-users-global-format', 'Text selection option is unchecked.');
$this
->assertNoFieldChecked('edit-simplify-users-global-status', 'Status option is unchecked.');
$this
->assertRaw('Taxonomy', 'Taxonomy options are now available.');
$this
->assertNoFieldChecked('edit-simplify-taxonomies-global-format', 'Taxonomy selection option is unchecked.');
$this
->assertNoFieldChecked('edit-simplify-taxonomies-global-relations', 'Taxonomy relation option is unchecked.');
$this
->assertNoFieldChecked('edit-simplify-taxonomies-global-path', 'Taxonomy url alias option is unchecked.');
$this
->assertRaw('Block', 'Blocks options are now available.');
$this
->assertNoFieldChecked('edit-simplify-blocks-global-format', 'Text format option is unchecked.');
$options = [
'simplify_admin' => TRUE,
'simplify_nodes_global[author]' => 'author',
'simplify_nodes_global[comment]' => 'comment',
'simplify_nodes_global[options]' => 'options',
'simplify_taxonomies_global[format]' => 'format',
'simplify_taxonomies_global[path]' => 'path',
];
$this
->drupalPostForm(NULL, $options, $this
->t('Save configuration'));
$this
->assertFieldChecked('edit-simplify-admin', 'Admin user option is checked.');
$this
->assertFieldChecked('edit-simplify-nodes-global-author', 'Node authoring information option is checked.');
$this
->assertNoFieldChecked('edit-simplify-nodes-global-format', 'Node text fomat selection option is not checked.');
$this
->assertFieldChecked('edit-simplify-nodes-global-options', 'Node promoting options option is checked.');
$this
->assertNoFieldChecked('edit-simplify-nodes-global-revision-information', 'Node revision information option is not checked.');
$this
->assertNoFieldChecked('edit-simplify-nodes-global-book', 'Node book outline option is not checked.');
$this
->assertFieldChecked('edit-simplify-nodes-global-comment', 'Node comment settings option is checked.');
$this
->assertNoFieldChecked('edit-simplify-nodes-global-menu', 'Node menu settings option is not checked.');
$this
->assertNoFieldChecked('edit-simplify-nodes-global-path-settings', 'Node URL path settings option is not checked.');
$this
->assertFieldChecked('edit-simplify-taxonomies-global-format', 'Taxonomy text fomat selection option is checked.');
$this
->assertNoFieldChecked('edit-simplify-taxonomies-global-relations', 'Taxonomy relation option is not checked.');
$this
->assertFieldChecked('edit-simplify-taxonomies-global-path', 'Taxonomy url alias option is checked.');
}
}