comparison core/modules/field/src/Tests/EntityReference/EntityReferenceAdminTest.php @ 12:7a779792577d

Update Drupal core to v8.4.5 (via Composer)
author Chris Cannam
date Fri, 23 Feb 2018 15:52:07 +0000
parents 4c8ae668cc8c
children 1fec387a4317
comparison
equal deleted inserted replaced
11:bfffd8d7479a 12:7a779792577d
328 'cardinality' => -1, 328 'cardinality' => -1,
329 ]; 329 ];
330 $this->drupalPostForm(NULL, $edit, t('Save field settings')); 330 $this->drupalPostForm(NULL, $edit, t('Save field settings'));
331 $this->drupalGet($bundle_path . '/fields/' . $field_path); 331 $this->drupalGet($bundle_path . '/fields/' . $field_path);
332 $term_name = $this->randomString(); 332 $term_name = $this->randomString();
333 $result = \Drupal::entityQuery('taxonomy_term')
334 ->condition('name', $term_name)
335 ->condition('vid', 'tags')
336 ->accessCheck(FALSE)
337 ->execute();
338 $this->assertIdentical(0, count($result), "No taxonomy terms exist with the name '$term_name'.");
333 $edit = [ 339 $edit = [
334 // This must be set before new entities will be auto-created. 340 // This must be set before new entities will be auto-created.
335 'settings[handler_settings][auto_create]' => 1, 341 'settings[handler_settings][auto_create]' => 1,
336 ]; 342 ];
337 $this->drupalPostForm(NULL, $edit, t('Save settings')); 343 $this->drupalPostForm(NULL, $edit, t('Save settings'));
340 // A term that doesn't yet exist. 346 // A term that doesn't yet exist.
341 'default_value_input[field_' . $taxonomy_term_field_name . '][0][target_id]' => $term_name, 347 'default_value_input[field_' . $taxonomy_term_field_name . '][0][target_id]' => $term_name,
342 ]; 348 ];
343 $this->drupalPostForm(NULL, $edit, t('Save settings')); 349 $this->drupalPostForm(NULL, $edit, t('Save settings'));
344 // The term should now exist. 350 // The term should now exist.
345 $term = taxonomy_term_load_multiple_by_name($term_name, 'tags')[1]; 351 $result = \Drupal::entityQuery('taxonomy_term')
346 $this->assertIdentical(1, count($term), 'Taxonomy term was auto created when set as field default.'); 352 ->condition('name', $term_name)
353 ->condition('vid', 'tags')
354 ->accessCheck(FALSE)
355 ->execute();
356 $this->assertIdentical(1, count($result), 'Taxonomy term was auto created when set as field default.');
347 } 357 }
348 358
349 /** 359 /**
350 * Tests the formatters for the Entity References. 360 * Tests the formatters for the Entity References.
351 */ 361 */