public function EditableDeletableConfigTest::testDeletableEntity in Search Autocomplete 8
Same name and namespace in other branches
- 2.x src/Tests/Entity/EditableDeletableConfigTest.php \Drupal\search_autocomplete\Tests\Entity\EditableDeletableConfigTest::testDeletableEntity()
Check access authorizations over deletable configurations.
File
- src/
Tests/ Entity/ EditableDeletableConfigTest.php, line 73
Class
- EditableDeletableConfigTest
- Test basic CRUD on configurations.
Namespace
Drupal\search_autocomplete\Tests\EntityCode
public function testDeletableEntity() {
// Get config setup.
$config_id = 'search_block';
$config = AutocompletionConfiguration::load($config_id);
// Verify that default configuration search_block cannot be edited on GUI.
$this
->drupalGet('/admin/config/search/search_autocomplete');
$elements = $this
->xpath('//tr[@id="' . $config_id . '"]//li[contains(@class, "delete")]');
$this
->assertFalse(isset($elements[0]), 'Deletable config has Delete operation');
// Check access permission to delete page for none deletable configurations.
$this
->drupalGet('/admin/config/search/search_autocomplete/manage/' . $config_id . '/delete');
$this
->assertResponse(403, "None deletable configuration cannot be deleted from GUI");
// Remove editability for this configuration.
$config
->setDeletable(TRUE);
$config
->save();
// Verify that deletable configuration can be deleted from GUI.
$this
->drupalGet('/admin/config/search/search_autocomplete');
$elements = $this
->xpath('//tr[@id="' . $config_id . '"]//li[contains(@class, "delete")]');
$this
->assertTrue(isset($elements[0]), 'Deletable config has Delete operation');
// Check that deletable configurations can be deleted.
$this
->drupalGet('/admin/config/search/search_autocomplete/manage/' . $config_id . '/delete');
$this
->assertResponse(200, "Deletable configuration can be deleted from GUI");
}