[TASK] Removes eval() in core tree data provider factory unit tests
[Packages/TYPO3.CMS.git] / typo3 / sysext / core / Tests / Unit / Tree / TableConfiguration / TreeDataProviderFactoryTest.php
index 26a57a6..60fff05 100644 (file)
@@ -13,6 +13,7 @@ namespace TYPO3\CMS\Core\Tests\Unit\Tree\TableConfiguration;
  *
  * The TYPO3 project - inspiring people to share!
  */
+use TYPO3\CMS\Core\Tests\Unit\Tree\TableConfiguration\Fixtures\TreeDataProviderFixture;
 
 /**
  * Testcase for TYPO3\CMS\Core\Tree\TableConfiguration\TreeDataProviderFactory
@@ -22,10 +23,10 @@ class TreeDataProviderFactoryTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
        /**
         * @var \TYPO3\CMS\Core\Tree\TableConfiguration\TreeDataProviderFactory
         */
-       protected $fixture;
+       protected $subject;
 
-       public function setUp() {
-               $this->fixture = new \TYPO3\CMS\Core\Tree\TableConfiguration\TreeDataProviderFactory();
+       protected function setUp() {
+               $this->subject = new \TYPO3\CMS\Core\Tree\TableConfiguration\TreeDataProviderFactory();
                $GLOBALS['TCA'] = array();
                $GLOBALS['TCA']['foo'] = array();
                $GLOBALS['TCA']['foo']['ctrl'] = array();
@@ -75,21 +76,17 @@ class TreeDataProviderFactoryTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
         * @expectedException \InvalidArgumentException
         */
        public function factoryThrowsExceptionIfInvalidConfigurationIsGiven(array $tcaConfiguration) {
-               $this->fixture->getDataProvider($tcaConfiguration, 'foo', 'bar', array('uid' => 1));
+               $this->subject->getDataProvider($tcaConfiguration, 'foo', 'bar', array('uid' => 1));
        }
 
        /**
         * @test
         */
        public function configuredDataProviderClassIsInstantiated() {
-               $dataProviderMockClassName = $this->getUniqueId('tx_coretest_tree_data_provider');
-               eval('class ' . $dataProviderMockClassName . ' {
-                       function __construct($configuration) {
-                       }
-               }');
+               $dataProviderMockClassName = TreeDataProviderFixture::class;
 
                $tcaConfiguration = array('treeConfig' => array('dataProvider' => $dataProviderMockClassName), 'internal_type' => 'foo');
-               $dataProvider = $this->fixture->getDataProvider($tcaConfiguration, 'foo', 'bar', array('uid' => 1));
+               $dataProvider = $this->subject->getDataProvider($tcaConfiguration, 'foo', 'bar', array('uid' => 1));
 
                $this->assertInstanceOf($dataProviderMockClassName, $dataProvider);
        }
@@ -107,7 +104,7 @@ class TreeDataProviderFactoryTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
                        }
                }';
                eval($classCode);
-               $dataProvider = $this->fixture->getDataProvider($tcaConfiguration, 'foo', 'bar', array('uid' => 1));
+               $dataProvider = $this->subject->getDataProvider($tcaConfiguration, 'foo', 'bar', array('uid' => 1));
 
                $this->assertInstanceOf($dataProviderMockClassName, $dataProvider);
        }