protected function EntityReferenceIntegrationTest::assertFieldValues in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/field/src/Tests/EntityReference/EntityReferenceIntegrationTest.php \Drupal\field\Tests\EntityReference\EntityReferenceIntegrationTest::assertFieldValues()
Asserts that the reference field values are correct.
Parameters
string $entity_name: The name of the test entity.
\Drupal\Core\Entity\EntityInterface[] $referenced_entities: An array of referenced entities.
1 call to EntityReferenceIntegrationTest::assertFieldValues()
- EntityReferenceIntegrationTest::testSupportedEntityTypesAndWidgets in core/
modules/ field/ src/ Tests/ EntityReference/ EntityReferenceIntegrationTest.php - Tests the entity reference field with all its supported field widgets.
File
- core/
modules/ field/ src/ Tests/ EntityReference/ EntityReferenceIntegrationTest.php, line 179 - Contains \Drupal\field\Tests\EntityReference\EntityReferenceIntegrationTest.
Class
- EntityReferenceIntegrationTest
- Tests various Entity reference UI components.
Namespace
Drupal\field\Tests\EntityReferenceCode
protected function assertFieldValues($entity_name, $referenced_entities) {
$entity = current(entity_load_multiple_by_properties($this->entityType, array(
'name' => $entity_name,
)));
$this
->assertTrue($entity, format_string('%entity_type: Entity found in the database.', array(
'%entity_type' => $this->entityType,
)));
$this
->assertEqual($entity->{$this->fieldName}->target_id, $referenced_entities[0]
->id());
$this
->assertEqual($entity->{$this->fieldName}->entity
->id(), $referenced_entities[0]
->id());
$this
->assertEqual($entity->{$this->fieldName}->entity
->label(), $referenced_entities[0]
->label());
$this
->assertEqual($entity->{$this->fieldName}[1]->target_id, $referenced_entities[1]
->id());
$this
->assertEqual($entity->{$this->fieldName}[1]->entity
->id(), $referenced_entities[1]
->id());
$this
->assertEqual($entity->{$this->fieldName}[1]->entity
->label(), $referenced_entities[1]
->label());
}