diff --git a/core/modules/entity_reference/lib/Drupal/entity_reference/Tests/EntityReferenceAdminTest.php b/core/modules/entity_reference/lib/Drupal/entity_reference/Tests/EntityReferenceAdminTest.php index bbfd49a..b89e4ea 100644 --- a/core/modules/entity_reference/lib/Drupal/entity_reference/Tests/EntityReferenceAdminTest.php +++ b/core/modules/entity_reference/lib/Drupal/entity_reference/Tests/EntityReferenceAdminTest.php @@ -21,13 +21,13 @@ public static function getInfo() { ); } - public static $modules = array('field_ui', 'entity_reference'); + public static $modules = array('field_ui', 'entity_reference', 'comment'); public function setUp() { parent::setUp(); // Create test user. - $this->admin_user = $this->drupalCreateUser(array('access content', 'administer node fields')); + $this->admin_user = $this->drupalCreateUser(array('access content', 'administer node fields', 'administer comment fields')); $this->drupalLogin($this->admin_user); // Create content type, with underscores. @@ -105,4 +105,31 @@ public function testFieldAdminHandler() { // Check that the field appears in the overview form. $this->assertFieldByXPath('//table[@id="field-overview"]//td[1]', 'Test label', t('Field was created and appears in the overview page.')); } + + /** + * Tests the creation of an entity reference field trough the UI on a EntityNG + * entity type. + * + * @todo Remove this test when nodes are converted to EntityNG: http://drupal.org/node/1818556 + */ + public function testFieldAdminEntityNG() { + $comment_bundle_path = 'admin/structure/types/manage/' . $this->type . '/comment'; + + // First step: 'Add new field' on the 'Comment fields' page. + $this->drupalPost($comment_bundle_path . '/fields', array( + 'fields[_add_new_field][label]' => 'Comment test label', + 'fields[_add_new_field][field_name]' => 'comment_test', + 'fields[_add_new_field][type]' => 'entity_reference', + 'fields[_add_new_field][widget_type]' => 'entity_reference_autocomplete', + ), t('Save')); + + // Node should be selected by default. + $this->assertFieldByName('field[settings][target_type]', 'node'); + + // Second step: 'Instance settings' form. + $this->drupalPost(NULL, array(), t('Save field settings')); + + // The base handler should be selected by default. + $this->assertFieldByName('instance[settings][handler]', 'default'); + } }