function ContentTranslationLinkTagTest::testCanonicalAlternateTagsMissing
Same name in other branches
- 9 core/modules/content_translation/tests/src/Functional/ContentTranslationLinkTagTest.php \Drupal\Tests\content_translation\Functional\ContentTranslationLinkTagTest::testCanonicalAlternateTagsMissing()
- 10 core/modules/content_translation/tests/src/Functional/ContentTranslationLinkTagTest.php \Drupal\Tests\content_translation\Functional\ContentTranslationLinkTagTest::testCanonicalAlternateTagsMissing()
- 11.x 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 129
Class
- ContentTranslationLinkTagTest
- Tests whether canonical link tags are present for content entities.
Namespace
Drupal\Tests\content_translation\FunctionalCode
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);
$result = $this->xpath('//link[@rel="alternate" and @hreflang]');
$this->assertEmpty($result, 'No alternate link tag found.');
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.