function EntityReferenceFieldTranslatedReferenceViewTest::assertEntityReferenceFormDisplay

Same name in other branches
  1. 9 core/modules/field/tests/src/Functional/EntityReference/EntityReferenceFieldTranslatedReferenceViewTest.php \Drupal\Tests\field\Functional\EntityReference\EntityReferenceFieldTranslatedReferenceViewTest::assertEntityReferenceFormDisplay()
  2. 8.9.x core/modules/field/tests/src/Functional/EntityReference/EntityReferenceFieldTranslatedReferenceViewTest.php \Drupal\Tests\field\Functional\EntityReference\EntityReferenceFieldTranslatedReferenceViewTest::assertEntityReferenceFormDisplay()
  3. 10 core/modules/field/tests/src/Functional/EntityReference/EntityReferenceFieldTranslatedReferenceViewTest.php \Drupal\Tests\field\Functional\EntityReference\EntityReferenceFieldTranslatedReferenceViewTest::assertEntityReferenceFormDisplay()

Assert entity reference form display.

@internal

1 call to EntityReferenceFieldTranslatedReferenceViewTest::assertEntityReferenceFormDisplay()
EntityReferenceFieldTranslatedReferenceViewTest::testEntityReferenceDisplay in core/modules/field/tests/src/Functional/EntityReference/EntityReferenceFieldTranslatedReferenceViewTest.php
Tests if the entity is displayed in an entity reference field.

File

core/modules/field/tests/src/Functional/EntityReference/EntityReferenceFieldTranslatedReferenceViewTest.php, line 203

Class

EntityReferenceFieldTranslatedReferenceViewTest
Tests the translation of entity reference field display on nodes.

Namespace

Drupal\Tests\field\Functional\EntityReference

Code

protected function assertEntityReferenceFormDisplay() : void {
    $this->drupalLogin($this->webUser);
    $url = $this->referrerEntity
        ->toUrl('edit-form');
    $translation_url = $this->referrerEntity
        ->toUrl('edit-form', [
        'language' => ConfigurableLanguage::load($this->translateToLangcode),
    ]);
    $this->drupalGet($url);
    $this->assertSession()
        ->fieldValueEquals('test_reference_field[0][target_id]', $this->originalLabel . ' (1)');
    $this->assertSession()
        ->fieldValueEquals('test_reference_field[1][target_id]', $this->labelOfNotTranslatedReference . ' (2)');
    $this->drupalGet($translation_url);
    $this->assertSession()
        ->fieldValueEquals('test_reference_field[0][target_id]', $this->translatedLabel . ' (1)');
    $this->assertSession()
        ->fieldValueEquals('test_reference_field[1][target_id]', $this->labelOfNotTranslatedReference . ' (2)');
    $this->drupalLogout();
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.