2 declare(strict_types = 1);
21 use TYPO3\TestingFramework\Core\Functional\Framework\DataHandling\Scenario\DataHandlerFactory;
22 use TYPO3\TestingFramework\Core\Functional\Framework\DataHandling\Scenario\DataHandlerWriter;
23 use TYPO3\TestingFramework\Core\Functional\Framework\Frontend\InternalRequest;
24 use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase;
43 'EN' => [
'id' => 0,
'title' =>
'English',
'locale' =>
'en_US.UTF8',
'iso' =>
'en',
'hrefLang' =>
'en-US',
'direction' =>
''],
44 'DE' => [
'id' => 1,
'title' =>
'German',
'locale' =>
'de_DE.UTF8',
'iso' =>
'de',
'hrefLang' =>
'de-DE',
'direction' =>
''],
49 parent::setUpBeforeClass();
50 static::initializeDatabaseSnapshot();
55 static::destroyDatabaseSnapshot();
56 parent::tearDownAfterClass();
59 protected function setUp(): void
84 $this->setUpFrontendRootPage(
86 [
'typo3/sysext/seo/Tests/Functional/Fixtures/HrefLang.typoscript']
89 $response = $this->executeFrontendRequest(
90 new InternalRequest($url)
92 $stream = $response->getBody();
94 $content = $stream->getContents();
96 foreach ($expectedTags as $expectedTag) {
97 self::assertContains($expectedTag, $content);
100 foreach ($notExpectedTags as $notExpectedTag) {
101 self::assertNotContains($notExpectedTag, $content);
111 'No translation available, so no hreflang tags expected' => [
115 '<link rel="alternate" hreflang='
118 'English page, with German translation' => [
119 'https://acme.com/hello',
121 '<link rel="alternate" hreflang="en-US" href="https://acme.com/hello"/>',
122 '<link rel="alternate" hreflang="de-DE" href="https://acme.com/de/willkommen"/>',
123 '<link rel="alternate" hreflang="x-default" href="https://acme.com/hello"/>',
127 'German page, with English translation and English default' => [
128 'https://acme.com/de/willkommen',
130 '<link rel="alternate" hreflang="en-US" href="https://acme.com/hello"/>',
131 '<link rel="alternate" hreflang="de-DE" href="https://acme.com/de/willkommen"/>',
132 '<link rel="alternate" hreflang="x-default" href="https://acme.com/hello"/>',
145 $this->withDatabaseSnapshot(
function () use ($pathToYamlFile) {
146 $backendUser = $this->setUpBackendUserFromFixture(1);
149 $factory = DataHandlerFactory::fromYamlFile($pathToYamlFile);
150 $writer = DataHandlerWriter::withBackendUser($backendUser);
151 $writer->invokeFactory($factory);
152 static::failIfArrayIsNotEmpty(
168 'Array was not empty as expected, but contained these items:' . LF
169 .
'* ' . implode(LF .
'* ', $items)