‪TYPO3CMS  10.4
SlugUniqueTest.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 {
29  protected function ‪setUp(): void
30  {
31  parent::setUp();
32  $this->‪setUpFrontendSite(1);
33  }
34 
39  public function ‪getEvalSettingDataProvider(): array
40  {
41  return [
42  'uniqueInSite' => ['uniqueInSite'],
43  'unique' => ['unique'],
44  'uniqueInPid' => ['uniqueInPid'],
45  ];
46  }
47 
53  public function ‪differentUniqueEvalSettingsDeDuplicateSlug(string $uniqueSetting): void
54  {
55  $this->importCSVDataSet(__DIR__ . '/DataSet/TestSlugUniqueBase.csv');
56  ‪$GLOBALS['TCA']['pages']['columns']['slug']['config']['eval'] = $uniqueSetting;
57  $dataHandler = GeneralUtility::makeInstance(DataHandler::class);
58  $dataHandler->enableLogging = false;
59  $dataHandler->start(
60  [
61  'pages' => [
62  3 => [
63  'title' => 'Page One',
64  'slug' => 'page-one',
65  ],
66  ],
67  ],
68  []
69  );
70  $dataHandler->process_datamap();
71  $this->assertCSVDataSet('typo3/sysext/core/Tests/Functional/DataHandling/DataHandler/DataSet/TestSlugUniqueResult.csv');
72  }
73 
79  public function ‪currentRecordIsExcludedWhenDeDuplicateSlug(string $uniqueSetting): void
80  {
81  $this->importCSVDataSet(__DIR__ . '/DataSet/TestSlugUniqueWithDeduplicatedSlugBase.csv');
82  ‪$GLOBALS['TCA']['pages']['columns']['slug']['config']['eval'] = $uniqueSetting;
83  $dataHandler = GeneralUtility::makeInstance(DataHandler::class);
84  $dataHandler->enableLogging = false;
85  $dataHandler->start(
86  [
87  'pages' => [
88  3 => [
89  'slug' => 'page-one-1',
90  ],
91  ],
92  ],
93  []
94  );
95  $dataHandler->process_datamap();
96 
97  $this->assertCSVDataSet('typo3/sysext/core/Tests/Functional/DataHandling/DataHandler/DataSet/TestSlugUniqueResult.csv');
98  }
99 
105  public function ‪differentUniqueEvalSettingsDeDuplicateSlugWhenCreatingNewRecords(string $uniqueSetting): void
106  {
107  $this->importCSVDataSet(__DIR__ . '/DataSet/TestSlugUniqueBase.csv');
108  ‪$GLOBALS['TCA']['pages']['columns']['slug']['config']['eval'] = $uniqueSetting;
109  $dataHandler = GeneralUtility::makeInstance(DataHandler::class);
110  $dataHandler->enableLogging = false;
111  $dataHandler->start(
112  [
113  'pages' => [
114  'NEW-1' => [
115  'pid' => 1,
116  'title' => 'Page Two',
117  'slug' => '',
118  ],
119  ],
120  ],
121  []
122  );
123  $dataHandler->process_datamap();
124 
125  $this->assertCSVDataSet('typo3/sysext/core/Tests/Functional/DataHandling/DataHandler/DataSet/TestSlugUniqueNewRecordResult.csv');
126  }
127 }
‪TYPO3\CMS\Core\DataHandling\DataHandler
Definition: DataHandler.php:84
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\DataHandler\SlugUniqueTest\differentUniqueEvalSettingsDeDuplicateSlugWhenCreatingNewRecords
‪differentUniqueEvalSettingsDeDuplicateSlugWhenCreatingNewRecords(string $uniqueSetting)
Definition: SlugUniqueTest.php:105
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\DataHandler
Definition: DefaultValuesTest.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\DataHandler\SlugUniqueTest\setUp
‪setUp()
Definition: SlugUniqueTest.php:29
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\DataHandler\SlugUniqueTest\differentUniqueEvalSettingsDeDuplicateSlug
‪differentUniqueEvalSettingsDeDuplicateSlug(string $uniqueSetting)
Definition: SlugUniqueTest.php:53
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\AbstractDataHandlerActionTestCase
Definition: AbstractDataHandlerActionTestCase.php:37
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\DataHandler\SlugUniqueTest
Definition: SlugUniqueTest.php:28
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\DataHandler\SlugUniqueTest\getEvalSettingDataProvider
‪array getEvalSettingDataProvider()
Definition: SlugUniqueTest.php:39
‪TYPO3\CMS\Core\Tests\Functional\DataHandling\DataHandler\SlugUniqueTest\currentRecordIsExcludedWhenDeDuplicateSlug
‪currentRecordIsExcludedWhenDeDuplicateSlug(string $uniqueSetting)
Definition: SlugUniqueTest.php:79
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:5
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:46