public function UnicityConfigTest::testUniqueId in Search Autocomplete 8
Same name and namespace in other branches
- 2.x src/Tests/Entity/UnicityConfigTest.php \Drupal\search_autocomplete\Tests\Entity\UnicityConfigTest::testUniqueId()
Configuration creation should fail if ID is not unique.
File
- src/
Tests/ Entity/ UnicityConfigTest.php, line 39
Class
- UnicityConfigTest
- Test uniticity when creation configurations.
Namespace
Drupal\search_autocomplete\Tests\EntityCode
public function testUniqueId() {
// ----------------------------------------------------------------------
// 1) Create the configuration.
// Add new configurations.
$this
->drupalGet('admin/config/search/search_autocomplete/add');
// Default values.
$config_name = "testing";
$config = [
'label' => 'test-label',
'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 = "testing";
$config = [
'label' => 'test-another',
'selector' => 'another',
];
// Click Add new button.
$this
->drupalPostForm(NULL, [
'label' => $config['label'],
'id' => $config_name,
'selector' => $config['selector'],
], 'Create Autocompletion Configuration');
$this
->assertRaw(t('The machine-readable name is already in use. It must be unique.'));
}