DateRecurInterpreterTest.php in Recurring Dates Field 3.0.x
File
tests/src/Functional/DateRecurInterpreterTest.php
View source
<?php
namespace Drupal\Tests\date_recur\Functional;
use Drupal\Core\Url;
use Drupal\FunctionalJavascriptTests\WebDriverTestBase;
class DateRecurInterpreterTest extends WebDriverTestBase {
protected $defaultTheme = 'classy';
protected static $modules = [
'date_recur_interpreter_test',
'date_recur',
];
protected function setUp() : void {
parent::setUp();
$this
->drupalLogin($this
->drupalCreateUser([
'date_recur manage interpreters',
]));
}
public function testInterpreterWebCreate() {
$instanceLabel = 'Kaya';
$url = Url::fromRoute('entity.date_recur_interpreter.add_form');
$this
->drupalGet($url);
$buttonLabel = \t('Next');
$this
->assertSession()
->buttonExists($buttonLabel);
$this
->assertSession()
->pageTextContains('Add interpreter');
$this
->assertSession()
->optionExists('plugin_type', 'test_interpreter');
$page = $this
->getSession()
->getPage();
$page
->findField('label')
->setValue($instanceLabel);
$this
->assertSession()
->waitForElementVisible('css', '[name="label"] + * .machine-name-value');
$page
->findField('plugin_type')
->setValue('test_interpreter');
$this
->submitForm([], $buttonLabel, 'date-recur-interpreter-add-form');
$this
->assertSession()
->buttonNotExists($buttonLabel);
$buttonLabel = \t('Save');
$this
->assertSession()
->pageTextContains('Add interpreter');
$this
->assertSession()
->checkboxNotChecked('configure[show_foo]');
$page = $this
->getSession()
->getPage();
$page
->checkField('configure[show_foo]');
$this
->submitForm([], $buttonLabel, 'date-recur-interpreter-add-form');
$this
->assertSession()
->addressEquals(Url::fromRoute('entity.date_recur_interpreter.collection')
->setAbsolute()
->toString());
$this
->assertSession()
->elementTextContains('css', '.messages', 'Saved the ' . $instanceLabel . ' interpreter.');
}
}