You are here

public function FormTest::testEditStyleExistingName in Style Switcher 3.0.x

Same name and namespace in other branches
  1. 8.2 tests/src/Functional/FormTest.php \Drupal\Tests\styleswitcher\Functional\FormTest::testEditStyleExistingName()

Tests a validation error on setting a style other existing name.

File

tests/src/Functional/FormTest.php, line 189

Class

FormTest
Tests Style Switcher forms.

Namespace

Drupal\Tests\styleswitcher\Functional

Code

public function testEditStyleExistingName() {
  $assert = $this
    ->assertSession();
  $path = 'public://styleswitcher_style.css';
  file_put_contents($path, '');
  $this
    ->config('styleswitcher.custom_styles')
    ->set('styles', $this
    ->composeStyles([
    'A' => $path,
    'B' => NULL,
  ]))
    ->save();
  $this
    ->drupalGet($this->adminPath . '/custom/b');
  $this
    ->submitForm([
    'name' => 'a',
  ], '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'));
}