‪TYPO3CMS  11.5
RelativeCssPathFixerTest.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 
26 {
30  protected ‪$backupEnvironment = true;
31 
35  public function ‪fixRelativeUrlPathsDataProvider(): array
36  {
37  return [
38  '@import from fileadmin with relative' => [
39  '@import url(../tests/test.css); body { background: #ffffff; }',
40  '/fileadmin/css/',
41  '@import url(\'/fileadmin/tests/test.css\'); body { background: #ffffff; }',
42  ],
43  '@import from fileadmin with no relative' => [
44  '@import url(test.css); body { background: #ffffff; }',
45  'fileadmin/css/',
46  '@import url(\'fileadmin/css/test.css\'); body { background: #ffffff; }',
47  ],
48  '@import from sitepackage with no relative' => [
49  '@import url(test.css); body { background: #ffffff; }',
50  'typo3conf/ext/sitepackage/Resources/Public/Css/',
51  '@import url(\'typo3conf/ext/sitepackage/Resources/Public/Css/test.css\'); body { background: #ffffff; }',
52  ],
53  'url() from sitepackage with relative' => [
54  '@font-face {
55  font-family: "Testfont"
56  src: url("../fonts/testfont.woff2") format("woff2"),
57  url("../fonts/testfont.woff") format("woff");
58  }',
59  '../../../typo3conf/ext/sitepackage/Resources/Public/Css/',
60  '@font-face {
61  font-family: "Testfont"
62  src: url(\'../../../typo3conf/ext/sitepackage/Resources/Public/fonts/testfont.woff2\') format("woff2"),
63  url(\'../../../typo3conf/ext/sitepackage/Resources/Public/fonts/testfont.woff\') format("woff");
64  }',
65  ],
66  'url() from fileadmin with no relative' => [
67  '@font-face {
68  font-family: "Testfont"
69  src: url("../fonts/testfont.woff2") format("woff2"),
70  url("../fonts/testfont.woff") format("woff");
71  }',
72  'fileadmin/css/',
73  '@font-face {
74  font-family: "Testfont"
75  src: url(\'fileadmin/fonts/testfont.woff2\') format("woff2"),
76  url(\'fileadmin/fonts/testfont.woff\') format("woff");
77  }',
78  ],
79  ];
80  }
81 
89  public function ‪fixRelativeUrlPaths(string $css, string $newDir, string $expected): void
90  {
91  $subject = new ‪RelativeCssPathFixer();
92  $fixedCssPath = $subject->fixRelativeUrlPaths($css, $newDir);
93  self::assertSame($expected, $fixedCssPath);
94  }
95 }
‪TYPO3\CMS\Core\Tests\Unit\Resource\RelativeCssPathFixerTest\$backupEnvironment
‪bool $backupEnvironment
Definition: RelativeCssPathFixerTest.php:29
‪TYPO3\CMS\Core\Tests\Unit\Resource
Definition: AbstractFileTest.php:18
‪TYPO3\CMS\Core\Tests\Unit\Resource\BaseTestCase
Definition: BaseTestCase.php:31
‪TYPO3\CMS\Core\Tests\Unit\Resource\RelativeCssPathFixerTest\fixRelativeUrlPathsDataProvider
‪array fixRelativeUrlPathsDataProvider()
Definition: RelativeCssPathFixerTest.php:34
‪TYPO3\CMS\Core\Tests\Unit\Resource\RelativeCssPathFixerTest
Definition: RelativeCssPathFixerTest.php:26
‪TYPO3\CMS\Core\Tests\Unit\Resource\RelativeCssPathFixerTest\fixRelativeUrlPaths
‪fixRelativeUrlPaths(string $css, string $newDir, string $expected)
Definition: RelativeCssPathFixerTest.php:88
‪TYPO3\CMS\Core\Resource\RelativeCssPathFixer
Definition: RelativeCssPathFixer.php:29