‪TYPO3CMS  10.4
ClassesConfigurationTest.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 
21 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
22 
26 class ‪ClassesConfigurationTest extends UnitTestCase
27 {
31  public function ‪hasClassReturnsTrue(): void
32  {
33  $className = 'ClassName';
34  $classesConfiguration = new ‪ClassesConfiguration([$className => []]);
35  self::assertTrue($classesConfiguration->hasClass($className));
36  }
37 
41  public function ‪hasClassReturnsFalse(): void
42  {
43  $className = 'ClassName';
44  $classesConfiguration = new ‪ClassesConfiguration([]);
45  self::assertFalse($classesConfiguration->hasClass($className));
46  }
47 
51  public function ‪getConfigurationForReturnsArray(): void
52  {
53  $configuration = [
54  'ClassName' => [
55  'tableName' => 'table'
56  ]
57  ];
58  $classesConfiguration = new ‪ClassesConfiguration($configuration);
59  self::assertSame(
60  $configuration['ClassName'],
61  $classesConfiguration->getConfigurationFor('ClassName')
62  );
63  }
64 
68  public function ‪getConfigurationForReturnsNull(): void
69  {
70  $classesConfiguration = new ‪ClassesConfiguration([]);
71  self::assertNull($classesConfiguration->getConfigurationFor('ClassName'));
72  }
73 
78  {
79  return [
80  [
81  [
82  'B',
83  'C',
84  'A',
85  ],
86  [
87  'A' => [
88  'subclasses' => [
89  'B',
90  ]
91  ],
92  'B' => [
93  'subclasses' => [
94  'C'
95  ]
96  ],
97  'C' => [
98  'subclasses' => [
99  'A'
100  ]
101  ],
102  ],
103  'A'
104  ],
105  [
106  [
107  'A',
108  'B',
109  'C',
110  ],
111  [
112  'A' => [
113  'subclasses' => [
114  'B',
115  ]
116  ],
117  'B' => [
118  'subclasses' => [
119  'C'
120  ]
121  ],
122  'C' => [
123  'subclasses' => [
124  'A'
125  ]
126  ],
127  ],
128  'C'
129  ],
130  [
131  [
132  'C',
133  'A',
134  'B',
135  ],
136  [
137  'A' => [
138  'subclasses' => [
139  'C',
140  ]
141  ],
142  'B' => [
143  'subclasses' => [
144  'C',
145  'B',
146  ]
147  ],
148  'C' => [
149  'subclasses' => [
150  'A',
151  'B',
152  ]
153  ],
154  ],
155  'B'
156  ],
157  ];
158  }
159 
167  public function ‪getSubclasses(array $expected, array $configuration, string $className): void
168  {
169  $classesConfiguration = new ‪ClassesConfiguration($configuration);
170  self::assertSame(
171  $expected,
172  $classesConfiguration->getSubClasses($className)
173  );
174  }
175 }
‪TYPO3\CMS\Extbase\Tests\Unit\Persistence\ClassesConfigurationTest
Definition: ClassesConfigurationTest.php:27
‪TYPO3\CMS\Extbase\Tests\Unit\Persistence\ClassesConfigurationTest\getSubclasses
‪getSubclasses(array $expected, array $configuration, string $className)
Definition: ClassesConfigurationTest.php:167
‪TYPO3\CMS\Extbase\Tests\Unit\Persistence\ClassesConfigurationTest\getConfigurationForReturnsArray
‪getConfigurationForReturnsArray()
Definition: ClassesConfigurationTest.php:51
‪TYPO3\CMS\Extbase\Tests\Unit\Persistence\ClassesConfigurationTest\hasClassReturnsFalse
‪hasClassReturnsFalse()
Definition: ClassesConfigurationTest.php:41
‪TYPO3\CMS\Extbase\Tests\Unit\Persistence\ClassesConfigurationTest\hasClassReturnsTrue
‪hasClassReturnsTrue()
Definition: ClassesConfigurationTest.php:31
‪TYPO3\CMS\Extbase\Persistence\ClassesConfiguration
Definition: ClassesConfiguration.php:24
‪TYPO3\CMS\Extbase\Tests\Unit\Persistence
Definition: ClassesConfigurationFactoryTest.php:18
‪TYPO3\CMS\Extbase\Tests\Unit\Persistence\ClassesConfigurationTest\getConfigurationForReturnsNull
‪getConfigurationForReturnsNull()
Definition: ClassesConfigurationTest.php:68
‪TYPO3\CMS\Extbase\Tests\Unit\Persistence\ClassesConfigurationTest\resolveSubclassesRecursiveDataProvider
‪array resolveSubclassesRecursiveDataProvider()
Definition: ClassesConfigurationTest.php:77