public function FormTest::testAddStyleExistingName in Style Switcher 3.0.x
Same name and namespace in other branches
- 8.2 tests/src/Functional/FormTest.php \Drupal\Tests\styleswitcher\Functional\FormTest::testAddStyleExistingName()
Tests a validation error when trying to add a style with existing name.
File
- tests/
src/ Functional/ FormTest.php, line 164
Class
- FormTest
- Tests Style Switcher forms.
Namespace
Drupal\Tests\styleswitcher\FunctionalCode
public function testAddStyleExistingName() {
$assert = $this
->assertSession();
$this
->config('styleswitcher.custom_styles')
->set('styles', $this
->composeStyles([
'A' => NULL,
]))
->save();
$this
->drupalGet($this->adminPath . '/add');
$path = 'public://styleswitcher_style.css';
file_put_contents($path, '');
$edit = [
'label' => 'B',
'name' => 'a',
'path' => $path,
];
$this
->submitForm($edit, 'Save');
$assert
->pageTextContains('The machine-readable name is already in use. It must be unique.');
$assert
->elementExists('css', 'form#styleswitcher-style-form');
$this
->assertSame('A', $this
->config('styleswitcher.custom_styles')
->get('styles.custom/a.label'));
}