Updated to Drupal 8.5. Core Media not yet in use.
[yaffs-website] / web / core / modules / views / tests / src / Kernel / Handler / FieldEntityLinkTest.php
index 874f03d4fccf7e806f393d7b80d4a06fcf634287..a7f5116f35ac8902a146831f5fcfe09e2bf6b471 100644 (file)
@@ -67,11 +67,11 @@ class FieldEntityLinkTest extends ViewsKernelTestBase {
    */
   public function testEntityLink() {
     // Anonymous users cannot see edit/delete links.
-    $expected_results = ['canonical' => TRUE, 'edit-form' => FALSE, 'delete-form' => FALSE];
+    $expected_results = ['canonical' => TRUE, 'edit-form' => FALSE, 'delete-form' => FALSE, 'canonical_raw' => TRUE, 'canonical_raw_absolute' => TRUE];
     $this->doTestEntityLink(\Drupal::currentUser(), $expected_results);
 
     // Admin users cannot see all links.
-    $expected_results = ['canonical' => TRUE, 'edit-form' => TRUE, 'delete-form' => TRUE];
+    $expected_results = ['canonical' => TRUE, 'edit-form' => TRUE, 'delete-form' => TRUE, 'canonical_raw' => TRUE, 'canonical_raw_absolute' => TRUE];
     $this->doTestEntityLink($this->adminUser, $expected_results);
   }
 
@@ -94,16 +94,39 @@ class FieldEntityLinkTest extends ViewsKernelTestBase {
         'label' => 'View entity test',
         'field_id' => 'view_entity_test',
         'destination' => FALSE,
+        'link' => TRUE,
+        'options' => [],
+        'relationship' => 'canonical',
       ],
       'edit-form' => [
         'label' => 'Edit entity test',
         'field_id' => 'edit_entity_test',
         'destination' => TRUE,
+        'link' => TRUE,
+        'options' => [],
+        'relationship' => 'edit-form',
       ],
       'delete-form' => [
         'label' => 'Delete entity test',
         'field_id' => 'delete_entity_test',
         'destination' => TRUE,
+        'link' => TRUE,
+        'options' => [],
+        'relationship' => 'delete-form',
+      ],
+      'canonical_raw' => [
+        'field_id' => 'canonical_entity_test',
+        'destination' => FALSE,
+        'link' => FALSE,
+        'options' => [],
+        'relationship' => 'canonical',
+      ],
+      'canonical_raw_absolute' => [
+        'field_id' => 'absolute_entity_test',
+        'destination' => FALSE,
+        'link' => FALSE,
+        'options' => ['absolute' => TRUE],
+        'relationship' => 'canonical',
       ],
     ];
 
@@ -112,9 +135,14 @@ class FieldEntityLinkTest extends ViewsKernelTestBase {
       foreach ($expected_results as $template => $expected_result) {
         $expected_link = '';
         if ($expected_result) {
-          $path = $entity->url($template);
+          $path = $entity->url($info[$template]['relationship'], $info[$template]['options']);
           $destination = $info[$template]['destination'] ? '?destination=/' : '';
-          $expected_link = '<a href="' . $path . $destination . '" hreflang="en">' . $info[$template]['label'] . '</a>';
+          if ($info[$template]['link']) {
+            $expected_link = '<a href="' . $path . $destination . '" hreflang="en">' . $info[$template]['label'] . '</a>';
+          }
+          else {
+            $expected_link = $path;
+          }
         }
         $link = $view->style_plugin->getField($index, $info[$template]['field_id']);
         $this->assertEqual($link, $expected_link);