‪TYPO3CMS  10.4
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 Psr\Http\Message\UriInterface;
25 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
26 
30 class ‪HrefLangGeneratorTest extends UnitTestCase
31 {
40  public function ‪checkIfGetSiteLanguageIsCalled($url, $shouldBeCalled)
41  {
42  $subject = $this->getAccessibleMock(
43  HrefLangGenerator::class,
44  ['getSiteLanguage'],
45  [
46  $this->prophesize(ContentObjectRenderer::class)->reveal(),
47  $this->prophesize(LanguageMenuProcessor::class)->reveal()
48  ]
49  );
50 
51  $siteLanguageProphecy = $this->prophesize(SiteLanguage::class);
52  $siteLanguageProphecy->getBase()->willReturn($this->prophesize(UriInterface::class)->reveal());
53  $subject->_call('getAbsoluteUrl', $url, $siteLanguageProphecy->reveal());
54  }
55 
59  public function ‪urlPathDataProvider(): array
60  {
61  return [
62  [
63  '/',
64  true
65  ],
66  [
67  'example.com',
68  true //This can't be defined as a domain because it can also be a filename
69  ],
70  [
71  'filename.pdf',
72  true
73  ],
74  [
75  'example.com/filename.pdf',
76  true
77  ],
78  [
79  '//example.com/filename.pdf',
80  false
81  ],
82  [
83  '//example.com',
84  false
85  ],
86  [
87  'https://example.com',
88  false
89  ],
90  [
91  '/page-1/subpage-1',
92  true
93  ],
94  [
95  'https://example.com/page-1/subpage-1',
96  false
97  ],
98  ];
99  }
100 }
‪TYPO3\CMS\Frontend\DataProcessing\LanguageMenuProcessor
Definition: LanguageMenuProcessor.php:48
‪TYPO3\CMS\Core\Site\Entity\SiteLanguage
Definition: SiteLanguage.php:26
‪TYPO3\CMS\Seo\HrefLang\HrefLangGenerator
Definition: HrefLangGenerator.php:39
‪TYPO3\CMS\Seo\Tests\Unit\HrefLang\HrefLangGeneratorTest\urlPathDataProvider
‪array urlPathDataProvider()
Definition: HrefLangGeneratorTest.php:59
‪TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer
Definition: ContentObjectRenderer.php:97
‪TYPO3\CMS\Seo\Tests\Unit\HrefLang\HrefLangGeneratorTest
Definition: HrefLangGeneratorTest.php:31
‪TYPO3\CMS\Seo\Tests\Unit\HrefLang
Definition: HrefLangGeneratorTest.php:18
‪TYPO3\CMS\Seo\Tests\Unit\HrefLang\HrefLangGeneratorTest\checkIfGetSiteLanguageIsCalled
‪checkIfGetSiteLanguageIsCalled($url, $shouldBeCalled)
Definition: HrefLangGeneratorTest.php:40