‪TYPO3CMS  10.4
AbstractRecycleTestCase.php
Go to the documentation of this file.
1 <?php
2 
3 /*
4  * This file is part of the TYPO3 CMS project.
5  *
6  * It is free software; you can redistribute it and/or modify it under
7  * the terms of the GNU General Public License, either version 2
8  * of the License, or any later version.
9  *
10  * For the full copyright and license information, please read the
11  * LICENSE.txt file that was distributed with this source code.
12  *
13  * The TYPO3 project - inspiring people to share!
14  */
15 
17 
21 use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase;
22 
26 abstract class ‪AbstractRecycleTestCase extends FunctionalTestCase
27 {
31  protected ‪$coreExtensionsToLoad = ['recycler'];
32 
38  protected ‪$backendUserFixture = 'typo3/sysext/recycler/Tests/Functional/Fixtures/Database/be_users.xml';
39 
44  protected function ‪setUp(): void
45  {
46  parent::setUp();
47  $this->importDataSet(__DIR__ . '/../Fixtures/Database/be_groups.xml');
49  }
50 
58  protected function ‪getDeletedPages($pageUid, $depth = 0)
59  {
61  $deletedRecords = GeneralUtility::makeInstance(DeletedRecords::class);
62  $deletedRecords->loadData($pageUid, 'pages', $depth);
63  return $deletedRecords->getDeletedRows();
64  }
65 
72  protected function ‪getDeletedContent($contentUid)
73  {
75  $deletedRecords = GeneralUtility::makeInstance(DeletedRecords::class);
76  $deletedRecords->loadData($contentUid, 'tt_content', 0);
77  return $deletedRecords->getDeletedRows();
78  }
79 
87  protected function ‪loadDataSet($path)
88  {
89  if (!is_file($path)) {
90  throw new \Exception(
91  'Fixture file ' . $path . ' not found',
92  1476109709
93  );
94  }
95 
96  $data = [];
97  $fileContent = file_get_contents($path);
98  // Disables the functionality to allow external entities to be loaded when parsing the XML, must be kept
99  if (PHP_MAJOR_VERSION < 8) {
100  $previousValueOfEntityLoader = libxml_disable_entity_loader(true);
101  }
102  $xml = simplexml_load_string($fileContent);
103  if (PHP_MAJOR_VERSION < 8) {
104  libxml_disable_entity_loader($previousValueOfEntityLoader);
105  }
106 
108  foreach ($xml->children() as $table) {
109  $record = [];
110 
112  foreach ($table->children() as $column) {
113  $columnName = $column->getName();
114  $columnValue = null;
115 
116  if (isset($column['ref'])) {
117  $columnValue = explode('#', $column['ref']);
118  } elseif (isset($column['is-NULL']) && ($column['is-NULL'] === 'yes')) {
119  $columnValue = null;
120  } else {
121  $columnValue = (string)$table->$columnName;
122  }
123 
124  $record[$columnName] = $columnValue;
125  }
126 
127  $tableName = $table->getName();
128  $data[$tableName][] = $record;
129  }
130  return $data;
131  }
132 }
‪TYPO3\CMS\Recycler\Tests\Functional\Recycle\AbstractRecycleTestCase\getDeletedPages
‪array getDeletedPages($pageUid, $depth=0)
Definition: AbstractRecycleTestCase.php:56
‪TYPO3\CMS\Recycler\Tests\Functional\Recycle\AbstractRecycleTestCase\$backendUserFixture
‪string $backendUserFixture
Definition: AbstractRecycleTestCase.php:36
‪TYPO3\CMS\Recycler\Tests\Functional\Recycle\AbstractRecycleTestCase
Definition: AbstractRecycleTestCase.php:27
‪TYPO3\CMS\Recycler\Tests\Functional\Recycle
Definition: AbstractRecycleTestCase.php:16
‪TYPO3\CMS\Core\Core\Bootstrap\initializeLanguageObject
‪static initializeLanguageObject()
Definition: Bootstrap.php:617
‪TYPO3\CMS\Recycler\Tests\Functional\Recycle\AbstractRecycleTestCase\$coreExtensionsToLoad
‪array $coreExtensionsToLoad
Definition: AbstractRecycleTestCase.php:30
‪TYPO3\CMS\Recycler\Tests\Functional\Recycle\AbstractRecycleTestCase\setUp
‪setUp()
Definition: AbstractRecycleTestCase.php:42
‪TYPO3\CMS\Recycler\Domain\Model\DeletedRecords
Definition: DeletedRecords.php:38
‪TYPO3\CMS\Core\Core\Bootstrap
Definition: Bootstrap.php:66
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:46
‪TYPO3\CMS\Recycler\Tests\Functional\Recycle\AbstractRecycleTestCase\getDeletedContent
‪array getDeletedContent($contentUid)
Definition: AbstractRecycleTestCase.php:70
‪TYPO3\CMS\Recycler\Tests\Functional\Recycle\AbstractRecycleTestCase\loadDataSet
‪array loadDataSet($path)
Definition: AbstractRecycleTestCase.php:85