AdminFunctionalityTest.php in Synonyms 2.0.x
File
modules/synonyms_select/tests/src/Functional/AdminFunctionalityTest.php
View source
<?php
namespace Drupal\Tests\synonyms_select\Functional;
use Drupal\Tests\BrowserTestBase;
class AdminFunctionalityTest extends BrowserTestBase {
public static $modules = [
'synonyms',
'synonyms_select',
];
protected $defaultTheme = 'stark';
public function setUp() {
parent::setUp();
$this->container
->get('router.builder')
->rebuild();
$account = $this
->drupalCreateUser([
'administer site configuration',
'administer synonyms',
]);
$this
->drupalLogin($account);
}
public function testSynonymsAdmin() {
$this
->drupalGet('admin/structure/synonyms');
$session = $this
->assertSession();
$session
->statusCodeEquals(200);
$session
->pageTextContains('Synonyms configuration');
$session
->pageTextContains('Default wordings:');
$session
->pageTextContains('Synonyms-friendly select widget: @synonym is the @field_label of @entity_label');
$this
->drupalGet('admin/structure/synonyms/settings');
$session = $this
->assertSession();
$session
->statusCodeEquals(200);
$session
->pageTextContains('Synonyms settings');
$session
->fieldValueEquals('select', '@synonym is the @field_label of @entity_label');
$session
->buttonExists('Save configuration');
$edit = [
'wording_type' => 'default',
'select' => 'Test wording',
];
$this
->drupalPostForm(NULL, $edit, 'Save');
$session = $this
->assertSession();
$session
->statusCodeEquals(200);
$session
->addressEquals('admin/structure/synonyms/settings');
$session
->pageTextContains('Synonyms settings');
$session
->fieldValueEquals('select', 'Test wording');
$session
->buttonExists('Save configuration');
$this
->drupalGet('admin/structure/synonyms/behavior/user/user');
$session = $this
->assertSession();
$session
->statusCodeEquals(200);
$session
->pageTextContains('Manage behaviors of User');
$session
->pageTextContains('Select service');
$session
->checkboxNotChecked('select_status');
$session
->buttonExists('Save configuration');
$edit = [
'select_status' => 1,
];
$this
->drupalPostForm(NULL, $edit, 'Save');
$session = $this
->assertSession();
$session
->statusCodeEquals(200);
$session
->addressEquals('admin/structure/synonyms/behavior/user/user');
$session
->pageTextContains('Manage behaviors of User');
$session
->pageTextContains('Select service');
$session
->checkboxChecked('select_status');
$session
->buttonExists('Save configuration');
}
}