public function WebTest::testModuleInstallation in Redis 8
Tests enabling modules and creating configuration.
File
- tests/
src/ Functional/ WebTest.php, line 123
Class
- WebTest
- Tests complex processes like installing modules with redis backends.
Namespace
Drupal\Tests\redis\FunctionalCode
public function testModuleInstallation() {
$admin_user = $this
->createUser([], NULL, TRUE);
$this
->drupalLogin($admin_user);
// Enable a few modules.
$edit["modules[node][enable]"] = TRUE;
$edit["modules[views][enable]"] = TRUE;
$edit["modules[field_ui][enable]"] = TRUE;
$edit["modules[text][enable]"] = TRUE;
$this
->drupalPostForm('admin/modules', $edit, t('Install'));
$this
->drupalPostForm(NULL, [], t('Continue'));
$assert = $this
->assertSession();
// The order of the modules is not guaranteed, so just assert that they are
// all listed.
$assert
->elementTextContains('css', '.messages--status', '6 modules have been enabled');
$assert
->elementTextContains('css', '.messages--status', 'Field UI');
$assert
->elementTextContains('css', '.messages--status', 'Node');
$assert
->elementTextContains('css', '.messages--status', 'Text');
$assert
->elementTextContains('css', '.messages--status', 'Views');
$assert
->elementTextContains('css', '.messages--status', 'Field');
$assert
->elementTextContains('css', '.messages--status', 'Filter');
$assert
->checkboxChecked('edit-modules-field-ui-enable');
// Create a node type with a field.
$edit = [
'name' => $this
->randomString(),
'type' => $node_type = mb_strtolower($this
->randomMachineName()),
];
$this
->drupalPostForm('admin/structure/types/add', $edit, t('Save and manage fields'));
$field_name = mb_strtolower($this
->randomMachineName());
$this
->fieldUIAddNewField('admin/structure/types/manage/' . $node_type, $field_name, NULL, 'text');
// Create a node, check display, edit, verify that it has been updated.
$edit = [
'title[0][value]' => $this
->randomMachineName(),
'body[0][value]' => $this
->randomMachineName(),
'field_' . $field_name . '[0][value]' => $this
->randomMachineName(),
];
$this
->drupalPostForm('node/add/' . $node_type, $edit, t('Save'));
// Test the output as anonymous user.
$this
->drupalLogout();
$this
->drupalGet('node');
$this
->assertSession()
->responseContains($edit['title[0][value]']);
$this
->drupalLogin($admin_user);
$this
->drupalGet('node');
$this
->clickLink($edit['title[0][value]']);
$this
->assertSession()
->responseContains($edit['body[0][value]']);
$this
->clickLink(t('Edit'));
$update = [
'title[0][value]' => $this
->randomMachineName(),
];
$this
->drupalPostForm(NULL, $update, t('Save'));
$this
->assertSession()
->responseContains($update['title[0][value]']);
$this
->drupalGet('node');
$this
->assertSession()
->responseContains($update['title[0][value]']);
$this
->drupalLogout();
$this
->drupalGet('node');
$this
->clickLink($update['title[0][value]']);
$this
->assertSession()
->responseContains($edit['body[0][value]']);
// Get database schema.
$db_schema = Database::getConnection()
->schema();
$this
->assertFalse($db_schema
->tableExists('cache_default'));
$this
->assertFalse($db_schema
->tableExists('cache_render'));
$this
->assertFalse($db_schema
->tableExists('cache_config'));
$this
->assertFalse($db_schema
->tableExists('cache_container'));
$this
->assertFalse($db_schema
->tableExists('cachetags'));
$this
->assertFalse($db_schema
->tableExists('semaphore'));
$this
->assertFalse($db_schema
->tableExists('flood'));
}