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