‪TYPO3CMS  ‪main
TypoScriptFrontendControllerTest.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\Unit\UnitTestCase;
22 
23 final class ‪TypoScriptFrontendControllerTest extends UnitTestCase
24 {
25  public static function ‪baseUrlWrapHandlesDifferentUrlsDataProvider(): array
26  {
27  return [
28  'without base url' => [
29  '',
30  'fileadmin/user_uploads/image.jpg',
31  'fileadmin/user_uploads/image.jpg',
32  ],
33  'with base url' => [
34  'http://www.google.com/',
35  'fileadmin/user_uploads/image.jpg',
36  'http://www.google.com/fileadmin/user_uploads/image.jpg',
37  ],
38  'without base url but with url prepended with a forward slash' => [
39  '',
40  '/fileadmin/user_uploads/image.jpg',
41  '/fileadmin/user_uploads/image.jpg',
42  ],
43  'with base url but with url prepended with a forward slash' => [
44  'http://www.google.com/',
45  '/fileadmin/user_uploads/image.jpg',
46  '/fileadmin/user_uploads/image.jpg',
47  ],
48  ];
49  }
50 
55  public function ‪baseUrlWrapHandlesDifferentUrls(string $baseUrl, string ‪$url, string $expected): void
56  {
57  $subject = $this->getMockBuilder(TypoScriptFrontendController::class)->disableOriginalConstructor()->onlyMethods([])->getMock();
58  $subject->config['config']['baseURL'] = $baseUrl;
59  self::assertSame($expected, $subject->baseUrlWrap(‪$url, true));
60  }
61 }
‪TYPO3\CMS\Frontend\Tests\Unit\Controller\TypoScriptFrontendControllerTest
Definition: TypoScriptFrontendControllerTest.php:24
‪TYPO3\CMS\Frontend\Tests\Unit\Controller\TypoScriptFrontendControllerTest\baseUrlWrapHandlesDifferentUrlsDataProvider
‪static baseUrlWrapHandlesDifferentUrlsDataProvider()
Definition: TypoScriptFrontendControllerTest.php:25
‪TYPO3\CMS\Frontend\Tests\Unit\Controller
Definition: ErrorControllerTest.php:18
‪TYPO3\CMS\Webhooks\Message\$url
‪identifier readonly UriInterface $url
Definition: LoginErrorOccurredMessage.php:36
‪TYPO3\CMS\Frontend\Controller\TypoScriptFrontendController
Definition: TypoScriptFrontendController.php:105
‪TYPO3\CMS\Frontend\Tests\Unit\Controller\TypoScriptFrontendControllerTest\baseUrlWrapHandlesDifferentUrls
‪baseUrlWrapHandlesDifferentUrls(string $baseUrl, string $url, string $expected)
Definition: TypoScriptFrontendControllerTest.php:55