protected function ViewTestBase::enableViewsTestModule in Drupal 10
Same name and namespace in other branches
- 8 core/modules/views/tests/src/Functional/ViewTestBase.php \Drupal\Tests\views\Functional\ViewTestBase::enableViewsTestModule()
- 9 core/modules/views/tests/src/Functional/ViewTestBase.php \Drupal\Tests\views\Functional\ViewTestBase::enableViewsTestModule()
Sets up the views_test_data.module.
Because the schema of views_test_data.module is dependent on the test using it, it cannot be enabled normally.
8 calls to ViewTestBase::enableViewsTestModule()
- AccessTestBase::setUp in core/
modules/ user/ tests/ src/ Functional/ Views/ AccessTestBase.php - DisplayBlockTest::setUp in core/
modules/ block/ tests/ src/ Functional/ Views/ DisplayBlockTest.php - ExcludedFieldTokenTest::setUp in core/
modules/ rest/ tests/ src/ Functional/ Views/ ExcludedFieldTokenTest.php - FieldCounterTest::setUp in core/
modules/ rest/ tests/ src/ Functional/ Views/ FieldCounterTest.php - FilterPermissionUiTest::setUp in core/
modules/ user/ tests/ src/ Functional/ Views/ FilterPermissionUiTest.php
File
- core/
modules/ views/ tests/ src/ Functional/ ViewTestBase.php, line 45
Class
- ViewTestBase
- Defines a base class for Views testing in the full web test environment.
Namespace
Drupal\Tests\views\FunctionalCode
protected function enableViewsTestModule() {
// Define the schema and views data variable before enabling the test module.
\Drupal::state()
->set('views_test_data_schema', $this
->schemaDefinition());
\Drupal::state()
->set('views_test_data_views_data', $this
->viewsData());
\Drupal::service('module_installer')
->install([
'views_test_data',
]);
$this
->resetAll();
$this
->rebuildContainer();
$this->container
->get('module_handler')
->reload();
// Load the test dataset.
$data_set = $this
->dataSet();
$query = Database::getConnection()
->insert('views_test_data')
->fields(array_keys($data_set[0]));
foreach ($data_set as $record) {
$query
->values($record);
}
$query
->execute();
}