TYPO3 CMS  TYPO3_6-2
WorkspaceServiceTest.php
Go to the documentation of this file.
1 <?php
3 
18 
25 
26  protected $coreExtensionsToLoad = array('version', 'workspaces');
27 
31  public function setUp() {
32  parent::setUp();
33  $this->setUpBackendUserFromFixture(1);
34  \TYPO3\CMS\Core\Core\Bootstrap::getInstance()->initializeLanguageObject();
35  $this->importDataSet(__DIR__ . '/../Fixtures/sys_workspace.xml');
36  }
37 
41  public function emptyWorkspaceReturnsEmptyArray() {
42  $this->markTestSkipped("This test need a review. It is green even if all fixtures are commented out");
43  $service = new \TYPO3\CMS\Workspaces\Service\WorkspaceService();
44  $result = $service->selectVersionsInWorkspace(90);
45  $this->assertTrue(empty($result), 'The workspace 90 contains no changes and the result was supposed to be empty');
46  $this->assertTrue(is_array($result), 'Even the empty result from workspace 90 is supposed to be an array');
47  }
48 
53  $this->importDataSet(ORIGINAL_ROOT . 'typo3/sysext/core/Tests/Functional/Fixtures/pages.xml');
54  $this->importDataSet(__DIR__ . '/../Fixtures/pages.xml');
55  $service = new \TYPO3\CMS\Workspaces\Service\WorkspaceService();
56  $result = $service->selectVersionsInWorkspace(91, 0, -99, 2);
57  $this->assertTrue(is_array($result), 'The result from workspace 91 is supposed to be an array');
58  $this->assertEquals(1, sizeof($result['pages']), 'The result is supposed to contain one version for this page in workspace 91');
59  $this->assertEquals(102, $result['pages'][0]['uid'], 'Wrong workspace overlay record picked');
60  $this->assertEquals(1, $result['pages'][0]['livepid'], 'Real pid wasn\'t resolved correctly');
61  }
62 
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, sizeof($result['pages']), 'The result is supposed to contain one version for this page in workspace 91');
73  }
74 
78  public function versionsCanBeFoundRecursive() {
79  $this->importDataSet(ORIGINAL_ROOT . 'typo3/sysext/core/Tests/Functional/Fixtures/pages.xml');
80  $this->importDataSet(__DIR__ . '/../Fixtures/pages.xml');
81  $service = new \TYPO3\CMS\Workspaces\Service\WorkspaceService();
82  $result = $service->selectVersionsInWorkspace(91, 0, -99, 1, 99);
83  $this->assertTrue(is_array($result), 'The result from workspace 91 is supposed to be an array');
84  $this->assertEquals(4, sizeof($result['pages']), 'The result is supposed to contain four versions for this page in workspace 91');
85  }
86 
91  $this->importDataSet(ORIGINAL_ROOT . 'typo3/sysext/core/Tests/Functional/Fixtures/pages.xml');
92  $this->importDataSet(__DIR__ . '/../Fixtures/pages.xml');
93  $service = new \TYPO3\CMS\Workspaces\Service\WorkspaceService();
94  // testing stage 1
95  $result = $service->selectVersionsInWorkspace(91, 0, 1, 1, 99);
96  $this->assertTrue(is_array($result), 'The result from workspace 91 is supposed to be an array');
97  $this->assertEquals(2, sizeof($result['pages']), 'The result is supposed to contain two versions for this page in workspace 91');
98  $this->assertEquals(102, $result['pages'][0]['uid'], 'First records is supposed to have the uid 102');
99  $this->assertEquals(105, $result['pages'][1]['uid'], 'First records is supposed to have the uid 105');
100  // testing stage 2
101  $result = $service->selectVersionsInWorkspace(91, 0, 2, 1, 99);
102  $this->assertTrue(is_array($result), 'The result from workspace 91 is supposed to be an array');
103  $this->assertEquals(2, sizeof($result['pages']), 'The result is supposed to contain two versions for this page in workspace 91');
104  $this->assertEquals(104, $result['pages'][0]['uid'], 'First records is supposed to have the uid 106');
105  $this->assertEquals(106, $result['pages'][1]['uid'], 'First records is supposed to have the uid 106');
106  }
107 
112  $this->importDataSet(ORIGINAL_ROOT . 'typo3/sysext/core/Tests/Functional/Fixtures/pages.xml');
113  $this->importDataSet(__DIR__ . '/../Fixtures/pages.xml');
114  $service = new \TYPO3\CMS\Workspaces\Service\WorkspaceService();
115  // testing all "draft" records
116  $result = $service->selectVersionsInWorkspace(91, 1, -99, 1, 99);
117  $this->assertTrue(is_array($result), 'The result from workspace 91 is supposed to be an array');
118  $this->assertEquals(2, sizeof($result['pages']), 'The result is supposed to contain three versions for this page in workspace 91');
119  // testing all "archive" records
120  $result = $service->selectVersionsInWorkspace(91, 2, -99, 1, 99);
121  $this->assertEquals(2, sizeof($result['pages']), 'The result is supposed to contain two versions for this page in workspace 91');
122  // testing both types records
123  $result = $service->selectVersionsInWorkspace(91, 0, -99, 1, 99);
124  $this->assertEquals(4, sizeof($result['pages']), 'The result is supposed to contain two versions for this page in workspace 91');
125  }
126 
134  $this->markTestSkipped("This test need a review. It is green even if all fixtures are commented out");
135  $this->importDataSet(__DIR__ . '/Fixtures/WorkspaceServiceTestMovedContent.xml');
136  // Test if the placeholder can be found when we ask using recursion (same result)
137  $service = new \TYPO3\CMS\Workspaces\Service\WorkspaceService();
138  $result = $service->selectVersionsInWorkspace(91, 0, -99, 2, 99);
139  $this->assertEquals(0, sizeof($result['pages']), 'Changes should not show up in this branch of the tree within workspace 91');
140  $this->assertEquals(0, sizeof($result['tt_content']), 'Changes should not show up in this branch of the tree within workspace 91');
141  }
142 
147  $this->importDataSet(__DIR__ . '/Fixtures/WorkspaceServiceTestMovedContent.xml');
148  // Test if the placeholder can be found when we ask using recursion (same result)
149  $service = new \TYPO3\CMS\Workspaces\Service\WorkspaceService();
150  $result = $service->selectVersionsInWorkspace(91, 0, -99, 5, 99);
151  $this->assertEquals(1, sizeof($result['pages']), 'Wrong amount of page versions found within workspace 91');
152  $this->assertEquals(103, $result['pages'][0]['uid'], 'Wrong move-to pointer found for page 3 in workspace 91');
153  $this->assertEquals(5, $result['pages'][0]['wspid'], 'Wrong workspace-pointer found for page 3 in workspace 91');
154  $this->assertEquals(2, $result['pages'][0]['livepid'], 'Wrong live-pointer found for page 3 in workspace 91');
155  $this->assertEquals(1, sizeof($result['tt_content']), 'Wrong amount of tt_content versions found within workspace 91');
156  $this->assertEquals(106, $result['tt_content'][0]['uid'], 'Wrong move-to pointer found for page 3 in workspace 91');
157  $this->assertEquals(7, $result['tt_content'][0]['wspid'], 'Wrong workspace-pointer found for page 3 in workspace 91');
158  $this->assertEquals(2, $result['tt_content'][0]['livepid'], 'Wrong live-pointer found for page 3 in workspace 91');
159  }
160 
165  $this->importDataSet(__DIR__ . '/Fixtures/WorkspaceServiceTestMovedContent.xml');
166  // Test if the placeholder can be found when we ask using recursion (same result)
167  $service = new \TYPO3\CMS\Workspaces\Service\WorkspaceService();
168  $result = $service->selectVersionsInWorkspace(91, 0, -99, 3, 99);
169  $this->assertEquals(1, sizeof($result), 'Wrong amount of versions found within workspace 91');
170  $this->assertEquals(1, sizeof($result['pages']), 'Wrong amount of page versions found within workspace 91');
171  $this->assertEquals(103, $result['pages'][0]['uid'], 'Wrong move-to pointer found for page 3 in workspace 91');
172  }
173 }
if($list_of_literals) if(!empty($literals)) if(!empty($literals)) $result
Analyse literals to prepend the N char to them if their contents aren&#39;t numeric.