‪TYPO3CMS  9.5
HrefLangGeneratorTest.php
Go to the documentation of this file.
1 <?php
2 declare(strict_types = 1);
3 
5 
6 /*
7  * This file is part of the TYPO3 CMS project.
8  *
9  * It is free software; you can redistribute it and/or modify it under
10  * the terms of the GNU General Public License, either version 2
11  * of the License, or any later version.
12  *
13  * For the full copyright and license information, please read the
14  * LICENSE.txt file that was distributed with this source code.
15  *
16  * The TYPO3 project - inspiring people to share!
17  */
18 
19 use Psr\Http\Message\ServerRequestInterface;
23 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
24 
28 class ‪HrefLangGeneratorTest extends UnitTestCase
29 {
38  public function ‪checkIfGetSiteLanguageIsCalled($url, $shouldBeCalled)
39  {
40  $subject = $this->getAccessibleMock(
41  HrefLangGenerator::class,
42  ['getSiteLanguage'],
43  [
44  $this->prophesize(ContentObjectRenderer::class)->reveal(),
45  $this->prophesize(TypoScriptFrontendController::class)->reveal(),
46  $this->prophesize(ServerRequestInterface::class)->reveal()
47  ]
48  );
49 
50  $check = $shouldBeCalled ? $this->once() : $this->never();
51  $subject->expects($check)->method('getSiteLanguage');
52  $subject->_call('getAbsoluteUrl', $url);
53  }
54 
58  public function ‪urlPathDataProvider(): array
59  {
60  return [
61  [
62  '/',
63  true
64  ],
65  [
66  'example.com',
67  true //This can't be defined as a domain because it can also be a filename
68  ],
69  [
70  'filename.pdf',
71  true
72  ],
73  [
74  'example.com/filename.pdf',
75  true
76  ],
77  [
78  '//example.com/filename.pdf',
79  false
80  ],
81  [
82  '//example.com',
83  false
84  ],
85  [
86  'https://example.com',
87  false
88  ],
89  [
90  '/page-1/subpage-1',
91  true
92  ],
93  [
94  'https://example.com/page-1/subpage-1',
95  false
96  ],
97  ];
98  }
99 }
‪TYPO3\CMS\Seo\HrefLang\HrefLangGenerator
Definition: HrefLangGenerator.php:34
‪TYPO3\CMS\Seo\Tests\Unit\HrefLang\HrefLangGeneratorTest\urlPathDataProvider
‪array urlPathDataProvider()
Definition: HrefLangGeneratorTest.php:58
‪TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController
Definition: TypoScriptFrontendController.php:97
‪TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer
Definition: ContentObjectRenderer.php:91
‪TYPO3\CMS\Seo\Tests\Unit\HrefLang\HrefLangGeneratorTest
Definition: HrefLangGeneratorTest.php:29
‪TYPO3\CMS\Seo\Tests\Unit\HrefLang
Definition: HrefLangGeneratorTest.php:4
‪TYPO3\CMS\Seo\Tests\Unit\HrefLang\HrefLangGeneratorTest\checkIfGetSiteLanguageIsCalled
‪checkIfGetSiteLanguageIsCalled($url, $shouldBeCalled)
Definition: HrefLangGeneratorTest.php:38