‪TYPO3CMS  ‪main
TcaFolderTest.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 
20 use PHPUnit\Framework\Attributes\Test;
25 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
26 
27 final class ‪TcaFolderTest extends UnitTestCase
28 {
29  protected bool ‪$resetSingletonInstances = true;
30 
31  #[Test]
33  {
34  $input = [
35  'databaseRow' => [
36  'aField' => 'aValue',
37  ],
38  'processedTca' => [
39  'columns' => [
40  'aField' => [
41  'config' => [
42  'type' => 'foo',
43  ],
44  ],
45  ],
46  ],
47  ];
48  $expected = $input;
49  self::assertSame($expected, (new ‪TcaFolder())->addData($input));
50  }
51 
52  #[Test]
53  public function ‪addDataSetsFolderData(): void
54  {
55  $input = [
56  'databaseRow' => [
57  'aField' => '1:/aFolder/anotherFolder/',
58  ],
59  'processedTca' => [
60  'columns' => [
61  'aField' => [
62  'config' => [
63  'type' => 'folder',
64  'maxitems' => 99999,
65  ],
66  ],
67  ],
68  ],
69  ];
70 
71  $folderMock = $this->createMock(Folder::class);
72 
73  $resourceFactoryMock = $this->createMock(ResourceFactory::class);
74  GeneralUtility::setSingletonInstance(ResourceFactory::class, $resourceFactoryMock);
75  $resourceFactoryMock->expects(self::atLeastOnce())->method('retrieveFileOrFolderObject')
76  ->with('1:/aFolder/anotherFolder/')->willReturn($folderMock);
77 
78  $expected = $input;
79  $expected['databaseRow']['aField'] = [
80  [
81  'folder' => '1:/aFolder/anotherFolder/',
82  ],
83  ];
84  self::assertSame($expected, (new ‪TcaFolder())->addData($input));
85  }
86 }
‪TYPO3\CMS\Core\Resource\Folder
Definition: Folder.php:38
‪TYPO3\CMS\Core\Resource\ResourceFactory
Definition: ResourceFactory.php:42
‪TYPO3\CMS\Backend\Tests\Unit\Form\FormDataProvider\TcaFolderTest\addDataReturnsFieldUnchangedIfFieldIsNotTypeFolder
‪addDataReturnsFieldUnchangedIfFieldIsNotTypeFolder()
Definition: TcaFolderTest.php:32
‪TYPO3\CMS\Backend\Form\FormDataProvider\TcaFolder
Definition: TcaFolder.php:31
‪TYPO3\CMS\Backend\Tests\Unit\Form\FormDataProvider\TcaFolderTest
Definition: TcaFolderTest.php:28
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:52
‪TYPO3\CMS\Backend\Tests\Unit\Form\FormDataProvider\TcaFolderTest\$resetSingletonInstances
‪bool $resetSingletonInstances
Definition: TcaFolderTest.php:29
‪TYPO3\CMS\Backend\Tests\Unit\Form\FormDataProvider\TcaFolderTest\addDataSetsFolderData
‪addDataSetsFolderData()
Definition: TcaFolderTest.php:53
‪TYPO3\CMS\Backend\Tests\Unit\Form\FormDataProvider
Definition: DatabaseDefaultLanguagePageRowTest.php:18