‪TYPO3CMS  10.4
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 {
32  {
33  $propertyMapperConfiguration = new ‪PropertyMappingConfiguration();
34  $propertyMapperConfiguration->allowAllProperties();
35  $propertyMapperConfiguration->forProperty('foo')->allowAllProperties();
36 
37  $propertyMapper = $this->getContainer()->get(PropertyMapper::class);
38 
39  $objectStorage = $propertyMapper->convert(
40  [
41  'foo' => ['color' => 'black']
42  ],
43  ObjectStorage::class . '<' . Cat::class . '>',
44  $propertyMapperConfiguration
45  );
46 
47  self::assertInstanceOf(ObjectStorage::class, $objectStorage);
48  self::assertCount(1, $objectStorage);
49 
50  $cat = $objectStorage->current();
51  self::assertInstanceOf(Cat::class, $cat);
52  self::assertSame('black', $cat->getColor());
53  }
54 
59  {
60  $propertyMapperConfiguration = new ‪PropertyMappingConfiguration();
61  $propertyMapperConfiguration->forProperty('foo')->allowAllProperties();
62 
63  $propertyMapper = $this->getContainer()->get(PropertyMapper::class);
64 
65  $objectStorage = $propertyMapper->convert(
66  'foo',
67  ObjectStorage::class . '<' . Cat::class . '>',
68  $propertyMapperConfiguration
69  );
70 
71  self::assertInstanceOf(ObjectStorage::class, $objectStorage);
72  self::assertCount(0, $objectStorage);
73  }
74 }
‪TYPO3\CMS\Extbase\Tests\Functional\Property\TypeConverter\ObjectStorageConverterTest\convertReturnsObjectStorage
‪convertReturnsObjectStorage()
Definition: ObjectStorageConverterTest.php:31
‪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\Persistence\ObjectStorage
Definition: ObjectStorage.php:28
‪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:37
‪TYPO3\CMS\Extbase\Tests\Functional\Property\TypeConverter\ObjectStorageConverterTest\getSourceChildPropertiesToBeConvertedReturnsEmptyArrayIfSourceIsAString
‪getSourceChildPropertiesToBeConvertedReturnsEmptyArrayIfSourceIsAString()
Definition: ObjectStorageConverterTest.php:58