Skip to content

Commit

Permalink
[TASK] Cleanup DataMapperTest
Browse files Browse the repository at this point in the history
Replace evaled classes with actual fixtures

Releases: master
Resolves: #83488
Change-Id: Id9b5e3040a8fde8cf260423dfdd1448f6675f09f
Reviewed-on: https://review.typo3.org/55284
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Reiner Teubner <reiner.teubner@me.com>
Tested-by: Reiner Teubner <reiner.teubner@me.com>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
  • Loading branch information
alexanderschnitzler authored and lolli42 committed Jan 8, 2018
1 parent ded1644 commit 5e1ecd0
Show file tree
Hide file tree
Showing 4 changed files with 100 additions and 43 deletions.
@@ -1,4 +1,5 @@
<?php
declare(strict_types=1);
namespace TYPO3\CMS\Extbase\Tests\Unit\Persistence\Generic\Mapper;

/*
Expand Down Expand Up @@ -62,32 +63,8 @@ public function mapSingleRowReturnsObjectFromPersistenceSessionIfAvailable()
*/
public function thawPropertiesSetsPropertyValues()
{
$className = $this->getUniqueId('Class');
$classNameWithNS = __NAMESPACE__ . '\\' . $className;
eval('namespace ' . __NAMESPACE__ . '; class ' . $className . ' extends \\' . \TYPO3\CMS\Extbase\DomainObject\AbstractEntity::class . ' {
/**
* @var string
*/
public $firstProperty;
/**
* @var int
*/
public $secondProperty;
/**
* @var float
*/
public $thirdProperty;
/**
* @var bool
*/
public $fourthProperty;
}'
);
$object = new $classNameWithNS();
$className = Fixture\DummyEntity::class;
$object = new Fixture\DummyEntity();
$row = [
'uid' => '1234',
'firstProperty' => 'firstValue',
Expand All @@ -105,10 +82,10 @@ public function thawPropertiesSetsPropertyValues()
$dataMap = $this->getAccessibleMock(\TYPO3\CMS\Extbase\Persistence\Generic\Mapper\DataMap::class, ['dummy'], [$className, $className]);
$dataMap->_set('columnMaps', $columnMaps);
$dataMaps = [
$classNameWithNS => $dataMap
$className => $dataMap
];
/** @var AccessibleObjectInterface|\TYPO3\CMS\Extbase\Reflection\ClassSchema $classSchema */
$classSchema = new ClassSchema($classNameWithNS);
$classSchema = new ClassSchema($className);
$mockReflectionService = $this->getMockBuilder(\TYPO3\CMS\Extbase\Reflection\ReflectionService::class)
->setMethods(['getClassSchema'])
->getMock();
Expand Down Expand Up @@ -201,23 +178,11 @@ public function mapObjectToClassPropertyReturnsExistingObjectWithoutCallingFetch
->disableOriginalConstructor()
->getMock();

$className = $this->getUniqueId('Class1');
$classNameWithNS = __NAMESPACE__ . '\\' . $className;

$className2 = $this->getUniqueId('Class2');
$className2WithNS = __NAMESPACE__ . '\\' . $className2;
eval('namespace ' . __NAMESPACE__ . '; class ' . $className2 . ' extends \\' . \TYPO3\CMS\Extbase\DomainObject\AbstractEntity::class . ' { }');
eval('namespace ' . __NAMESPACE__ . '; class ' . $className . ' extends \\' . \TYPO3\CMS\Extbase\DomainObject\AbstractEntity::class . ' {
/**
* @var ' . $className2WithNS . '
*/
public $relationProperty;
}');
$object = new $classNameWithNS();
$child = new $className2WithNS();
$object = new Fixture\DummyParentEntity();
$child = new Fixture\DummyChildEntity();

/** @var \TYPO3\CMS\Extbase\Reflection\ClassSchema|AccessibleObjectInterface|\PHPUnit_Framework_MockObject_MockObject $classSchema1 */
$classSchema1 = new ClassSchema($classNameWithNS);
$classSchema1 = new ClassSchema(Fixture\DummyParentEntity::class);
$identifier = 1;

$session = new \TYPO3\CMS\Extbase\Persistence\Generic\Session();
Expand Down
@@ -0,0 +1,23 @@
<?php
declare(strict_types=1);
namespace TYPO3\CMS\Extbase\Tests\Unit\Persistence\Generic\Mapper\Fixture;

/*
* This file is part of the TYPO3 CMS project.
*
* It is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, either version 2
* of the License, or any later version.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* The TYPO3 project - inspiring people to share!
*/

/**
* Fixture
*/
class DummyChildEntity extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity
{
}
@@ -0,0 +1,42 @@
<?php
declare(strict_types=1);
namespace TYPO3\CMS\Extbase\Tests\Unit\Persistence\Generic\Mapper\Fixture;

/*
* This file is part of the TYPO3 CMS project.
*
* It is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, either version 2
* of the License, or any later version.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* The TYPO3 project - inspiring people to share!
*/

/**
* Fixture
*/
class DummyEntity extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity
{
/**
* @var string
*/
public $firstProperty;

/**
* @var int
*/
public $secondProperty;

/**
* @var float
*/
public $thirdProperty;

/**
* @var bool
*/
public $fourthProperty;
}
@@ -0,0 +1,27 @@
<?php
declare(strict_types=1);
namespace TYPO3\CMS\Extbase\Tests\Unit\Persistence\Generic\Mapper\Fixture;

/*
* This file is part of the TYPO3 CMS project.
*
* It is free software; you can redistribute it and/or modify it under
* the terms of the GNU General Public License, either version 2
* of the License, or any later version.
*
* For the full copyright and license information, please read the
* LICENSE.txt file that was distributed with this source code.
*
* The TYPO3 project - inspiring people to share!
*/

/**
* Fixture
*/
class DummyParentEntity extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity
{
/**
* @var \TYPO3\CMS\Extbase\Tests\Unit\Persistence\Generic\Mapper\Fixture\DummyChildEntity
*/
public $relationProperty;
}

0 comments on commit 5e1ecd0

Please sign in to comment.