31 foreach ($this->testNodesToDelete as $node) {
32 if (\
TYPO3\CMS\Core\Utility\GeneralUtility::isFirstPartOfStr($node, PATH_site .
'typo3temp/')) {
43 public function constructorThrowsExceptionIfParentIsNull() {
45 $node = $this->
getAccessibleMock(
'TYPO3\\CMS\\Install\\FolderStructure\\LinkNode', array(
'dummy'), array(),
'', FALSE);
46 $node->__construct(array(), NULL);
53 public function constructorThrowsExceptionIfNameContainsForwardSlash() {
54 $parent = $this->getMock(
'TYPO3\CMS\Install\FolderStructure\NodeInterface', array(), array(),
'', FALSE);
56 $node = $this->
getAccessibleMock(
'TYPO3\\CMS\\Install\\FolderStructure\\LinkNode', array(
'dummy'), array(),
'', FALSE);
60 $node->__construct($structure, $parent);
66 public function constructorSetsParent() {
67 $parent = $this->getMock(
'TYPO3\CMS\Install\FolderStructure\NodeInterface', array(), array(),
'', FALSE);
69 $node = $this->
getAccessibleMock(
'TYPO3\\CMS\\Install\\FolderStructure\\LinkNode', array(
'dummy'), array(),
'', FALSE);
73 $node->__construct($structure, $parent);
74 $this->assertSame($parent, $node->_call(
'getParent'));
80 public function constructorSetsName() {
82 $node = $this->
getAccessibleMock(
'TYPO3\\CMS\\Install\\FolderStructure\\LinkNode', array(
'dummy'), array(),
'', FALSE);
83 $parent = $this->getMock(
'TYPO3\CMS\Install\FolderStructure\RootNodeInterface', array(), array(),
'', FALSE);
85 $node->__construct(array(
'name' => $name), $parent);
86 $this->assertSame($name, $node->getName());
92 public function constructorSetsTarget() {
94 $node = $this->
getAccessibleMock(
'TYPO3\\CMS\\Install\\FolderStructure\\LinkNode', array(
'dummy'), array(),
'', FALSE);
95 $parent = $this->getMock(
'TYPO3\CMS\Install\FolderStructure\RootNodeInterface', array(), array(),
'', FALSE);
97 $node->__construct(array(
'target' => $target), $parent);
98 $this->assertSame($target, $node->_call(
'getTarget'));
104 public function getStatusReturnsArray() {
107 'TYPO3\\CMS\\Install\\FolderStructure\\LinkNode',
108 array(
'isWindowsOs',
'getAbsolutePath',
'exists'),
113 $path = PATH_site .
'typo3temp/' . $this->
getUniqueId(
'dir_');
114 $node->expects($this->any())->method(
'getAbsolutePath')->will($this->returnValue($path));
115 $this->assertInternalType(
'array', $node->getStatus());
121 public function getStatusReturnsArrayWithInformationStatusIfRunningOnWindows() {
124 'TYPO3\\CMS\\Install\\FolderStructure\\LinkNode',
125 array(
'isWindowsOs',
'getAbsolutePath',
'exists'),
130 $path = PATH_site .
'typo3temp/' . $this->
getUniqueId(
'dir_');
131 $node->expects($this->any())->method(
'getAbsolutePath')->will($this->returnValue($path));
132 $node->expects($this->once())->method(
'isWindowsOs')->will($this->returnValue(TRUE));
133 $statusArray = $node->getStatus();
135 $status = $statusArray[0];
136 $this->assertInstanceOf(
'TYPO3\\CMS\\Install\\Status\\InfoStatus', $status);
142 public function getStatusReturnsArrayWithErrorStatusIfLinkNotExists() {
145 'TYPO3\\CMS\\Install\\FolderStructure\\LinkNode',
146 array(
'isWindowsOs',
'getAbsolutePath',
'exists'),
151 $path = PATH_site .
'typo3temp/' . $this->
getUniqueId(
'dir_');
152 $node->expects($this->any())->method(
'getAbsolutePath')->will($this->returnValue($path));
153 $node->expects($this->any())->method(
'isWindowsOs')->will($this->returnValue(FALSE));
154 $node->expects($this->once())->method(
'exists')->will($this->returnValue(FALSE));
155 $statusArray = $node->getStatus();
157 $status = $statusArray[0];
158 $this->assertInstanceOf(
'TYPO3\\CMS\\Install\\Status\\ErrorStatus', $status);
164 public function getStatusReturnsArrayWithWarningStatusIfNodeIsNotALink() {
167 'TYPO3\\CMS\\Install\\FolderStructure\\LinkNode',
168 array(
'isWindowsOs',
'getAbsolutePath',
'exists',
'isLink',
'getRelativePathBelowSiteRoot'),
173 $node->expects($this->any())->method(
'getAbsolutePath')->will($this->returnValue($path));
174 $node->expects($this->any())->method(
'exists')->will($this->returnValue(TRUE));
175 $node->expects($this->once())->method(
'isLink')->will($this->returnValue(FALSE));
176 $statusArray = $node->getStatus();
178 $status = $statusArray[0];
179 $this->assertInstanceOf(
'\TYPO3\CMS\Install\Status\WarningStatus', $status);
185 public function getStatusReturnsErrorStatusIfLinkTargetIsNotCorrect() {
188 'TYPO3\\CMS\\Install\\FolderStructure\\LinkNode',
189 array(
'isWindowsOs',
'getAbsolutePath',
'exists',
'isLink',
'isTargetCorrect',
'getCurrentTarget',
'getRelativePathBelowSiteRoot'),
194 $node->expects($this->any())->method(
'getAbsolutePath')->will($this->returnValue($path));
195 $node->expects($this->any())->method(
'getCurrentTarget')->will($this->returnValue(
''));
196 $node->expects($this->any())->method(
'exists')->will($this->returnValue(TRUE));
197 $node->expects($this->any())->method(
'isLink')->will($this->returnValue(TRUE));
198 $node->expects($this->once())->method(
'isLink')->will($this->returnValue(FALSE));
199 $statusArray = $node->getStatus();
201 $status = $statusArray[0];
202 $this->assertInstanceOf(
'\TYPO3\CMS\Install\Status\ErrorStatus', $status);
208 public function getStatusReturnsOkStatusIfLinkExistsAndTargetIsCorrect() {
211 'TYPO3\\CMS\\Install\\FolderStructure\\LinkNode',
212 array(
'isWindowsOs',
'getAbsolutePath',
'exists',
'isLink',
'isTargetCorrect',
'getRelativePathBelowSiteRoot'),
217 $node->expects($this->any())->method(
'getAbsolutePath')->will($this->returnValue($path));
218 $node->expects($this->any())->method(
'exists')->will($this->returnValue(TRUE));
219 $node->expects($this->once())->method(
'isLink')->will($this->returnValue(TRUE));
220 $node->expects($this->once())->method(
'isTargetCorrect')->will($this->returnValue(TRUE));
221 $statusArray = $node->getStatus();
223 $status = $statusArray[0];
224 $this->assertInstanceOf(
'\TYPO3\CMS\Install\Status\OkStatus', $status);
230 public function fixReturnsEmptyArray() {
233 'TYPO3\\CMS\\Install\\FolderStructure\\LinkNode',
234 array(
'getRelativePathBelowSiteRoot'),
239 $statusArray = $node->fix();
240 $this->assertEmpty($statusArray);
247 public function isLinkThrowsExceptionIfLinkNotExists() {
249 $node = $this->
getAccessibleMock(
'TYPO3\\CMS\\Install\\FolderStructure\\LinkNode', array(
'exists'), array(),
'', FALSE);
250 $node->expects($this->once())->method(
'exists')->will($this->returnValue(FALSE));
251 $this->assertFalse($node->_call(
'isLink'));
257 public function isLinkReturnsTrueIfNameIsLink() {
258 if (TYPO3_OS ===
'WIN') {
259 $this->markTestSkipped(
'Test not available on Windows OS.');
262 $node = $this->
getAccessibleMock(
'TYPO3\\CMS\\Install\\FolderStructure\\LinkNode', array(
'exists',
'getAbsolutePath'), array(),
'', FALSE);
263 $path = PATH_site .
'typo3temp/' . $this->
getUniqueId(
'link_');
264 $target = PATH_site . $this->
getUniqueId(
'linkTarget_');
265 symlink($target, $path);
266 $this->testNodesToDelete[] = $path;
267 $node->expects($this->any())->method(
'exists')->will($this->returnValue(TRUE));
268 $node->expects($this->any())->method(
'getAbsolutePath')->will($this->returnValue($path));
269 $this->assertTrue($node->_call(
'isLink'));
275 public function isFileReturnsFalseIfNameIsAFile() {
276 if (TYPO3_OS ===
'WIN') {
277 $this->markTestSkipped(
'Test not available on Windows OS.');
280 $node = $this->
getAccessibleMock(
'TYPO3\\CMS\\Install\\FolderStructure\\LinkNode', array(
'exists',
'getAbsolutePath'), array(),
'', FALSE);
281 $path = PATH_site .
'typo3temp/' . $this->
getUniqueId(
'file_');
283 $this->testNodesToDelete[] = $path;
284 $node->expects($this->any())->method(
'exists')->will($this->returnValue(TRUE));
285 $node->expects($this->any())->method(
'getAbsolutePath')->will($this->returnValue($path));
286 $this->assertFalse($node->_call(
'isLink'));
293 public function isTargetCorrectThrowsExceptionIfLinkNotExists() {
295 $node = $this->
getAccessibleMock(
'TYPO3\\CMS\\Install\\FolderStructure\\LinkNode', array(
'exists'), array(),
'', FALSE);
296 $node->expects($this->once())->method(
'exists')->will($this->returnValue(FALSE));
297 $this->assertFalse($node->_call(
'isTargetCorrect'));
304 public function isTargetCorrectThrowsExceptionIfNodeIsNotALink() {
306 $node = $this->
getAccessibleMock(
'TYPO3\\CMS\\Install\\FolderStructure\\LinkNode', array(
'exists',
'isLink',
'getTarget'), array(),
'', FALSE);
307 $node->expects($this->any())->method(
'exists')->will($this->returnValue(TRUE));
308 $node->expects($this->once())->method(
'isLink')->will($this->returnValue(FALSE));
309 $this->assertTrue($node->_call(
'isTargetCorrect'));
315 public function isTargetCorrectReturnsTrueIfNoExpectedLinkTargetIsSpecified() {
317 $node = $this->
getAccessibleMock(
'TYPO3\\CMS\\Install\\FolderStructure\\LinkNode', array(
'exists',
'isLink',
'getTarget'), array(),
'', FALSE);
318 $node->expects($this->any())->method(
'exists')->will($this->returnValue(TRUE));
319 $node->expects($this->any())->method(
'isLink')->will($this->returnValue(TRUE));
320 $node->expects($this->once())->method(
'getTarget')->will($this->returnValue(
''));
321 $this->assertTrue($node->_call(
'isTargetCorrect'));
327 public function isTargetCorrectAcceptsATargetWithATrailingSlash() {
329 $node = $this->
getAccessibleMock(
'TYPO3\\CMS\\Install\\FolderStructure\\LinkNode', array(
'exists',
'isLink',
'getCurrentTarget',
'getTarget'), array(),
'', FALSE);
330 $node->expects($this->any())->method(
'exists')->will($this->returnValue(TRUE));
331 $node->expects($this->any())->method(
'isLink')->will($this->returnValue(TRUE));
332 $node->expects($this->once())->method(
'getCurrentTarget')->will($this->returnValue(
'someLinkTarget/'));
333 $node->expects($this->once())->method(
'getTarget')->will($this->returnValue(
'someLinkTarget'));
334 $this->assertTrue($node->_call(
'isTargetCorrect'));
340 public function isTargetCorrectReturnsTrueIfActualTargetIsIdenticalToSpecifiedTarget() {
341 if (TYPO3_OS ===
'WIN') {
342 $this->markTestSkipped(
'Test not available on Windows OS.');
344 $path = PATH_site .
'typo3temp/' . $this->
getUniqueId(
'link_');
346 symlink($target, $path);
347 $this->testNodesToDelete[] = $path;
349 $node = $this->
getAccessibleMock(
'TYPO3\\CMS\\Install\\FolderStructure\\LinkNode',
350 array(
'exists',
'isLink',
'getTarget',
'getAbsolutePath'),
355 $node->expects($this->any())->method(
'exists')->will($this->returnValue(TRUE));
356 $node->expects($this->any())->method(
'isLink')->will($this->returnValue(TRUE));
357 $node->expects($this->once())->method(
'getTarget')->will($this->returnValue($target));
358 $node->expects($this->once())->method(
'getAbsolutePath')->will($this->returnValue($path));
359 $this->assertTrue($node->_call(
'isTargetCorrect'));
365 public function isTargetCorrectReturnsFalseIfActualTargetIsNotIdenticalToSpecifiedTarget() {
366 if (TYPO3_OS ===
'WIN') {
367 $this->markTestSkipped(
'Test not available on Windows OS.');
369 $path = PATH_site .
'typo3temp/' . $this->
getUniqueId(
'link_');
371 symlink($target, $path);
372 $this->testNodesToDelete[] = $path;
374 $node = $this->
getAccessibleMock(
'TYPO3\\CMS\\Install\\FolderStructure\\LinkNode',
375 array(
'exists',
'isLink',
'getTarget',
'getAbsolutePath'),
380 $node->expects($this->any())->method(
'exists')->will($this->returnValue(TRUE));
381 $node->expects($this->any())->method(
'isLink')->will($this->returnValue(TRUE));
382 $node->expects($this->once())->method(
'getTarget')->will($this->returnValue(
'foo'));
383 $node->expects($this->once())->method(
'getAbsolutePath')->will($this->returnValue($path));
384 $this->assertFalse($node->_call(
'isTargetCorrect'));
static rmdir($path, $removeNonEmpty=FALSE)
getAccessibleMock( $originalClassName, array $methods=array(), array $arguments=array(), $mockClassName='', $callOriginalConstructor=TRUE, $callOriginalClone=TRUE, $callAutoload=TRUE)