‪TYPO3CMS  11.5
SlugHelperUniqueTest.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
6 
7 /*
8  * This file is part of the TYPO3 CMS project.
9  *
10  * It is free software; you can redistribute it and/or modify it under
11  * the terms of the GNU General Public License, either version 2
12  * of the License, or any later version.
13  *
14  * For the full copyright and license information, please read the
15  * LICENSE.txt file that was distributed with this source code.
16  *
17  * The TYPO3 project - inspiring people to share!
18  */
19 
24 
26 {
28  'typo3/sysext/core/Tests/Functional/Fixtures/Extensions/irre_tutorial',
29  ];
30 
31  protected function ‪setUp(): void
32  {
33  parent::setUp();
34 
35  $this->importCSVDataSet(__DIR__ . '/DataSet/PagesForSlugsUnique.csv');
36  $this->‪setUpFrontendSite(1);
37  $this->setUpFrontendRootPage(1, ['typo3/sysext/core/Tests/Functional/Fixtures/Frontend/JsonRenderer.typoscript']);
38  }
39 
44  {
45  $subject = GeneralUtility::makeInstance(
46  SlugHelper::class,
47  'pages',
48  'slug',
49  [
50  'generatorOptions' => [
51  'fields' => ['title'],
52  'prefixParentPageSlug' => true,
53  ],
54  ]
55  );
56 
57  $state = ‪RecordStateFactory::forName('pages')->fromArray(['uid' => 'NEW102', 'pid' => 1]);
58  $overflowSlug = $subject->buildSlugForUniqueInSite('/unique-slug', $state);
59  $parts = explode('-', $overflowSlug);
60  if (count($parts) !== 3) {
61  self::fail('No suffix to the slug was created');
62  }
63  $variablePartOfSlug = end($parts);
64  self::assertSame(32, strlen($variablePartOfSlug));
65  }
66 
71  {
72  $subject = GeneralUtility::makeInstance(
73  SlugHelper::class,
74  'pages',
75  'slug',
76  [
77  'generatorOptions' => [
78  'fields' => ['title'],
79  'prefixParentPageSlug' => true,
80  ],
81  ]
82  );
83  $state = ‪RecordStateFactory::forName('pages')->fromArray(['uid' => 'NEW102', 'pid' => 1]);
84  $overflowSlug = $subject->buildSlugForUniqueInPid('/unique-slug', $state);
85  $parts = explode('-', $overflowSlug);
86  if (count($parts) !== 3) {
87  self::fail('No suffix to the slug was created');
88  }
89  $variablePartOfSlug = end($parts);
90  self::assertSame(32, strlen($variablePartOfSlug));
91  }
92 
97  {
98  $subject = GeneralUtility::makeInstance(
99  SlugHelper::class,
100  'pages',
101  'slug',
102  [
103  'generatorOptions' => [
104  'fields' => ['title'],
105  'prefixParentPageSlug' => true,
106  ],
107  ]
108  );
109 
110  $state = ‪RecordStateFactory::forName('pages')->fromArray(['uid' => 'NEW102', 'pid' => 1]);
111  $overflowSlug = $subject->buildSlugForUniqueInTable('/unique-slug', $state);
112  $parts = explode('-', $overflowSlug);
113  if (count($parts) !== 3) {
114  self::fail('No suffix to the slug was created');
115  }
116  $variablePartOfSlug = end($parts);
117  self::assertSame(32, strlen($variablePartOfSlug));
118  }
119 }
‪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:127
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\Slug\SlugHelperUniqueTest\$testExtensionsToLoad
‪$testExtensionsToLoad
Definition: SlugHelperUniqueTest.php:27
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\AbstractDataHandlerActionTestCase
Definition: AbstractDataHandlerActionTestCase.php:41
‪TYPO3\CMS\Core\DataHandling\Model\RecordStateFactory
Definition: RecordStateFactory.php:26
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\Slug\SlugHelperUniqueTest
Definition: SlugHelperUniqueTest.php:26
‪TYPO3\CMS\Core\DataHandling\SlugHelper
Definition: SlugHelper.php:43
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\Slug\SlugHelperUniqueTest\buildSlugForUniqueInSiteRespectsMaxRetryOverflow
‪buildSlugForUniqueInSiteRespectsMaxRetryOverflow()
Definition: SlugHelperUniqueTest.php:43
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\Slug\SlugHelperUniqueTest\buildSlugForUniqueInTableRespectsMaxRetryOverflow
‪buildSlugForUniqueInTableRespectsMaxRetryOverflow()
Definition: SlugHelperUniqueTest.php:96
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\Slug\SlugHelperUniqueTest\buildSlugForUniqueInPidRespectsMaxRetryOverflow
‪buildSlugForUniqueInPidRespectsMaxRetryOverflow()
Definition: SlugHelperUniqueTest.php:70
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\Slug\SlugHelperUniqueTest\setUp
‪setUp()
Definition: SlugHelperUniqueTest.php:31
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:50
‪TYPO3\CMS\Core\DataHandling\Model\RecordStateFactory\forName
‪static static forName(string $name)
Definition: RecordStateFactory.php:35