‪TYPO3CMS  ‪main
InitializeProcessedTcaTest.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;
22 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
23 
24 final class ‪InitializeProcessedTcaTest extends UnitTestCase
25 {
27 
28  protected function ‪setUp(): void
29  {
30  parent::setUp();
31  $this->subject = new ‪InitializeProcessedTca();
32  }
33 
34  #[Test]
36  {
37  $input = [
38  'tableName' => 'aTable',
39  ];
40  $expected = [
41  'columns' => [],
42  ];
43  ‪$GLOBALS['TCA'][$input['tableName']] = $expected;
44  $result = $this->subject->addData($input);
45  self::assertEquals($expected, $result['processedTca']);
46  }
47 
48  #[Test]
49  public function ‪addDataKeepsGivenProcessedTca(): void
50  {
51  $input = [
52  'tableName' => 'aTable',
53  'processedTca' => [
54  'columns' => [
55  'afield' => [],
56  ],
57  ],
58  ];
59  $expected = $input;
60  self::assertEquals($expected, $this->subject->addData($input));
61  }
62 
63  #[Test]
65  {
66  $input = [
67  'tableName' => 'aTable',
68  ];
69 
70  $this->expectException(\UnexpectedValueException::class);
71  $this->expectExceptionCode(1437914223);
72 
73  $this->subject->addData($input);
74  }
75 
76  #[Test]
78  {
79  $input = [
80  'tableName' => 'aTable',
81  ];
82  ‪$GLOBALS['TCA'][$input['tableName']] = 'foo';
83  $this->expectException(\UnexpectedValueException::class);
84  $this->expectExceptionCode(1437914223);
85 
86  $this->subject->addData($input);
87  }
88 }
‪TYPO3\CMS\Backend\Form\FormDataProvider\InitializeProcessedTca
Definition: InitializeProcessedTca.php:24
‪TYPO3\CMS\Backend\Tests\Unit\Form\FormDataProvider\InitializeProcessedTcaTest
Definition: InitializeProcessedTcaTest.php:25
‪TYPO3\CMS\Backend\Tests\Unit\Form\FormDataProvider\InitializeProcessedTcaTest\$subject
‪InitializeProcessedTca $subject
Definition: InitializeProcessedTcaTest.php:26
‪TYPO3\CMS\Backend\Tests\Unit\Form\FormDataProvider\InitializeProcessedTcaTest\addDataSetsTableTcaFromGlobalsInResult
‪addDataSetsTableTcaFromGlobalsInResult()
Definition: InitializeProcessedTcaTest.php:35
‪TYPO3\CMS\Backend\Tests\Unit\Form\FormDataProvider\InitializeProcessedTcaTest\addDataKeepsGivenProcessedTca
‪addDataKeepsGivenProcessedTca()
Definition: InitializeProcessedTcaTest.php:49
‪TYPO3\CMS\Backend\Tests\Unit\Form\FormDataProvider\InitializeProcessedTcaTest\addDataThrowsExceptionIfGlobalTableTcaIsNotAnArray
‪addDataThrowsExceptionIfGlobalTableTcaIsNotAnArray()
Definition: InitializeProcessedTcaTest.php:77
‪$GLOBALS
‪$GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['adminpanel']['modules']
Definition: ext_localconf.php:25
‪TYPO3\CMS\Backend\Tests\Unit\Form\FormDataProvider\InitializeProcessedTcaTest\addDataThrowsExceptionIfGlobalTableTcaIsNotSet
‪addDataThrowsExceptionIfGlobalTableTcaIsNotSet()
Definition: InitializeProcessedTcaTest.php:64
‪TYPO3\CMS\Backend\Tests\Unit\Form\FormDataProvider\InitializeProcessedTcaTest\setUp
‪setUp()
Definition: InitializeProcessedTcaTest.php:28
‪TYPO3\CMS\Backend\Tests\Unit\Form\FormDataProvider
Definition: DatabaseDefaultLanguagePageRowTest.php:18