‪TYPO3CMS  11.5
HrefLangGeneratorTest.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 
20 use Prophecy\PhpUnit\ProphecyTrait;
21 use Psr\Http\Message\UriInterface;
23 use TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer;
26 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
27 
31 class ‪HrefLangGeneratorTest extends UnitTestCase
32 {
33  use ProphecyTrait;
34 
42  public function ‪checkIfGetSiteLanguageIsCalled(string $url): void
43  {
44  $subject = $this->getAccessibleMock(
45  HrefLangGenerator::class,
46  ['getSiteLanguage'],
47  [
48  $this->prophesize(ContentObjectRenderer::class)->reveal(),
49  $this->prophesize(LanguageMenuProcessor::class)->reveal(),
50  ]
51  );
52 
53  $siteLanguageProphecy = $this->prophesize(SiteLanguage::class);
54  $siteLanguageProphecy->getBase()->willReturn($this->prophesize(UriInterface::class)->reveal());
55  $subject->_call('getAbsoluteUrl', $url, $siteLanguageProphecy->reveal());
56  }
57 
61  public function ‪urlPathDataProvider(): array
62  {
63  return [
64  [
65  '/',
66  ],
67  [
68  'example.com',
69  ],
70  [
71  'filename.pdf',
72  ],
73  [
74  'example.com/filename.pdf',
75  ],
76  [
77  '//example.com/filename.pdf',
78  ],
79  [
80  '//example.com',
81  ],
82  [
83  'https://example.com',
84  ],
85  [
86  '/page-1/subpage-1',
87  ],
88  [
89  'https://example.com/page-1/subpage-1',
90  ],
91  ];
92  }
93 }
‪TYPO3\CMS\Frontend\DataProcessing\LanguageMenuProcessor
Definition: LanguageMenuProcessor.php:45
‪TYPO3\CMS\Core\Site\Entity\SiteLanguage
Definition: SiteLanguage.php:26
‪TYPO3\CMS\Seo\HrefLang\HrefLangGenerator
Definition: HrefLangGenerator.php:38
‪TYPO3\CMS\Seo\Tests\Unit\HrefLang\HrefLangGeneratorTest\checkIfGetSiteLanguageIsCalled
‪checkIfGetSiteLanguageIsCalled(string $url)
Definition: HrefLangGeneratorTest.php:41
‪TYPO3\CMS\Seo\Tests\Unit\HrefLang\HrefLangGeneratorTest\urlPathDataProvider
‪array urlPathDataProvider()
Definition: HrefLangGeneratorTest.php:60
‪TYPO3\CMS\Seo\Tests\Unit\HrefLang\HrefLangGeneratorTest
Definition: HrefLangGeneratorTest.php:32
‪TYPO3\CMS\Seo\Tests\Unit\HrefLang
Definition: HrefLangGeneratorTest.php:18