TYPO3 CMS  TYPO3_7-6
WorkspaceServiceTest.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 
21 {
22  protected $coreExtensionsToLoad = ['version', 'workspaces'];
23 
27  protected function setUp()
28  {
29  parent::setUp();
30  $this->setUpBackendUserFromFixture(1);
31  \TYPO3\CMS\Core\Core\Bootstrap::getInstance()->initializeLanguageObject();
32  $this->importDataSet(__DIR__ . '/../Fixtures/sys_workspace.xml');
33  }
34 
39  {
40  $this->markTestSkipped('This test need a review. It is green even if all fixtures are commented out');
41  $service = new \TYPO3\CMS\Workspaces\Service\WorkspaceService();
42  $result = $service->selectVersionsInWorkspace(90);
43  $this->assertTrue(empty($result), 'The workspace 90 contains no changes and the result was supposed to be empty');
44  $this->assertTrue(is_array($result), 'Even the empty result from workspace 90 is supposed to be an array');
45  }
46 
51  {
52  $this->importDataSet(ORIGINAL_ROOT . 'typo3/sysext/core/Tests/Functional/Fixtures/pages.xml');
53  $this->importDataSet(__DIR__ . '/../Fixtures/pages.xml');
54  $service = new \TYPO3\CMS\Workspaces\Service\WorkspaceService();
55  $result = $service->selectVersionsInWorkspace(91, 0, -99, 2);
56  $this->assertTrue(is_array($result), 'The result from workspace 91 is supposed to be an array');
57  $this->assertEquals(1, count($result['pages']), 'The result is supposed to contain one version for this page in workspace 91');
58  $this->assertEquals(102, $result['pages'][0]['uid'], 'Wrong workspace overlay record picked');
59  $this->assertEquals(1, $result['pages'][0]['livepid'], 'Real pid wasn\'t resolved correctly');
60  }
61 
66  {
67  $this->importDataSet(ORIGINAL_ROOT . 'typo3/sysext/core/Tests/Functional/Fixtures/pages.xml');
68  $this->importDataSet(__DIR__ . '/../Fixtures/pages.xml');
69  $service = new \TYPO3\CMS\Workspaces\Service\WorkspaceService();
70  $result = $service->selectVersionsInWorkspace(\TYPO3\CMS\Workspaces\Service\WorkspaceService::SELECT_ALL_WORKSPACES, 0, -99, 2);
71  $this->assertTrue(is_array($result), 'The result from workspace 91 is supposed to be an array');
72  $this->assertEquals(2, count($result['pages']), 'The result is supposed to contain one version for this page in workspace 91');
73  }
74 
78  public function versionsCanBeFoundRecursive()
79  {
80  $this->importDataSet(ORIGINAL_ROOT . 'typo3/sysext/core/Tests/Functional/Fixtures/pages.xml');
81  $this->importDataSet(__DIR__ . '/../Fixtures/pages.xml');
82  $service = new \TYPO3\CMS\Workspaces\Service\WorkspaceService();
83  $result = $service->selectVersionsInWorkspace(91, 0, -99, 1, 99);
84  $this->assertTrue(is_array($result), 'The result from workspace 91 is supposed to be an array');
85  $this->assertEquals(4, count($result['pages']), 'The result is supposed to contain four versions for this page in workspace 91');
86  }
87 
92  {
93  $this->importDataSet(ORIGINAL_ROOT . 'typo3/sysext/core/Tests/Functional/Fixtures/pages.xml');
94  $this->importDataSet(__DIR__ . '/../Fixtures/pages.xml');
95  $service = new \TYPO3\CMS\Workspaces\Service\WorkspaceService();
96  // testing stage 1
97  $result = $service->selectVersionsInWorkspace(91, 0, 1, 1, 99);
98  $this->assertTrue(is_array($result), 'The result from workspace 91 is supposed to be an array');
99  $this->assertEquals(2, count($result['pages']), 'The result is supposed to contain two versions for this page in workspace 91');
100  $this->assertEquals(102, $result['pages'][0]['uid'], 'First records is supposed to have the uid 102');
101  $this->assertEquals(105, $result['pages'][1]['uid'], 'First records is supposed to have the uid 105');
102  // testing stage 2
103  $result = $service->selectVersionsInWorkspace(91, 0, 2, 1, 99);
104  $this->assertTrue(is_array($result), 'The result from workspace 91 is supposed to be an array');
105  $this->assertEquals(2, count($result['pages']), 'The result is supposed to contain two versions for this page in workspace 91');
106  $this->assertEquals(104, $result['pages'][0]['uid'], 'First records is supposed to have the uid 106');
107  $this->assertEquals(106, $result['pages'][1]['uid'], 'First records is supposed to have the uid 106');
108  }
109 
114  {
115  $this->importDataSet(ORIGINAL_ROOT . 'typo3/sysext/core/Tests/Functional/Fixtures/pages.xml');
116  $this->importDataSet(__DIR__ . '/../Fixtures/pages.xml');
117  $service = new \TYPO3\CMS\Workspaces\Service\WorkspaceService();
118  // testing all "draft" records
119  $result = $service->selectVersionsInWorkspace(91, 1, -99, 1, 99);
120  $this->assertTrue(is_array($result), 'The result from workspace 91 is supposed to be an array');
121  $this->assertEquals(2, count($result['pages']), 'The result is supposed to contain three versions for this page in workspace 91');
122  // testing all "archive" records
123  $result = $service->selectVersionsInWorkspace(91, 2, -99, 1, 99);
124  $this->assertEquals(2, count($result['pages']), 'The result is supposed to contain two versions for this page in workspace 91');
125  // testing both types records
126  $result = $service->selectVersionsInWorkspace(91, 0, -99, 1, 99);
127  $this->assertEquals(4, count($result['pages']), 'The result is supposed to contain two versions for this page in workspace 91');
128  }
129 
137  {
138  $this->markTestSkipped('This test need a review. It is green even if all fixtures are commented out');
139  $this->importDataSet(__DIR__ . '/Fixtures/WorkspaceServiceTestMovedContent.xml');
140  // Test if the placeholder can be found when we ask using recursion (same result)
141  $service = new \TYPO3\CMS\Workspaces\Service\WorkspaceService();
142  $result = $service->selectVersionsInWorkspace(91, 0, -99, 2, 99);
143  $this->assertEquals(0, count($result['pages']), 'Changes should not show up in this branch of the tree within workspace 91');
144  $this->assertEquals(0, count($result['tt_content']), 'Changes should not show up in this branch of the tree within workspace 91');
145  }
146 
151  {
152  $this->importDataSet(__DIR__ . '/Fixtures/WorkspaceServiceTestMovedContent.xml');
153  // Test if the placeholder can be found when we ask using recursion (same result)
154  $service = new \TYPO3\CMS\Workspaces\Service\WorkspaceService();
155  $result = $service->selectVersionsInWorkspace(91, 0, -99, 5, 99);
156  $this->assertEquals(1, count($result['pages']), 'Wrong amount of page versions found within workspace 91');
157  $this->assertEquals(103, $result['pages'][0]['uid'], 'Wrong move-to pointer found for page 3 in workspace 91');
158  $this->assertEquals(5, $result['pages'][0]['wspid'], 'Wrong workspace-pointer found for page 3 in workspace 91');
159  $this->assertEquals(2, $result['pages'][0]['livepid'], 'Wrong live-pointer found for page 3 in workspace 91');
160  $this->assertEquals(1, count($result['tt_content']), 'Wrong amount of tt_content versions found within workspace 91');
161  $this->assertEquals(106, $result['tt_content'][0]['uid'], 'Wrong move-to pointer found for page 3 in workspace 91');
162  $this->assertEquals(7, $result['tt_content'][0]['wspid'], 'Wrong workspace-pointer found for page 3 in workspace 91');
163  $this->assertEquals(2, $result['tt_content'][0]['livepid'], 'Wrong live-pointer found for page 3 in workspace 91');
164  }
165 
170  {
171  $this->importDataSet(__DIR__ . '/Fixtures/WorkspaceServiceTestMovedContent.xml');
172  // Test if the placeholder can be found when we ask using recursion (same result)
173  $service = new \TYPO3\CMS\Workspaces\Service\WorkspaceService();
174  $result = $service->selectVersionsInWorkspace(91, 0, -99, 3, 99);
175  $this->assertEquals(1, count($result), 'Wrong amount of versions found within workspace 91');
176  $this->assertEquals(1, count($result['pages']), 'Wrong amount of page versions found within workspace 91');
177  $this->assertEquals(103, $result['pages'][0]['uid'], 'Wrong move-to pointer found for page 3 in workspace 91');
178  }
179 }