diff --git a/core/modules/entity_reference/lib/Drupal/entity_reference/Tests/EntityReferenceFieldTest.php b/core/modules/entity_reference/lib/Drupal/entity_reference/Tests/EntityReferenceFieldTest.php index 7233374..fc328f8 100644 --- a/core/modules/entity_reference/lib/Drupal/entity_reference/Tests/EntityReferenceFieldTest.php +++ b/core/modules/entity_reference/lib/Drupal/entity_reference/Tests/EntityReferenceFieldTest.php @@ -9,6 +9,7 @@ use Drupal\field\FieldValidationException; use Drupal\system\Tests\Entity\EntityUnitTestBase; +use Drupal\field\Field; /** * Tests for the entity reference field. @@ -89,14 +90,16 @@ public function setUp() { array('target_bundles' => array($this->bundle)) ); - $this->field = field_info_field($this->fieldName); - $this->instance = field_info_instance($this->entityType, $this->fieldName, $this->bundle); + $this->field = Field::fieldInfo()->getField($this->fieldName); + $instances = Field::fieldInfo()->getBundleInstances($this->entityType, $this->bundle); + $this->instance = $instances[$this->fieldName]; } /** * Tests reference field validation. */ - function testEntityReferenceFieldValidation() { + public function testEntityReferenceFieldValidation() { + // Test valid and invalid values with field_attach_validate(). $referenced_entity = entity_create($this->referencedEntityType, array('type' => $this->bundle)); $referenced_entity->save(); @@ -110,11 +113,11 @@ function testEntityReferenceFieldValidation() { $this->fail('Correct reference does not cause validation error.'); } - $bad_referenced_entity = entity_create($this->referencedEntityType, array('type' => drupal_strtolower($this->randomName()))); - $bad_referenced_entity->save(); + $invalid_referenced_entity = entity_create($this->referencedEntityType, array('type' => drupal_strtolower($this->randomName()))); + $invalid_referenced_entity->save(); $entity = entity_create($this->entityType, array('type' => $this->bundle)); - $entity->{$this->fieldName}->target_id = $bad_referenced_entity->id(); + $entity->{$this->fieldName}->target_id = $invalid_referenced_entity->id(); try { field_attach_validate($entity->getBCEntity()); $this->fail('Wrong reference causes validation error.'); @@ -127,7 +130,7 @@ function testEntityReferenceFieldValidation() { /** * Tests that bundle changes are mirrored in field definitions. */ - function testEntityReferenceFieldChangeMachineName() { + public function testEntityReferenceFieldChangeMachineName() { // Add several entries in the 'target_bundles' setting, to make sure that // they all get updated. $test_bundle_2 = drupal_strtolower($this->randomName());