Updated to Drupal 8.5. Core Media not yet in use.
[yaffs-website] / web / core / modules / field / src / Tests / EntityReference / EntityReferenceAdminTest.php
index fa68cb61509fe71a40052aacbdf779b18e0f80f4..9bacb07d9642bf163f267b12f2d176d0497e6a4c 100644 (file)
@@ -94,6 +94,8 @@ class EntityReferenceAdminTest extends WebTestBase {
 
     // The base handler settings should be displayed.
     $entity_type_id = 'node';
+    // Check that the type label is correctly displayed.
+    $this->assertText('Content type');
     $bundles = $this->container->get('entity_type.bundle.info')->getBundleInfo($entity_type_id);
     foreach ($bundles as $bundle_name => $bundle_info) {
       $this->assertFieldByName('settings[handler_settings][target_bundles][' . $bundle_name . ']');
@@ -330,6 +332,12 @@ class EntityReferenceAdminTest extends WebTestBase {
     $this->drupalPostForm(NULL, $edit, t('Save field settings'));
     $this->drupalGet($bundle_path . '/fields/' . $field_path);
     $term_name = $this->randomString();
+    $result = \Drupal::entityQuery('taxonomy_term')
+      ->condition('name', $term_name)
+      ->condition('vid', 'tags')
+      ->accessCheck(FALSE)
+      ->execute();
+    $this->assertIdentical(0, count($result), "No taxonomy terms exist with the name '$term_name'.");
     $edit = [
       // This must be set before new entities will be auto-created.
       'settings[handler_settings][auto_create]' => 1,
@@ -342,8 +350,12 @@ class EntityReferenceAdminTest extends WebTestBase {
     ];
     $this->drupalPostForm(NULL, $edit, t('Save settings'));
     // The term should now exist.
-    $term = taxonomy_term_load_multiple_by_name($term_name, 'tags')[1];
-    $this->assertIdentical(1, count($term), 'Taxonomy term was auto created when set as field default.');
+    $result = \Drupal::entityQuery('taxonomy_term')
+      ->condition('name', $term_name)
+      ->condition('vid', 'tags')
+      ->accessCheck(FALSE)
+      ->execute();
+    $this->assertIdentical(1, count($result), 'Taxonomy term was auto created when set as field default.');
   }
 
   /**