function EntityReferenceFieldTranslatedReferenceViewTest::assertEntityReferenceDisplay

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

Assert entity reference display.

@internal

1 call to EntityReferenceFieldTranslatedReferenceViewTest::assertEntityReferenceDisplay()
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 184

Class

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

Namespace

Drupal\Tests\field\Functional\EntityReference

Code

protected function assertEntityReferenceDisplay() : void {
    $url = $this->referrerEntity
        ->toUrl();
    $translation_url = $this->referrerEntity
        ->toUrl('canonical', [
        'language' => ConfigurableLanguage::load($this->translateToLangcode),
    ]);
    $this->drupalGet($url);
    $this->assertSession()
        ->pageTextContains($this->labelOfNotTranslatedReference);
    $this->assertSession()
        ->pageTextContains($this->originalLabel);
    $this->assertSession()
        ->pageTextNotContains($this->translatedLabel);
    $this->drupalGet($translation_url);
    $this->assertSession()
        ->pageTextContains($this->labelOfNotTranslatedReference);
    $this->assertSession()
        ->pageTextNotContains($this->originalLabel);
    $this->assertSession()
        ->pageTextContains($this->translatedLabel);
}

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