You are here

public function UnicityConfigTest::testUniqueSelector in Search Autocomplete 8

Same name and namespace in other branches
  1. 2.x src/Tests/Entity/UnicityConfigTest.php \Drupal\search_autocomplete\Tests\Entity\UnicityConfigTest::testUniqueSelector()

Configuration creation should fail if selector is not unique.

File

src/Tests/Entity/UnicityConfigTest.php, line 92

Class

UnicityConfigTest
Test uniticity when creation configurations.

Namespace

Drupal\search_autocomplete\Tests\Entity

Code

public function testUniqueSelector() {

  // ----------------------------------------------------------------------
  // 1) Create the configuration.
  // Add new configurations.
  $this
    ->drupalGet('admin/config/search/search_autocomplete/add');

  // Default values.
  $config_name = "test1";
  $config = [
    'label' => 'test1',
    'selector' => 'input#edit',
  ];

  // Click Add new button.
  $this
    ->drupalPostForm(NULL, [
    'label' => $config['label'],
    'id' => $config_name,
    'selector' => $config['selector'],
  ], 'Create Autocompletion Configuration');

  // ----------------------------------------------------------------------
  // 2) Create the configuration again.
  // Add new configurations.
  $this
    ->drupalGet('admin/config/search/search_autocomplete/add');

  // Default values.
  $config_name = "test2";
  $config = [
    'label' => 'test2',
    'selector' => 'input#edit',
  ];

  // Click Add new button.
  $this
    ->drupalPostForm(NULL, [
    'label' => $config['label'],
    'id' => $config_name,
    'selector' => $config['selector'],
  ], 'Create Autocompletion Configuration');
  $this
    ->assertRaw('The selector ID must be unique.');
}