Same name and namespace in other branches
  1. 8.9.x core/modules/content_translation/tests/src/Functional/ContentTranslationLinkTagTest.php \Drupal\Tests\content_translation\Functional\ContentTranslationLinkTagTest::testCanonicalAlternateTagsMissing()
  2. 9 core/modules/content_translation/tests/src/Functional/ContentTranslationLinkTagTest.php \Drupal\Tests\content_translation\Functional\ContentTranslationLinkTagTest::testCanonicalAlternateTagsMissing()

Tests alternate link tag missing for entity types without canonical links.

File

core/modules/content_translation/tests/src/Functional/ContentTranslationLinkTagTest.php, line 145

Class

ContentTranslationLinkTagTest
Tests whether canonical link tags are present for content entities.

Namespace

Drupal\Tests\content_translation\Functional

Code

public function testCanonicalAlternateTagsMissing() {

  /** @var \Drupal\Core\Entity\EntityTypeManagerInterface $entityTypeManager */
  $entityTypeManager = $this->container
    ->get('entity_type.manager');
  $definition = $entityTypeManager
    ->getDefinition('entity_test_translatable_no_skip');

  // Ensure 'canonical' link template does not exist, in case it is added in
  // the future.
  $this
    ->assertFalse($definition
    ->hasLinkTemplate('canonical'), 'Canonical link template does not exist for entity_test_translatable_no_skip entity.');
  $entity = EntityTestTranslatableNoUISkip::create();
  $entity
    ->save();
  $this
    ->drupalGet($entity
    ->toUrl('edit-form'));
  $this
    ->assertSession()
    ->statusCodeEquals(200);
  $this
    ->assertSession()
    ->elementNotExists('xpath', '//link[@rel="alternate" and @hreflang]');
}