TYPO3 CMS  TYPO3_8-7
AbstractRecycleTestCase.php
Go to the documentation of this file.
1 <?php
3 
4 /*
5  * This file is part of the TYPO3 CMS project.
6  *
7  * It is free software; you can redistribute it and/or modify it under
8  * the terms of the GNU General Public License, either version 2
9  * of the License, or any later version.
10  *
11  * For the full copyright and license information, please read the
12  * LICENSE.txt file that was distributed with this source code.
13  *
14  * The TYPO3 project - inspiring people to share!
15  */
16 
18 
22 abstract class AbstractRecycleTestCase extends \TYPO3\TestingFramework\Core\Functional\FunctionalTestCase
23 {
27  protected $coreExtensionsToLoad = ['recycler'];
28 
34  protected $backendUserFixture = 'typo3/sysext/recycler/Tests/Functional/Fixtures/Database/be_users.xml';
35 
40  protected function setUp()
41  {
42  parent::setUp();
43  $this->importDataSet(__DIR__ . '/../Fixtures/Database/be_groups.xml');
44  \TYPO3\CMS\Core\Core\Bootstrap::getInstance()->initializeLanguageObject();
45  }
46 
54  protected function getDeletedPages($pageUid, $depth = 0)
55  {
57  $deletedRecords = GeneralUtility::makeInstance(\TYPO3\CMS\Recycler\Domain\Model\DeletedRecords::class);
58  $deletedRecords->loadData($pageUid, 'pages', $depth);
59  return $deletedRecords->getDeletedRows();
60  }
61 
68  protected function getDeletedContent($contentUid)
69  {
71  $deletedRecords = GeneralUtility::makeInstance(\TYPO3\CMS\Recycler\Domain\Model\DeletedRecords::class);
72  $deletedRecords->loadData($contentUid, 'tt_content', 0);
73  return $deletedRecords->getDeletedRows();
74  }
75 
83  protected function loadDataSet($path)
84  {
85  if (!is_file($path)) {
86  throw new \Exception(
87  'Fixture file ' . $path . ' not found',
88  1476109709
89  );
90  }
91 
92  $data = [];
93  $fileContent = file_get_contents($path);
94  // Disables the functionality to allow external entities to be loaded when parsing the XML, must be kept
95  $previousValueOfEntityLoader = libxml_disable_entity_loader(true);
96  $xml = simplexml_load_string($fileContent);
97  libxml_disable_entity_loader($previousValueOfEntityLoader);
98 
100  foreach ($xml->children() as $table) {
101  $record = [];
102 
104  foreach ($table->children() as $column) {
105  $columnName = $column->getName();
106  $columnValue = null;
107 
108  if (isset($column['ref'])) {
109  $columnValue = explode('#', $column['ref']);
110  } elseif (isset($column['is-NULL']) && ($column['is-NULL'] === 'yes')) {
111  $columnValue = null;
112  } else {
113  $columnValue = (string)$table->$columnName;
114  }
115 
116  $record[$columnName] = $columnValue;
117  }
118 
119  $tableName = $table->getName();
120  $data[$tableName][] = $record;
121  }
122  return $data;
123  }
124 }
static makeInstance($className,... $constructorArguments)