public static function ViewTestData::createTestViews in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/views/src/Tests/ViewTestData.php \Drupal\views\Tests\ViewTestData::createTestViews()
Create test views from config.
Parameters
string $class: The name of the test class. Installs the listed test views *in order*.
array $modules: The module directories to look in for test views.
45 calls to ViewTestData::createTestViews()
- AccessRoleUITest::setUp in core/
modules/ user/ src/ Tests/ Views/ AccessRoleUITest.php - Sets up a Drupal site for running functional and integration tests.
- AccessTest::setUp in core/
modules/ views/ src/ Tests/ Plugin/ AccessTest.php - Sets up a Drupal site for running functional and integration tests.
- BaseFieldAccessTest::setUp in core/
modules/ views/ src/ Tests/ Entity/ BaseFieldAccessTest.php - Sets up a Drupal site for running functional and integration tests.
- BlockContentTestBase::setUp in core/
modules/ block_content/ src/ Tests/ Views/ BlockContentTestBase.php - Sets up a Drupal site for running functional and integration tests.
- CommentTestBase::setUp in core/
modules/ comment/ src/ Tests/ Views/ CommentTestBase.php - Sets up a Drupal site for running functional and integration tests.
File
- core/
modules/ views/ src/ Tests/ ViewTestData.php, line 30 - Contains \Drupal\views\Tests\ViewTestData.
Class
- ViewTestData
- Provides tests view data and the base test schema with sample data records.
Namespace
Drupal\views\TestsCode
public static function createTestViews($class, array $modules) {
$views = array();
while ($class) {
if (property_exists($class, 'testViews')) {
$views = array_merge($views, $class::$testViews);
}
$class = get_parent_class($class);
}
if (!empty($views)) {
$storage = \Drupal::entityManager()
->getStorage('view');
$module_handler = \Drupal::moduleHandler();
foreach ($modules as $module) {
$config_dir = drupal_get_path('module', $module) . '/test_views';
if (!is_dir($config_dir) || !$module_handler
->moduleExists($module)) {
continue;
}
$file_storage = new FileStorage($config_dir);
$available_views = $file_storage
->listAll('views.view.');
foreach ($views as $id) {
$config_name = 'views.view.' . $id;
if (in_array($config_name, $available_views)) {
$storage
->create($file_storage
->read($config_name))
->save();
}
}
}
}
// Rebuild the router once.
\Drupal::service('router.builder')
->rebuild();
}