2 namespace TYPO3\CMS\Extbase\Tests\Unit\Property
;
5 * This script belongs to the Extbase framework. *
7 * It is free software; you can redistribute it and/or modify it under *
8 * the terms of the GNU Lesser General Public License as published by the *
9 * Free Software Foundation, either version 3 of the License, or (at your *
10 * option) any later version. *
12 * This script is distributed in the hope that it will be useful, but *
13 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- *
14 * TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser *
15 * General Public License for more details. *
17 * You should have received a copy of the GNU Lesser General Public *
18 * License along with the script. *
19 * If not, see http://www.gnu.org/licenses/lgpl.html *
21 * The TYPO3 project - inspiring people to share! *
24 require_once(__DIR__
. '/../../Fixture/TxClassWithGettersAndSetters.php');
27 * Testcase for the Property Mapper
29 * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
30 * @covers \TYPO3\CMS\Extbase\Property\Mapper
32 class MapperTest
extends \TYPO3\CMS\Extbase\Tests\Unit\BaseTestCase
{
35 * @var \TYPO3\CMS\Extbase\Property\Mapper
40 * Sets up this test case
43 * @author Sebastian Kurfürst <sebastian@typo3.org>
45 public function setUp() {
46 /** @var \TYPO3\CMS\Extbase\Object\ObjectManager $objectManager */
47 $objectManager = new \TYPO3\CMS\Extbase\
Object\
ObjectManager();
49 /** @var \TYPO3\CMS\Extbase\Persistence\Generic\PersistenceManager $persistenceManager */
50 $persistenceManager = new \TYPO3\CMS\Extbase\Persistence\Generic\
PersistenceManager();
52 /** @var \TYPO3\CMS\Extbase\Persistence\Generic\QueryFactory $queryFactory */
53 $queryFactory = new \TYPO3\CMS\Extbase\Persistence\Generic\
QueryFactory();
55 /** @var \TYPO3\CMS\Extbase\Reflection\ReflectionService $reflectionService */
56 $reflectionService = new \TYPO3\CMS\Extbase\Reflection\
ReflectionService();
57 $reflectionService->injectObjectManager($objectManager);
59 /** @var \TYPO3\CMS\Extbase\Validation\ValidatorResolver $validatorResolver */
60 $validatorResolver = new \TYPO3\CMS\Extbase\Validation\
ValidatorResolver();
62 $this->fixture
= new \TYPO3\CMS\Extbase\Property\
Mapper();
63 $this->fixture
->injectObjectManager($objectManager);
64 $this->fixture
->injectPersistenceManager($persistenceManager);
65 $this->fixture
->injectQueryFactory($queryFactory);
66 $this->fixture
->injectReflectionService($reflectionService);
67 $this->fixture
->injectValidatorResolver($validatorResolver);
70 public function tearDown() {
71 unset($this->fixture
);
77 public function mapReturnsObjectForNamespaceClasses() {
83 $expectedObject = new \TYPO3\CMS\Extbase\Tests\Fixture\
ClassWithGettersAndSetters();
84 $expectedObject->setProperty1($source['property1']);
85 $expectedObject->setProperty2($source['property2']);
87 $this->assertEquals($expectedObject, $this->fixture
->map(array('property1', 'property2'), $source, 'TYPO3\\CMS\\Extbase\\Tests\\Fixture\\ClassWithGettersAndSetters'));
93 public function mapReturnsObjectForOldTxClasses() {
99 $expectedObject = new \
Tx_Extbase_Tests_Fixture_TxClassWithGettersAndSetters();
100 $expectedObject->setProperty1($source['property1']);
101 $expectedObject->setProperty2($source['property2']);
103 $this->assertEquals($expectedObject, $this->fixture
->map(array('property1', 'property2'), $source, 'Tx_Extbase_Tests_Fixture_TxClassWithGettersAndSetters'));