Commit 6fd72a2c authored by webchick's avatar webchick

Issue #2095115 by beejeebus: Delete ViewTestConfigInstaller and have...

Issue #2095115 by beejeebus: Delete ViewTestConfigInstaller and have ViewTestData create views, not 'import' them.
parent a4f9d8e3
......@@ -56,7 +56,7 @@ protected function setUp() {
$this->installSchema('aggregator', array('aggregator_item', 'aggregator_feed', 'aggregator_category_feed', 'aggregator_category', 'aggregator_category_item'));
ViewTestData::importTestViews(get_class($this), array('aggregator_test_views'));
ViewTestData::createTestViews(get_class($this), array('aggregator_test_views'));
$this->itemStorageController = $this->container->get('entity.manager')->getStorageController('aggregator_item');
$this->feedStorageController = $this->container->get('entity.manager')->getStorageController('aggregator_feed');
......
......@@ -43,7 +43,7 @@ public static function getInfo() {
protected function setUp() {
parent::setUp();
ViewTestData::importTestViews(get_class($this), array('block_test_views'));
ViewTestData::createTestViews(get_class($this), array('block_test_views'));
$this->enableViewsTestModule();
}
......
......@@ -32,7 +32,7 @@ abstract class CommentTestBase extends ViewTestBase {
function setUp() {
parent::setUp();
ViewTestData::importTestViews(get_class($this), array('comment_test_views'));
ViewTestData::createTestViews(get_class($this), array('comment_test_views'));
// Add two users, create a node with the user1 as author and another node
// with user2 as author. For the second node add a comment from user1.
......
......@@ -52,7 +52,7 @@ public static function getInfo() {
protected function setUp() {
parent::setUp();
ViewTestData::importTestViews(get_class($this), array('contact_test_views'));
ViewTestData::createTestViews(get_class($this), array('contact_test_views'));
$this->userData = $this->container->get('user.data');
}
......
......@@ -51,7 +51,7 @@ function setUp() {
$user->langcode = 'en';
$user->save();
ViewTestData::importTestViews(get_class($this), array('content_translation_test_views'));
ViewTestData::createTestViews(get_class($this), array('content_translation_test_views'));
}
/**
......
......@@ -48,7 +48,7 @@ protected function setUp() {
$this->enableModules(array('system', 'dblog'));
$this->installSchema('dblog', array('watchdog'));
ViewTestData::importTestViews(get_class($this), array('dblog_test_views'));
ViewTestData::createTestViews(get_class($this), array('dblog_test_views'));
}
/**
......
......@@ -51,7 +51,7 @@ abstract class FieldTestBase extends ViewTestBase {
protected function setUp() {
parent::setUp();
ViewTestData::importTestViews(get_class($this), array('field_test_views'));
ViewTestData::createTestViews(get_class($this), array('field_test_views'));
}
function setUpFields($amount = 3) {
......
......@@ -40,7 +40,7 @@ public static function getInfo() {
*/
protected function setUp() {
parent::setUp();
ViewTestData::importTestViews(get_class($this), array('file_test_views'));
ViewTestData::createTestViews(get_class($this), array('file_test_views'));
}
/**
......
......@@ -40,7 +40,7 @@ public static function getInfo() {
protected function setUp() {
parent::setUp();
ViewTestData::importTestViews(get_class($this), array('forum_test_views'));
ViewTestData::createTestViews(get_class($this), array('forum_test_views'));
}
......
......@@ -25,7 +25,7 @@ abstract class NodeTestBase extends ViewTestBase {
protected function setUp() {
parent::setUp();
ViewTestData::importTestViews(get_class($this), array('node_test_views'));
ViewTestData::createTestViews(get_class($this), array('node_test_views'));
}
}
......@@ -24,7 +24,7 @@ class RevisionRelationships extends ViewTestBase {
protected function setUp() {
parent::setUp();
ViewTestData::importTestViews(get_class($this), array('node_test_views'));
ViewTestData::createTestViews(get_class($this), array('node_test_views'));
}
/**
......
......@@ -50,7 +50,7 @@ public static function getInfo() {
protected function setUp() {
parent::setUp();
ViewTestData::importTestViews(get_class($this), array('rest_test_views'));
ViewTestData::createTestViews(get_class($this), array('rest_test_views'));
$this->adminUser = $this->drupalCreateUser(array('administer views', 'administer entity_test content', 'access user profiles', 'view test entity'));
......
......@@ -57,7 +57,7 @@ public static function getInfo() {
protected function setUp() {
parent::setUp();
ViewTestData::importTestViews(get_class($this), array('statistics_test_views'));
ViewTestData::createTestViews(get_class($this), array('statistics_test_views'));
// Create a new user for viewing nodes.
$this->webUser = $this->drupalCreateUser(array('access content'));
......
......@@ -45,7 +45,7 @@ public static function getInfo() {
protected function setUp() {
parent::setUp();
ViewTestData::importTestViews(get_class($this), array('taxonomy_test_views'));
ViewTestData::createTestViews(get_class($this), array('taxonomy_test_views'));
}
/**
......
......@@ -48,7 +48,7 @@ function setUp() {
parent::setUp();
$this->mockStandardInstall();
ViewTestData::importTestViews(get_class($this), array('taxonomy_test_views'));
ViewTestData::createTestViews(get_class($this), array('taxonomy_test_views'));
$this->term1 = $this->createTerm();
$this->term2 = $this->createTerm();
......
......@@ -26,7 +26,7 @@ abstract class TrackerTestBase extends ViewTestBase {
protected function setUp() {
parent::setUp();
ViewTestData::importTestViews(get_class($this), array('tracker_test_views'));
ViewTestData::createTestViews(get_class($this), array('tracker_test_views'));
$this->drupalCreateContentType(array('type' => 'page', 'name' => 'Basic page'));
......
......@@ -65,7 +65,7 @@ public static function getInfo() {
protected function setUp() {
parent::setUp();
ViewTestData::importTestViews(get_class($this), array('user_test_views'));
ViewTestData::createTestViews(get_class($this), array('user_test_views'));
$this->enableViewsTestModule();
......
......@@ -39,7 +39,7 @@ abstract class UserTestBase extends ViewTestBase {
protected function setUp() {
parent::setUp();
ViewTestData::importTestViews(get_class($this), array('user_test_views'));
ViewTestData::createTestViews(get_class($this), array('user_test_views'));
$this->users[] = $this->drupalCreateUser();
$this->users[] = user_load(1);
......
......@@ -46,7 +46,7 @@ abstract class UserUnitTestBase extends ViewUnitTestBase {
protected function setUp() {
parent::setUp();
ViewTestData::importTestViews(get_class($this), array('user_test_views'));
ViewTestData::createTestViews(get_class($this), array('user_test_views'));
$this->installSchema('user', array('users', 'users_roles'));
$this->installSchema('system', 'sequences');
......
......@@ -37,7 +37,7 @@ protected function setUp() {
$this->enableViewsTestModule();
ViewTestData::importTestViews(get_class($this), array('views_test_data'));
ViewTestData::createTestViews(get_class($this), array('views_test_data'));
$this->admin_user = $this->drupalCreateUser(array('access all views'));
$this->web_user = $this->drupalCreateUser();
......
......@@ -45,7 +45,7 @@ public static function getInfo() {
protected function setUp() {
parent::setUp();
ViewTestData::importTestViews(get_class($this), array('block_test_views'));
ViewTestData::createTestViews(get_class($this), array('block_test_views'));
}
/**
......
......@@ -38,7 +38,7 @@ protected function setUp() {
foreach (ViewExecutable::getPluginTypes() as $plugin_type) {
$this->container->get("plugin.manager.views.$plugin_type")->clearCachedDefinitions();
}
ViewTestData::importTestViews(get_class($this), array('views_test_config'));
ViewTestData::createTestViews(get_class($this), array('views_test_config'));
}
/**
......
<?php
/**
* @file
* Contains \Drupal\views\Tests\ViewTestConfigInstaller.
*/
namespace Drupal\views\Tests;
use Drupal\Core\Config\ConfigImporter;
/**
* Defines a configuration installer.
*
* A config installer imports test views for views testing.
*
* @see \Drupal\Core\Config\ConfigImporter
* @see \Drupal\views\Tests\ViewTestData
*/
class ViewTestConfigInstaller extends ConfigImporter {
/**
* The name used to identify events and the lock.
*/
const ID = 'views.test.installer';
}
......@@ -8,7 +8,6 @@
namespace Drupal\views\Tests;
use Drupal\Core\Config\FileStorage;
use Drupal\Core\Config\StorageComparer;
/**
* Provides tests view data and the base test schema with sample data records.
......@@ -21,17 +20,14 @@
class ViewTestData {
/**
* Imports test views from config.
* Create test views from config.
*
* @param string $class
* The name of the test class.
* @param array $modules
* (optional) The module directories to look in for test views.
* Defaults to an empty array.
*
* @see config_install_default_config()
* The module directories to look in for test views.
*/
public static function importTestViews($class, $modules = array()) {
public static function createTestViews($class, array $modules) {
$views = array();
while ($class) {
if (property_exists($class, 'testViews')) {
......@@ -40,6 +36,7 @@ public static function importTestViews($class, $modules = array()) {
$class = get_parent_class($class);
}
if (!empty($views)) {
$storage_controller = \Drupal::entityManager()->getStorageController('view');
$module_handler = \Drupal::moduleHandler();
foreach ($modules as $module) {
$config_dir = drupal_get_path('module', $module) . '/test_views';
......@@ -47,28 +44,15 @@ public static function importTestViews($class, $modules = array()) {
continue;
}
$source_storage = new FileStorage($config_dir);
// Only import views used by test.
$views_to_import = array();
foreach ($source_storage->listAll('views.view.') as $config_name) {
$file_storage = new FileStorage($config_dir);
foreach ($file_storage->listAll('views.view.') as $config_name) {
$id = str_replace('views.view.', '', $config_name);
if (in_array($id, $views)) {
$views_to_import[] = $config_name;
$storage_controller
->create($file_storage->read($config_name))
->save();
}
}
$storage_comparer = new StorageComparer(
$source_storage,
\Drupal::service('config.storage')
);
$storage_comparer->addChangelist('create', $views_to_import);
$installer = new ViewTestConfigInstaller(
$storage_comparer,
\Drupal::service('event_dispatcher'),
\Drupal::service('config.factory'),
\Drupal::entityManager(),
\Drupal::lock()
);
$installer->import();
}
}
}
......
......@@ -66,7 +66,7 @@ protected function setUpFixtures() {
// Tests implementing ViewUnitTestBase depend on the theme system being
// properly configured.
$this->installConfig(array('system'));
ViewTestData::importTestViews(get_class($this), array('views_test_config'));
ViewTestData::createTestViews(get_class($this), array('views_test_config'));
}
/**
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment