‪TYPO3CMS  11.5
ObjectStorageConverterTest.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 
24 use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase;
25 
26 class ‪ObjectStorageConverterTest extends FunctionalTestCase
27 {
31  protected ‪$initializeDatabase = false;
32 
36  public function ‪convertReturnsObjectStorage(): void
37  {
38  $propertyMapperConfiguration = new ‪PropertyMappingConfiguration();
39  $propertyMapperConfiguration->allowAllProperties();
40  $propertyMapperConfiguration->forProperty('foo')->allowAllProperties();
41 
42  $propertyMapper = $this->get(PropertyMapper::class);
43 
44  $objectStorage = $propertyMapper->convert(
45  [
46  'foo' => ['color' => 'black'],
47  ],
48  ObjectStorage::class . '<' . Cat::class . '>',
49  $propertyMapperConfiguration
50  );
51 
52  self::assertInstanceOf(ObjectStorage::class, $objectStorage);
53  self::assertCount(1, $objectStorage);
54 
55  $cat = $objectStorage->current();
56  self::assertInstanceOf(Cat::class, $cat);
57  self::assertSame('black', $cat->getColor());
58  }
59 
64  {
65  $propertyMapperConfiguration = new ‪PropertyMappingConfiguration();
66  $propertyMapperConfiguration->forProperty('foo')->allowAllProperties();
67 
68  $propertyMapper = $this->get(PropertyMapper::class);
69 
70  $objectStorage = $propertyMapper->convert(
71  'foo',
72  ObjectStorage::class . '<' . Cat::class . '>',
73  $propertyMapperConfiguration
74  );
75 
76  self::assertInstanceOf(ObjectStorage::class, $objectStorage);
77  self::assertCount(0, $objectStorage);
78  }
79 }
‪TYPO3\CMS\Extbase\Tests\Functional\Property\TypeConverter\ObjectStorageConverterTest\convertReturnsObjectStorage
‪convertReturnsObjectStorage()
Definition: ObjectStorageConverterTest.php:35
‪TYPO3\CMS\Extbase\Tests\Functional\Property\Fixtures\Cat
Definition: Cat.php:21
‪TYPO3\CMS\Extbase\Tests\Functional\Property\TypeConverter\ObjectStorageConverterTest
Definition: ObjectStorageConverterTest.php:27
‪TYPO3\CMS\Extbase\Tests\Functional\Property\TypeConverter\ObjectStorageConverterTest\$initializeDatabase
‪bool $initializeDatabase
Definition: ObjectStorageConverterTest.php:30
‪TYPO3\CMS\Extbase\Persistence\ObjectStorage
Definition: ObjectStorage.php:32
‪TYPO3\CMS\Extbase\Tests\Functional\Property\TypeConverter
Definition: ArrayConverterTest.php:18
‪TYPO3\CMS\Extbase\Property\PropertyMappingConfiguration
Definition: PropertyMappingConfiguration.php:22
‪TYPO3\CMS\Extbase\Property\PropertyMapper
Definition: PropertyMapper.php:39
‪TYPO3\CMS\Extbase\Tests\Functional\Property\TypeConverter\ObjectStorageConverterTest\getSourceChildPropertiesToBeConvertedReturnsEmptyArrayIfSourceIsAString
‪getSourceChildPropertiesToBeConvertedReturnsEmptyArrayIfSourceIsAString()
Definition: ObjectStorageConverterTest.php:62