‪TYPO3CMS  10.4
SlugHelperTest.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 
23 
28 {
32  protected ‪$scenarioDataSetDirectory = 'typo3/sysext/core/Tests/Functional/DataHandling/Slug/DataSet/';
33 
37  protected ‪$assertCleanReferenceIndex = false;
38 
43  protected ‪$siteLanguageConfiguration = [
44  1 => [
45  'title' => 'Dansk',
46  'enabled' => true,
47  'languageId' => 1,
48  'base' => '/dk/',
49  'typo3Language' => 'dk',
50  'locale' => 'da_DK.UTF-8',
51  'iso-639-1' => 'da',
52  'flag' => 'dk',
53  'fallbackType' => 'fallback',
54  'fallbacks' => '0'
55  ],
56  2 => [
57  'title' => 'Deutsch',
58  'enabled' => true,
59  'languageId' => 2,
60  'base' => '/de/',
61  'typo3Language' => 'de',
62  'locale' => 'de_DE.UTF-8',
63  'iso-639-1' => 'de',
64  'flag' => 'de',
65  'fallbackType' => 'fallback',
66  'fallbacks' => '0'
67  ],
68  3 => [
69  'title' => 'Schweizer Deutsch',
70  'enabled' => true,
71  'languageId' => 3,
72  'base' => '/de-ch/',
73  'typo3Language' => 'ch',
74  'locale' => 'de_CH.UTF-8',
75  'iso-639-1' => 'ch',
76  'flag' => 'ch',
77  'fallbackType' => 'fallback',
78  'fallbacks' => '2,0'
79  ],
80  ];
81 
82  protected function ‪setUp(): void
83  {
84  parent::setUp();
85 
86  $this->‪importScenarioDataSet('Pages');
87  $this->‪setUpFrontendSite(1, $this->siteLanguageConfiguration);
88  $this->setUpFrontendRootPage(1, ['typo3/sysext/core/Tests/Functional/Fixtures/Frontend/JsonRenderer.typoscript']);
89  }
90 
106  {
107  return [
108  'default page / default parent' => [
109  '/default-parent/default-page',
110  [
111  'uid' => '13',
112  'title' => 'Default Page',
113  'sys_language_uid' => 0
114  ]
115  ],
116  'Dansk page / default parent' => [
117  '/default-parent/dansk-page',
118  [
119  'uid' => '13',
120  'title' => 'Dansk Page',
121  'sys_language_uid' => 1
122  ],
123  ],
124  'german page / german parent' => [
125  '/german-parent/german-page',
126  [
127  'uid' => '13',
128  'title' => 'German Page',
129  'sys_language_uid' => 2
130  ]
131  ],
132  'swiss page / german fallback parent' => [
133  '/german-parent/swiss-page',
134  [
135  'uid' => '13',
136  'title' => 'Swiss Page',
137  'sys_language_uid' => 3
138  ],
139  ],
140  ];
141  }
142 
149  public function ‪generateRespectsFallbackLanguageOfParentPageSlug(string $expected, array $page)
150  {
151  $slugHelper = GeneralUtility::makeInstance(
152  SlugHelper::class,
153  'pages',
154  'slug',
155  [
156  'generatorOptions' => [
157  'fields' => ['title'],
158  'prefixParentPageSlug' => true,
159  ],
160  ]
161  );
162 
163  self::assertEquals(
164  $expected,
165  $slugHelper->generate(
166  [
167  'title' => $page['title'],
168  'uid' => $page['uid'],
169  'sys_language_uid' => $page['sys_language_uid']
170  ],
171  (int)$page['uid']
172  )
173  );
174  }
175 }
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\Slug\SlugHelperTest
Definition: SlugHelperTest.php:28
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\Slug\SlugHelperTest\setUp
‪setUp()
Definition: SlugHelperTest.php:79
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\Slug\SlugHelperTest\$siteLanguageConfiguration
‪array $siteLanguageConfiguration
Definition: SlugHelperTest.php:40
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\Slug
Definition: SlugHelperTest.php:18
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\AbstractDataHandlerActionTestCase\setUpFrontendSite
‪setUpFrontendSite(int $pageId, array $additionalLanguages=[])
Definition: AbstractDataHandlerActionTestCase.php:143
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\AbstractDataHandlerActionTestCase
Definition: AbstractDataHandlerActionTestCase.php:37
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\Slug\SlugHelperTest\generateRespectsFallbackLanguageOfParentPageSlug
‪generateRespectsFallbackLanguageOfParentPageSlug(string $expected, array $page)
Definition: SlugHelperTest.php:146
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\Slug\SlugHelperTest\$scenarioDataSetDirectory
‪string $scenarioDataSetDirectory
Definition: SlugHelperTest.php:31
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\Slug\SlugHelperTest\generateRespectsFallbackLanguageOfParentPageSlugDataProvider
‪array generateRespectsFallbackLanguageOfParentPageSlugDataProvider()
Definition: SlugHelperTest.php:102
‪TYPO3\CMS\Core\DataHandling\SlugHelper
Definition: SlugHelper.php:42
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\Slug\SlugHelperTest\$assertCleanReferenceIndex
‪bool $assertCleanReferenceIndex
Definition: SlugHelperTest.php:35
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:46
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\AbstractDataHandlerActionTestCase\importScenarioDataSet
‪importScenarioDataSet($dataSetName)
Definition: AbstractDataHandlerActionTestCase.php:201