function ContentTranslationLinkTagTest::testCanonicalAlternateTagsMissing

Same name in other branches
  1. 9 core/modules/content_translation/tests/src/Functional/ContentTranslationLinkTagTest.php \Drupal\Tests\content_translation\Functional\ContentTranslationLinkTagTest::testCanonicalAlternateTagsMissing()
  2. 8.9.x core/modules/content_translation/tests/src/Functional/ContentTranslationLinkTagTest.php \Drupal\Tests\content_translation\Functional\ContentTranslationLinkTagTest::testCanonicalAlternateTagsMissing()
  3. 10 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 146

Class

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

Namespace

Drupal\Tests\content_translation\Functional

Code

public function testCanonicalAlternateTagsMissing() : void {
    
    /** @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]');
}

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