You are here

protected function EntityReferenceFieldTranslatedReferenceViewTest::assertEntityReferenceDisplay in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/field/tests/src/Functional/EntityReference/EntityReferenceFieldTranslatedReferenceViewTest.php \Drupal\Tests\field\Functional\EntityReference\EntityReferenceFieldTranslatedReferenceViewTest::assertEntityReferenceDisplay()

Assert entity reference display.

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 179

Class

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

Namespace

Drupal\Tests\field\Functional\EntityReference

Code

protected function assertEntityReferenceDisplay() {
  $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);
}