diff --git a/core/modules/entity_reference/src/Tests/Views/EntityReferenceRelationshipTest.php b/core/modules/entity_reference/src/Tests/Views/EntityReferenceRelationshipTest.php index 9ae79a7..f2a803d 100644 --- a/core/modules/entity_reference/src/Tests/Views/EntityReferenceRelationshipTest.php +++ b/core/modules/entity_reference/src/Tests/Views/EntityReferenceRelationshipTest.php @@ -52,8 +52,6 @@ protected function setUp() { $this->installEntitySchema('user'); $this->installEntitySchema('entity_test'); - ViewTestData::createTestViews(get_class($this), array('entity_reference_test_views')); - $field_storage = FieldStorageConfig::create(array( 'entity_type' => 'entity_test', 'field_name' => 'field_test', @@ -76,6 +74,8 @@ protected function setUp() { )); $field->save(); + ViewTestData::createTestViews(get_class($this), array('entity_reference_test_views')); + // Create some test entities which link each other. $entity_storage= \Drupal::entityManager()->getStorage('entity_test'); $referenced_entity = $entity_storage->create(array()); diff --git a/core/modules/entity_reference/tests/modules/entity_reference_test_views/test_views/views.view.test_entity_reference_view.yml b/core/modules/entity_reference/tests/modules/entity_reference_test_views/test_views/views.view.test_entity_reference_view.yml index c60ede7..90e4d31 100644 --- a/core/modules/entity_reference/tests/modules/entity_reference_test_views/test_views/views.view.test_entity_reference_view.yml +++ b/core/modules/entity_reference/tests/modules/entity_reference_test_views/test_views/views.view.test_entity_reference_view.yml @@ -67,7 +67,7 @@ display: test_relationship: id: reverse_field_test table: entity_test - field: reverse_field_test + field: reverse__entity_test__field_test relationship: none plugin_id: standard display_plugin: embed diff --git a/core/modules/views/src/Tests/Entity/FieldEntityTest.php b/core/modules/views/src/Tests/Entity/FieldEntityTest.php index 37e27c0..715a36b 100644 --- a/core/modules/views/src/Tests/Entity/FieldEntityTest.php +++ b/core/modules/views/src/Tests/Entity/FieldEntityTest.php @@ -9,6 +9,7 @@ use Drupal\comment\Tests\CommentTestTrait; use Drupal\views\Tests\ViewTestBase; +use Drupal\views\Tests\ViewTestData; use Drupal\views\Views; /** @@ -35,6 +36,19 @@ class FieldEntityTest extends ViewTestBase { public static $modules = array('node', 'comment'); /** + * {@inheritdoc} + */ + protected function setUp($import_test_views = TRUE) { + parent::setUp(FALSE); + + $this->drupalCreateContentType(array('type' => 'page')); + $this->addDefaultCommentField('node', 'page'); + + ViewTestData::createTestViews(get_class($this), array('views_test_config')); + } + + + /** * Tests the getEntity method. */ public function testGetEntity() { @@ -43,8 +57,6 @@ public function testGetEntity() { $account = entity_create('user', array('name' => $this->randomMachineName(), 'bundle' => 'user')); $account->save(); - $this->drupalCreateContentType(array('type' => 'page')); - $this->addDefaultCommentField('node', 'page'); $node = entity_create('node', array('uid' => $account->id(), 'type' => 'page')); $node->save(); diff --git a/core/modules/views/src/Tests/Entity/ViewEntityDependenciesTest.php b/core/modules/views/src/Tests/Entity/ViewEntityDependenciesTest.php index d96f666..8805214 100644 --- a/core/modules/views/src/Tests/Entity/ViewEntityDependenciesTest.php +++ b/core/modules/views/src/Tests/Entity/ViewEntityDependenciesTest.php @@ -9,6 +9,7 @@ use Drupal\Component\Utility\Unicode; use Drupal\field\Entity\FieldStorageConfig; +use Drupal\views\Tests\ViewTestData; use Drupal\views\Tests\ViewUnitTestBase; use Drupal\views\Views; @@ -37,16 +38,11 @@ class ViewEntityDependenciesTest extends ViewUnitTestBase { * {@inheritdoc} */ protected function setUp() { - parent::setUp(); + parent::setUp(FALSE); + // Install the necessary dependencies for node type creation to work. $this->installEntitySchema('node'); $this->installConfig(array('field', 'node')); - } - - /** - * Tests the calculateDependencies method. - */ - public function testCalculateDependencies() { $comment_type = entity_create('comment_type', array( 'id' => 'comment', @@ -55,6 +51,7 @@ public function testCalculateDependencies() { 'target_entity_type_id' => 'node', )); $comment_type->save(); + $content_type = entity_create('node_type', array( 'type' => $this->randomMachineName(), 'name' => $this->randomString(), @@ -82,6 +79,13 @@ public function testCalculateDependencies() { 'settings' => array('display_summary' => TRUE), ))->save(); + ViewTestData::createTestViews(get_class($this), array('views_test_config')); + } + + /** + * Tests the calculateDependencies method. + */ + public function testCalculateDependencies() { $expected = []; $expected['test_field_get_entity'] = [ 'module' => [ diff --git a/core/modules/views/src/Tests/ViewUnitTestBase.php b/core/modules/views/src/Tests/ViewUnitTestBase.php index 2de7f2b..eaa2694 100644 --- a/core/modules/views/src/Tests/ViewUnitTestBase.php +++ b/core/modules/views/src/Tests/ViewUnitTestBase.php @@ -33,11 +33,23 @@ */ public static $modules = array('system', 'views', 'views_test_config', 'views_test_data'); - protected function setUp() { + /** + * {@inheritdoc} + * + * @param bool $import_test_views + * Should the views specififed on the test class be imported. If you need + * to setup some additional stuff, like fields, you need to call false and + * then call createTestViews for your own. + */ + protected function setUp($import_test_views = TRUE) { parent::setUp(); $this->installSchema('system', array('router', 'sequences')); $this->setUpFixtures(); + + if ($import_test_views) { + ViewTestData::createTestViews(get_class($this), array('views_test_config')); + } } /** @@ -46,7 +58,7 @@ protected function setUp() { * Because the schema of views_test_data.module is dependent on the test * using it, it cannot be enabled normally. */ - protected function setUpFixtures() { + protected function setUpFixtures($import_test_views = TRUE) { // First install the system module. Many Views have Page displays have menu // links, and for those to work, the system menus must already be present. $this->installConfig(array('system')); @@ -70,8 +82,6 @@ protected function setUpFixtures() { $query->values($record); } $query->execute(); - - ViewTestData::createTestViews(get_class($this), array('views_test_config')); } /**