Skip to content
Snippets Groups Projects
Commit f8ff417c authored by Angie Byron's avatar Angie Byron
Browse files

Issue #2579411 by yched: Resolve @todo by adding test in EntityReferenceFieldTest

parent 4694001f
Branches
Tags
2 merge requests!7452Issue #1797438. HTML5 validation is preventing form submit and not fully...,!789Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10
......@@ -105,8 +105,14 @@ public function testEntityReferenceFieldValidation() {
$this->assertEqual($violations->count(), 1, 'Validation throws a violation.');
$this->assertEqual($violations[0]->getMessage(), t('The referenced entity (%type: %id) does not exist.', array('%type' => $this->referencedEntityType, '%id' => 9999)));
// @todo Implement a test case for invalid bundle references after
// https://www.drupal.org/node/2064191 is fixed.
// Test a non-referenceable bundle.
entity_test_create_bundle('non_referenceable', NULL, $this->referencedEntityType);
$referenced_entity = entity_create($this->referencedEntityType, array('type' => 'non_referenceable'));
$referenced_entity->save();
$entity->{$this->fieldName}->target_id = $referenced_entity->id();
$violations = $entity->{$this->fieldName}->validate();
$this->assertEqual($violations->count(), 1, 'Validation throws a violation.');
$this->assertEqual($violations[0]->getMessage(), t('The entity must be of bundle %bundle.', array('%bundle' => $this->bundle)));
}
/**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment