‪TYPO3CMS  ‪main
ExportPageTreeViewTest.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 
24 
26 {
27  protected array ‪$testExtensionsToLoad = [
28  'typo3/sysext/core/Tests/Functional/Fixtures/Extensions/irre_tutorial',
29  ];
30 
31  public static function ‪printTreeSucceedsDataProvider(): array
32  {
33  return [
34  ['pid' => 0, 'levels' => ‪Export::LEVELS_EXPANDED_TREE, 'expectedTreeItemsCount' => 2],
35  ['pid' => 1, 'levels' => ‪Export::LEVELS_EXPANDED_TREE, 'expectedTreeItemsCount' => 1],
36  ['pid' => 0, 'levels' => 0, 'expectedTreeItemsCount' => 1],
37  ['pid' => 1, 'levels' => 0, 'expectedTreeItemsCount' => 1],
38  ];
39  }
40 
45  public function ‪printTreeSucceeds(int ‪$pid, int ‪$levels, int $expectedTreeItemsCount): void
46  {
47  // @todo: This test needs an overhaul.
48  // It fails with mariadb / mysql with "DOMDocument::loadXML(): Namespace prefix xlink for href on use is not defined in Entity, line: 6"
49  // it fails with sqlite with data set 0 due to missing '</li></ul>' at the end. ExportPagetTree class issue?
50  self::markTestSkipped();
51 
52  $this->importCSVDataSet(__DIR__ . '/../Fixtures/DatabaseImports/irre_tutorial.csv');
53 
54  $exportPageTreeView = $this->getAccessibleMock(ExportPageTreeView::class, null);
55  GeneralUtility::addInstance(ExportPageTreeView::class, $exportPageTreeView);
56 
57  $subject = $this->getAccessibleMock(Export::class, [
58  'setMetaData', 'exportAddRecordsFromRelations', 'exportAddFilesFromRelations', 'exportAddFilesFromSysFilesRecords',
59  ]);
60  $subject->setPid(‪$pid);
61  $subject->setLevels(‪$levels);
62  $subject->setTables(['_ALL']);
63  $subject->process();
64 
65  $clause = $exportPageTreeView->_get('clause');
66  $tree = $exportPageTreeView->_get('tree');
67  $treeHtml = $subject->_get('treeHTML');
68  $domDocument = new \DOMDocument();
69 
70  self::assertEquals(
71  ['deleted=0', 'sys_language_uid=0'],
72  GeneralUtility::trimExplode('AND', $clause, true)
73  );
74  self::assertEquals($expectedTreeItemsCount, count($tree));
75  self::assertEquals($expectedTreeItemsCount, substr_count($treeHtml, '<span class="treelist-title">'));
76  foreach ($tree as $treeItem) {
77  self::assertStringContainsString(
78  sprintf('id="pages%d"', $treeItem['row']['uid']),
79  $treeHtml
80  );
81  self::assertStringContainsString(
82  sprintf('<span class="treelist-title">%s</span>', $treeItem['row']['title']),
83  $treeHtml
84  );
85  }
86 
87  self::assertTrue($domDocument->loadXML($treeHtml));
88  }
89 }
‪TYPO3\CMS\Impexp\ImportExport\$pid
‪int $pid
Definition: ImportExport.php:63
‪TYPO3\CMS\Impexp\View\ExportPageTreeView
Definition: ExportPageTreeView.php:34
‪TYPO3\CMS\Impexp\Tests\Functional\Export\ExportPageTreeViewTest
Definition: ExportPageTreeViewTest.php:26
‪TYPO3\CMS\Impexp\Tests\Functional\Export\ExportPageTreeViewTest\printTreeSucceeds
‪printTreeSucceeds(int $pid, int $levels, int $expectedTreeItemsCount)
Definition: ExportPageTreeViewTest.php:45
‪TYPO3\CMS\Impexp\Export\$levels
‪int $levels
Definition: Export.php:86
‪TYPO3\CMS\Impexp\Export\LEVELS_EXPANDED_TREE
‪const LEVELS_EXPANDED_TREE
Definition: Export.php:53
‪TYPO3\CMS\Impexp\Tests\Functional\Export\ExportPageTreeViewTest\$testExtensionsToLoad
‪array $testExtensionsToLoad
Definition: ExportPageTreeViewTest.php:27
‪TYPO3\CMS\Impexp\Tests\Functional\Export
Definition: ExportPageTreeViewTest.php:18
‪TYPO3\CMS\Impexp\Tests\Functional\AbstractImportExportTestCase
Definition: AbstractImportExportTestCase.php:33
‪TYPO3\CMS\Impexp\Tests\Functional\Export\ExportPageTreeViewTest\printTreeSucceedsDataProvider
‪static printTreeSucceedsDataProvider()
Definition: ExportPageTreeViewTest.php:31
‪TYPO3\CMS\Impexp\Export
Definition: Export.php:51
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:51