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