Further Drupal 8.6.4 changes. Some core files were not committed before a commit...
[yaffs-website] / web / core / modules / views / tests / src / Functional / Plugin / DisplayEntityReferenceTest.php
index a081ad7d97987f8581620e6e9496afc1bd78df9f..817c51d7875adf8e0b3bab69f0a2cfcad1c5a28d 100644 (file)
@@ -5,7 +5,7 @@ namespace Drupal\Tests\views\Functional\Plugin;
 use Drupal\entity_test\Entity\EntityTest;
 use Drupal\field\Entity\FieldConfig;
 use Drupal\field\Entity\FieldStorageConfig;
-use Drupal\field\Tests\EntityReference\EntityReferenceTestTrait;
+use Drupal\Tests\field\Traits\EntityReferenceTestTrait;
 use Drupal\Tests\views\Functional\ViewTestBase;
 use Drupal\views\Views;
 
@@ -125,6 +125,10 @@ class DisplayEntityReferenceTest extends ViewTestBase {
    * Tests the entity reference display plugin.
    */
   public function testEntityReferenceDisplay() {
+    // Test that the 'title' settings are not shown.
+    $this->drupalGet('admin/structure/views/view/test_display_entity_reference/edit/entity_reference_1');
+    $this->assertSession()->linkByHrefNotExists('admin/structure/views/nojs/display/test_display_entity_reference/entity_reference_1/title');
+
     // Add the new field to the fields.
     $this->drupalPostForm('admin/structure/views/nojs/add-handler/test_display_entity_reference/default/field', ['name[entity_test__' . $this->fieldName . '.' . $this->fieldName . ']' => TRUE], t('Add and configure fields'));
     $this->drupalPostForm(NULL, [], t('Apply'));
@@ -209,7 +213,7 @@ class DisplayEntityReferenceTest extends ViewTestBase {
     $this->drupalPostForm('admin/structure/views/nojs/display/test_display_entity_reference/entity_reference_1/style_options', ['style_options[search_fields][uid]' => 'uid'], t('Apply'));
     $this->drupalPostForm(NULL, [], t('Save'));
 
-    // Test that the search still works with the ralated field.
+    // Test that the search still works with the related field.
     $view = Views::getView('test_display_entity_reference');
     $view->setDisplay('entity_reference_1');
 
@@ -249,6 +253,12 @@ class DisplayEntityReferenceTest extends ViewTestBase {
     $this->executeView($view);
 
     $this->assertEqual(count($view->result), 2, 'Search returned two rows');
+
+    // Test that the render() return empty array for empty result.
+    $view = Views::getView('test_display_entity_reference');
+    $view->setDisplay('entity_reference_1');
+    $render = $view->display_handler->render();
+    $this->assertSame([], $render, 'Render returned empty array');
   }
 
 }