‪TYPO3CMS  10.4
MetaTagTest.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
5 /*
6  * This file is part of the TYPO3 CMS project.
7  *
8  * It is free software; you can redistribute it and/or modify it under
9  * the terms of the GNU General Public License, either version 2
10  * of the License, or any later version.
11  *
12  * For the full copyright and license information, please read the
13  * LICENSE.txt file that was distributed with this source code.
14  *
15  * The TYPO3 project - inspiring people to share!
16  */
17 
19 
21 use TYPO3\TestingFramework\Core\Functional\Framework\Frontend\InternalRequest;
22 
27 {
28  protected function ‪setUp(): void
29  {
30  $this->coreExtensionsToLoad[] = 'seo';
31 
32  parent::setUp();
33  $this->importDataSet(ORIGINAL_ROOT . 'typo3/sysext/seo/Tests/Functional/Fixtures/Scenarios/pages_with_seo_meta.xml');
34 
36  'website-local',
37  $this->‪buildSiteConfiguration(1, 'http://localhost/'),
38  [
39  $this->‪buildDefaultLanguageConfiguration('EN', '/')
40  ]
41  );
42  }
43 
44  public function ‪ensureMetaDataAreCorrectDataProvider(): array
45  {
46  return [
47  'page with twitter_card in page properties' => [
48  1,
49  [
50  ['type' => 'name' , 'tag' => 'twitter:card', 'content' => 'summary'],
51  ]
52  ],
53  'page with twitter_card in page properties and in typoscript' => [
54  2,
55  [
56  ['type' => 'name' , 'tag' => 'twitter:card', 'content' => 'summary'],
57  ]
58  ],
59  'page with twitter_card in page properties and in typoscript with replace' => [
60  3,
61  [
62  ['type' => 'name' , 'tag' => 'twitter:card', 'content' => 'summary_large_image'],
63  ]
64  ],
65  ];
66  }
67 
74  public function ‪ensureMetaDataAreCorrect(int $pageId, array $expectedMetaTags): void
75  {
76  $this->setUpFrontendRootPage(1, ['typo3/sysext/seo/Tests/Functional/Fixtures/page' . $pageId . '.typoscript']);
77 
78  // First hit to create a cached version
79  $uncachedResponse = $this->executeFrontendRequest(
80  (new InternalRequest('http://localhost/'))->withQueryParameters([
81  'id' => $pageId,
82  ])
83  );
84  $body = (string)$uncachedResponse->getBody();
85 
86  foreach ($expectedMetaTags as $expectedMetaTag) {
87  self::assertStringContainsString('<meta ' . $expectedMetaTag['type'] . '="' . $expectedMetaTag['tag'] . '" content="' . $expectedMetaTag['content'] . '" />', $body);
88  }
89  }
90 }
‪TYPO3\CMS\Seo\Tests\Functional\MetaTag\MetaTagTest\setUp
‪setUp()
Definition: MetaTagTest.php:28
‪TYPO3\CMS\Core\Tests\Functional\SiteHandling\SiteBasedTestTrait\writeSiteConfiguration
‪writeSiteConfiguration(string $identifier, array $site=[], array $languages=[], array $errorHandling=[])
Definition: SiteBasedTestTrait.php:58
‪TYPO3\CMS\Seo\Tests\Functional\MetaTag
Definition: MetaTagTest.php:18
‪TYPO3\CMS\Frontend\Tests\Functional\SiteHandling\AbstractTestCase
Definition: AbstractTestCase.php:29
‪TYPO3\CMS\Core\Tests\Functional\SiteHandling\SiteBasedTestTrait\buildDefaultLanguageConfiguration
‪array buildDefaultLanguageConfiguration(string $identifier, string $base)
Definition: SiteBasedTestTrait.php:124
‪TYPO3\CMS\Seo\Tests\Functional\MetaTag\MetaTagTest\ensureMetaDataAreCorrectDataProvider
‪ensureMetaDataAreCorrectDataProvider()
Definition: MetaTagTest.php:44
‪TYPO3\CMS\Seo\Tests\Functional\MetaTag\MetaTagTest\ensureMetaDataAreCorrect
‪ensureMetaDataAreCorrect(int $pageId, array $expectedMetaTags)
Definition: MetaTagTest.php:74
‪TYPO3\CMS\Core\Tests\Functional\SiteHandling\SiteBasedTestTrait\buildSiteConfiguration
‪array buildSiteConfiguration(int $rootPageId, string $base='')
Definition: SiteBasedTestTrait.php:109
‪TYPO3\CMS\Seo\Tests\Functional\MetaTag\MetaTagTest
Definition: MetaTagTest.php:27