‪TYPO3CMS  11.5
ClassesConfigurationFactoryTest.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\CMS\Core\Package\PackageManager;
27 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
28 
32 class ‪ClassesConfigurationFactoryTest extends UnitTestCase
33 {
37  public function ‪inheritPropertiesFromParentClasses(): void
38  {
39  $classesConfigurationFactory = new ‪ClassesConfigurationFactory(new ‪NullFrontend('extbase'), new PackageManager(new ‪DependencyOrderingService()), 'PersistenceClasses');
40 
41  $classes = [
42  A::class => [
43  'properties' => [
44  'propertiesFromA' => [
45  'fieldName' => 'field_name_a',
46  ],
47  ],
48  ],
49  B::class => [
50  'properties' => [
51  'propertiesFromA' => [
52  'fieldName' => 'field_name_z',
53  ],
54  'propertiesFromB' => [
55  'fieldName' => 'field_name_b',
56  ],
57  ],
58  ],
59  C::class => [
60  'properties' => [
61  'columnNameC' => [
62  'fieldName' => 'field_name_c',
63  ],
64  ],
65  ],
66  ];
67 
68  $reflectionMethod = (new \ReflectionClass($classesConfigurationFactory))
69  ->getMethod('inheritPropertiesFromParentClasses');
70  $reflectionMethod->setAccessible(true);
71  $classes = $reflectionMethod->invoke($classesConfigurationFactory, $classes);
72 
73  self::assertSame(
74  [
75  A::class => [
76  'properties' => [
77  'propertiesFromA' => [
78  'fieldName' => 'field_name_a',
79  ],
80  ],
81  ],
82  B::class => [
83  'properties' => [
84  'propertiesFromA' => [
85  'fieldName' => 'field_name_z',
86  ],
87  'propertiesFromB' => [
88  'fieldName' => 'field_name_b',
89  ],
90  ],
91  ],
92  C::class => [
93  'properties' => [
94  'propertiesFromA' => [
95  'fieldName' => 'field_name_z',
96  ],
97  'propertiesFromB' => [
98  'fieldName' => 'field_name_b',
99  ],
100  'columnNameC' => [
101  'fieldName' => 'field_name_c',
102  ],
103  ],
104  ],
105  ],
106  $classes
107  );
108  }
109 }
‪TYPO3\CMS\Extbase\Tests\Unit\Persistence\Fixture\Domain\Model\B
Definition: B.php:23
‪TYPO3\CMS\Core\Cache\Frontend\NullFrontend
Definition: NullFrontend.php:29
‪TYPO3\CMS\Extbase\Tests\Unit\Persistence\Fixture\Domain\Model\A
Definition: A.php:25
‪TYPO3\CMS\Core\Service\DependencyOrderingService
Definition: DependencyOrderingService.php:32
‪TYPO3\CMS\Extbase\Tests\Unit\Persistence
Definition: ClassesConfigurationFactoryTest.php:18
‪TYPO3\CMS\Extbase\Tests\Unit\Persistence\ClassesConfigurationFactoryTest\inheritPropertiesFromParentClasses
‪inheritPropertiesFromParentClasses()
Definition: ClassesConfigurationFactoryTest.php:37
‪TYPO3\CMS\Extbase\Tests\Unit\Persistence\ClassesConfigurationFactoryTest
Definition: ClassesConfigurationFactoryTest.php:33
‪TYPO3\CMS\Extbase\Persistence\ClassesConfigurationFactory
Definition: ClassesConfigurationFactory.php:27
‪TYPO3\CMS\Extbase\Tests\Unit\Persistence\Fixture\Domain\Model\C
Definition: C.php:23