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\\FileNode', 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\\FileNode', 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\\FileNode', array(
'dummy'), array(),
'', FALSE);
73 $node->__construct($structure, $parent);
74 $this->assertSame($parent, $node->_call(
'getParent'));
80 public function constructorSetsTargetPermission() {
81 $parent = $this->getMock(
'TYPO3\CMS\Install\FolderStructure\NodeInterface', array(), array(),
'', FALSE);
83 $node = $this->
getAccessibleMock(
'TYPO3\\CMS\\Install\\FolderStructure\\FileNode', array(
'dummy'), array(),
'', FALSE);
84 $targetPermission =
'0660';
87 'targetPermission' => $targetPermission,
89 $node->__construct($structure, $parent);
90 $this->assertSame($targetPermission, $node->_call(
'getTargetPermission'));
96 public function constructorSetsName() {
98 $node = $this->
getAccessibleMock(
'TYPO3\\CMS\\Install\\FolderStructure\\FileNode', array(
'dummy'), array(),
'', FALSE);
99 $parent = $this->getMock(
'TYPO3\CMS\Install\FolderStructure\RootNodeInterface', array(), array(),
'', FALSE);
101 $node->__construct(array(
'name' => $name), $parent);
102 $this->assertSame($name, $node->getName());
109 public function constructorThrowsExceptionIfBothTargetContentAndTargetContentFileAreSet() {
111 $node = $this->
getAccessibleMock(
'TYPO3\\CMS\\Install\\FolderStructure\\FileNode', array(
'dummy'), array(),
'', FALSE);
112 $parent = $this->getMock(
'TYPO3\CMS\Install\FolderStructure\RootNodeInterface', array(), array(),
'', FALSE);
115 'targetContent' =>
'foo',
116 'targetContentFile' =>
'aPath',
118 $node->__construct($structure, $parent);
124 public function constructorSetsTargetContent() {
126 $node = $this->
getAccessibleMock(
'TYPO3\\CMS\\Install\\FolderStructure\\FileNode', array(
'dummy'), array(),
'', FALSE);
127 $parent = $this->getMock(
'TYPO3\CMS\Install\FolderStructure\RootNodeInterface', array(), array(),
'', FALSE);
131 'targetContent' => $targetContent,
133 $node->__construct($structure, $parent);
134 $this->assertSame($targetContent, $node->_get(
'targetContent'));
140 public function constructorSetsTargetContentToContentOfTargetContentFile() {
142 $node = $this->
getAccessibleMock(
'TYPO3\\CMS\\Install\\FolderStructure\\FileNode', array(
'dummy'), array(),
'', FALSE);
143 $parent = $this->getMock(
'TYPO3\CMS\Install\FolderStructure\RootNodeInterface', array(), array(),
'', FALSE);
144 $targetFile = PATH_site .
'typo3temp/' . $this->
getUniqueId(
'test_');
146 file_put_contents($targetFile, $targetContent);
147 $this->testNodesToDelete[] = $targetFile;
150 'targetContentFile' => $targetFile,
152 $node->__construct($structure, $parent);
153 $this->assertSame($targetContent, $node->_get(
'targetContent'));
160 public function constructorThrowsExceptionIfTargetContentFileDoesNotExist() {
162 $node = $this->
getAccessibleMock(
'TYPO3\\CMS\\Install\\FolderStructure\\FileNode', array(
'dummy'), array(),
'', FALSE);
163 $parent = $this->getMock(
'TYPO3\CMS\Install\FolderStructure\RootNodeInterface', array(), array(),
'', FALSE);
164 $targetFile = PATH_site .
'typo3temp/' . $this->
getUniqueId(
'test_');
167 'targetContentFile' => $targetFile,
169 $node->__construct($structure, $parent);
175 public function targetContentIsNullIfNotGiven() {
177 $node = $this->
getAccessibleMock(
'TYPO3\\CMS\\Install\\FolderStructure\\FileNode', array(
'dummy'), array(),
'', FALSE);
178 $parent = $this->getMock(
'TYPO3\CMS\Install\FolderStructure\RootNodeInterface', array(), array(),
'', FALSE);
182 $node->__construct($structure, $parent);
183 $this->assertNull($node->_get(
'targetContent'));
189 public function getStatusReturnsArray() {
192 'TYPO3\\CMS\\Install\\FolderStructure\\FileNode',
193 array(
'getAbsolutePath',
'exists',
'isFile',
'isWritable',
'isPermissionCorrect',
'isContentCorrect'),
198 $path = PATH_site .
'typo3temp/' . $this->
getUniqueId(
'dir_');
199 $node->expects($this->any())->method(
'getAbsolutePath')->will($this->returnValue($path));
200 $node->expects($this->any())->method(
'exists')->will($this->returnValue(TRUE));
201 $node->expects($this->any())->method(
'isFile')->will($this->returnValue(TRUE));
202 $node->expects($this->any())->method(
'isPermissionCorrect')->will($this->returnValue(TRUE));
203 $node->expects($this->any())->method(
'isWritable')->will($this->returnValue(TRUE));
204 $node->expects($this->any())->method(
'isContentCorrect')->will($this->returnValue(TRUE));
205 $this->assertInternalType(
'array', $node->getStatus());
211 public function getStatusReturnsArrayWithWarningStatusIFileNotExists() {
214 'TYPO3\\CMS\\Install\\FolderStructure\\FileNode',
215 array(
'getAbsolutePath',
'exists',
'isFile',
'isWritable',
'isPermissionCorrect',
'isContentCorrect'),
220 $path = PATH_site .
'typo3temp/' . $this->
getUniqueId(
'dir_');
221 $node->expects($this->any())->method(
'getAbsolutePath')->will($this->returnValue($path));
222 $node->expects($this->any())->method(
'exists')->will($this->returnValue(FALSE));
223 $node->expects($this->any())->method(
'isFile')->will($this->returnValue(TRUE));
224 $node->expects($this->any())->method(
'isPermissionCorrect')->will($this->returnValue(TRUE));
225 $node->expects($this->any())->method(
'isWritable')->will($this->returnValue(TRUE));
226 $node->expects($this->any())->method(
'isContentCorrect')->will($this->returnValue(TRUE));
227 $statusArray = $node->getStatus();
229 $status = $statusArray[0];
230 $this->assertInstanceOf(
'\TYPO3\CMS\Install\Status\WarningStatus', $status);
236 public function getStatusReturnsArrayWithErrorStatusIfNodeIsNotAFile() {
239 'TYPO3\\CMS\\Install\\FolderStructure\\FileNode',
240 array(
'getAbsolutePath',
'exists',
'isFile',
'isWritable',
'isPermissionCorrect',
'isContentCorrect'),
245 $path = PATH_site .
'typo3temp/' . $this->
getUniqueId(
'dir_');
247 $this->testNodesToDelete[] = $path;
248 $node->expects($this->any())->method(
'getAbsolutePath')->will($this->returnValue($path));
249 $node->expects($this->any())->method(
'exists')->will($this->returnValue(TRUE));
250 $node->expects($this->any())->method(
'isFile')->will($this->returnValue(FALSE));
251 $node->expects($this->any())->method(
'isPermissionCorrect')->will($this->returnValue(TRUE));
252 $node->expects($this->any())->method(
'isWritable')->will($this->returnValue(TRUE));
253 $node->expects($this->any())->method(
'isContentCorrect')->will($this->returnValue(TRUE));
254 $statusArray = $node->getStatus();
256 $status = $statusArray[0];
257 $this->assertInstanceOf(
'\TYPO3\CMS\Install\Status\ErrorStatus', $status);
263 public function getStatusReturnsArrayNoticeStatusIfFileExistsButIsNotWritable() {
266 'TYPO3\\CMS\\Install\\FolderStructure\\FileNode',
267 array(
'getAbsolutePath',
'exists',
'isFile',
'isWritable',
'isPermissionCorrect',
'isContentCorrect'),
272 $path = PATH_site .
'typo3temp/' . $this->
getUniqueId(
'dir_');
274 $this->testNodesToDelete[] = $path;
275 $node->expects($this->any())->method(
'getAbsolutePath')->will($this->returnValue($path));
276 $node->expects($this->any())->method(
'exists')->will($this->returnValue(TRUE));
277 $node->expects($this->any())->method(
'isFile')->will($this->returnValue(TRUE));
278 $node->expects($this->any())->method(
'isPermissionCorrect')->will($this->returnValue(TRUE));
279 $node->expects($this->any())->method(
'isWritable')->will($this->returnValue(FALSE));
280 $node->expects($this->any())->method(
'isContentCorrect')->will($this->returnValue(TRUE));
281 $statusArray = $node->getStatus();
283 $status = $statusArray[0];
284 $this->assertInstanceOf(
'\TYPO3\CMS\Install\Status\NoticeStatus', $status);
290 public function getStatusReturnsArrayWithNoticeStatusIfFileExistsButPermissionAreNotCorrect() {
293 'TYPO3\\CMS\\Install\\FolderStructure\\FileNode',
294 array(
'getAbsolutePath',
'exists',
'isFile',
'isWritable',
'isPermissionCorrect',
'isContentCorrect'),
299 $path = PATH_site .
'typo3temp/' . $this->
getUniqueId(
'dir_');
301 $this->testNodesToDelete[] = $path;
302 $node->expects($this->any())->method(
'getAbsolutePath')->will($this->returnValue($path));
303 $node->expects($this->any())->method(
'exists')->will($this->returnValue(TRUE));
304 $node->expects($this->any())->method(
'isFile')->will($this->returnValue(TRUE));
305 $node->expects($this->any())->method(
'isPermissionCorrect')->will($this->returnValue(FALSE));
306 $node->expects($this->any())->method(
'isWritable')->will($this->returnValue(TRUE));
307 $node->expects($this->any())->method(
'isContentCorrect')->will($this->returnValue(TRUE));
308 $statusArray = $node->getStatus();
310 $status = $statusArray[0];
311 $this->assertInstanceOf(
'\TYPO3\CMS\Install\Status\NoticeStatus', $status);
317 public function getStatusReturnsArrayWithNoticeStatusIfFileExistsButContentIsNotCorrect() {
320 'TYPO3\\CMS\\Install\\FolderStructure\\FileNode',
321 array(
'getAbsolutePath',
'exists',
'isFile',
'isWritable',
'isPermissionCorrect',
'isContentCorrect'),
326 $path = PATH_site .
'typo3temp/' . $this->
getUniqueId(
'dir_');
328 $this->testNodesToDelete[] = $path;
329 $node->expects($this->any())->method(
'getAbsolutePath')->will($this->returnValue($path));
330 $node->expects($this->any())->method(
'exists')->will($this->returnValue(TRUE));
331 $node->expects($this->any())->method(
'isFile')->will($this->returnValue(TRUE));
332 $node->expects($this->any())->method(
'isPermissionCorrect')->will($this->returnValue(TRUE));
333 $node->expects($this->any())->method(
'isWritable')->will($this->returnValue(TRUE));
334 $node->expects($this->any())->method(
'isContentCorrect')->will($this->returnValue(FALSE));
335 $statusArray = $node->getStatus();
337 $status = $statusArray[0];
338 $this->assertInstanceOf(
'\TYPO3\CMS\Install\Status\NoticeStatus', $status);
344 public function getStatusReturnsArrayWithOkStatusIfFileExistsAndPermissionAreCorrect() {
347 'TYPO3\\CMS\\Install\\FolderStructure\\FileNode',
348 array(
'getAbsolutePath',
'exists',
'isFile',
'isWritable',
'isPermissionCorrect',
'isContentCorrect'),
353 $path = PATH_site .
'typo3temp/' . $this->
getUniqueId(
'dir_');
355 $this->testNodesToDelete[] = $path;
356 $node->expects($this->any())->method(
'getAbsolutePath')->will($this->returnValue($path));
357 $node->expects($this->any())->method(
'exists')->will($this->returnValue(TRUE));
358 $node->expects($this->any())->method(
'isFile')->will($this->returnValue(TRUE));
359 $node->expects($this->any())->method(
'isPermissionCorrect')->will($this->returnValue(TRUE));
360 $node->expects($this->any())->method(
'isWritable')->will($this->returnValue(TRUE));
361 $node->expects($this->any())->method(
'isContentCorrect')->will($this->returnValue(TRUE));
362 $statusArray = $node->getStatus();
364 $status = $statusArray[0];
365 $this->assertInstanceOf(
'\TYPO3\CMS\Install\Status\OkStatus', $status);
371 public function fixCallsFixSelfAndReturnsItsResult() {
374 'TYPO3\\CMS\\Install\\FolderStructure\\FileNode',
381 $node->expects($this->once())->method(
'fixSelf')->will($this->returnValue($uniqueReturn));
382 $this->assertSame($uniqueReturn, $node->fix());
388 public function fixSelfCallsCreateFileIfFileDoesNotExistAndReturnsResult() {
391 'TYPO3\\CMS\\Install\\FolderStructure\\FileNode',
392 array(
'exists',
'createFile',
'setContent',
'getAbsolutePath',
'isFile',
'isPermissionCorrect'),
397 $node->expects($this->any())->method(
'exists')->will($this->returnValue(FALSE));
398 $node->expects($this->any())->method(
'isFile')->will($this->returnValue(TRUE));
399 $node->expects($this->any())->method(
'isPermissionCorrect')->will($this->returnValue(TRUE));
401 $node->expects($this->once())->method(
'createFile')->will($this->returnValue($uniqueReturn));
402 $actualReturn = $node->_call(
'fixSelf');
403 $actualReturn = $actualReturn[0];
404 $this->assertSame($uniqueReturn, $actualReturn);
410 public function fixSelfCallsSetsContentIfFileCreationWasSuccessfulAndTargetContentIsNotNullAndReturnsResult() {
413 'TYPO3\\CMS\\Install\\FolderStructure\\FileNode',
414 array(
'exists',
'createFile',
'setContent',
'getAbsolutePath',
'isFile',
'isPermissionCorrect'),
419 $node->expects($this->any())->method(
'exists')->will($this->returnValue(FALSE));
420 $node->expects($this->any())->method(
'isFile')->will($this->returnValue(TRUE));
421 $node->expects($this->any())->method(
'isPermissionCorrect')->will($this->returnValue(TRUE));
423 $createFileStatus = $this->getMock(
'TYPO3\\CMS\\Install\\Status\\OkStatus', array(), array(),
'', FALSE);
424 $node->expects($this->any())->method(
'createFile')->will($this->returnValue($createFileStatus));
425 $node->_set(
'targetContent',
'foo');
426 $node->expects($this->once())->method(
'setContent')->will($this->returnValue($uniqueReturn));
427 $actualReturn = $node->_call(
'fixSelf');
428 $actualReturn = $actualReturn[1];
429 $this->assertSame($uniqueReturn, $actualReturn);
435 public function fixSelfDoesNotCallSetContentIfFileCreationFailed() {
438 'TYPO3\\CMS\\Install\\FolderStructure\\FileNode',
439 array(
'exists',
'createFile',
'setContent',
'getAbsolutePath',
'isFile',
'isPermissionCorrect'),
444 $node->expects($this->any())->method(
'exists')->will($this->returnValue(FALSE));
445 $node->expects($this->any())->method(
'isFile')->will($this->returnValue(TRUE));
446 $node->expects($this->any())->method(
'isPermissionCorrect')->will($this->returnValue(TRUE));
447 $createFileStatus = $this->getMock(
'TYPO3\\CMS\\Install\\Status\\ErrorStatus', array(), array(),
'', FALSE);
448 $node->expects($this->any())->method(
'createFile')->will($this->returnValue($createFileStatus));
449 $node->_set(
'targetContent',
'foo');
450 $node->expects($this->never())->method(
'setContent');
451 $node->_call(
'fixSelf');
457 public function fixSelfDoesNotCallSetContentIfFileTargetContentIsNull() {
460 'TYPO3\\CMS\\Install\\FolderStructure\\FileNode',
461 array(
'exists',
'createFile',
'setContent',
'getAbsolutePath',
'isFile',
'isPermissionCorrect'),
466 $node->expects($this->any())->method(
'exists')->will($this->returnValue(FALSE));
467 $node->expects($this->any())->method(
'isFile')->will($this->returnValue(TRUE));
468 $node->expects($this->any())->method(
'isPermissionCorrect')->will($this->returnValue(TRUE));
469 $createFileStatus = $this->getMock(
'TYPO3\\CMS\\Install\\Status\\OkStatus', array(), array(),
'', FALSE);
470 $node->expects($this->any())->method(
'createFile')->will($this->returnValue($createFileStatus));
471 $node->_set(
'targetContent', NULL);
472 $node->expects($this->never())->method(
'setContent');
473 $node->_call(
'fixSelf');
479 public function fixSelfReturnsErrorStatusIfNodeExistsButIsNotAFileAndReturnsResult() {
482 'TYPO3\\CMS\\Install\\FolderStructure\\FileNode',
483 array(
'exists',
'createFile',
'getAbsolutePath',
'isFile',
'isPermissionCorrect',
'fixPermission'),
488 $node->expects($this->any())->method(
'exists')->will($this->returnValue(TRUE));
489 $node->expects($this->any())->method(
'isFile')->will($this->returnValue(TRUE));
490 $node->expects($this->any())->method(
'isPermissionCorrect')->will($this->returnValue(FALSE));
492 $node->expects($this->once())->method(
'fixPermission')->will($this->returnValue($uniqueReturn));
493 $this->assertSame(array($uniqueReturn), $node->_call(
'fixSelf'));
499 public function fixSelfCallsFixPermissionIfFileExistsButPermissionAreWrong() {
502 'TYPO3\\CMS\\Install\\FolderStructure\\FileNode',
503 array(
'exists',
'createFile',
'getAbsolutePath',
'isFile',
'isPermissionCorrect',
'getRelativePathBelowSiteRoot'),
508 $node->expects($this->any())->method(
'exists')->will($this->returnValue(TRUE));
509 $node->expects($this->once())->method(
'isFile')->will($this->returnValue(FALSE));
510 $node->expects($this->any())->method(
'isPermissionCorrect')->will($this->returnValue(TRUE));
511 $resultArray = $node->_call(
'fixSelf');
512 $this->assertInstanceOf(
'TYPO3\\CMS\Install\\Status\\StatusInterface', $resultArray[0]);
520 'TYPO3\\CMS\\Install\\FolderStructure\\FileNode',
521 array(
'exists',
'isFile',
'isPermissionCorrect'),
526 $node->expects($this->any())->method(
'exists')->will($this->returnValue(TRUE));
527 $node->expects($this->any())->method(
'isFile')->will($this->returnValue(TRUE));
528 $node->expects($this->any())->method(
'isPermissionCorrect')->will($this->returnValue(TRUE));
529 $this->assertInternalType(
'array', $node->_call(
'fixSelf'));
536 public function createFileThrowsExceptionIfNodeExists() {
538 $node = $this->
getAccessibleMock(
'TYPO3\\CMS\\Install\\FolderStructure\\FileNode', array(
'exists',
'getAbsolutePath'), array(),
'', FALSE);
539 $node->expects($this->once())->method(
'getAbsolutePath')->will($this->returnValue(
''));
540 $node->expects($this->once())->method(
'exists')->will($this->returnValue(TRUE));
541 $node->_call(
'createFile');
547 public function createFileReturnsOkStatusIfFileWasCreated() {
549 $node = $this->
getAccessibleMock(
'TYPO3\\CMS\\Install\\FolderStructure\\FileNode', array(
'exists',
'getAbsolutePath'), array(),
'', FALSE);
550 $path = PATH_site .
'typo3temp/' . $this->
getUniqueId(
'file_');
551 $this->testNodesToDelete[] = $path;
552 $node->expects($this->once())->method(
'exists')->will($this->returnValue(FALSE));
553 $node->expects($this->any())->method(
'getAbsolutePath')->will($this->returnValue($path));
554 $this->assertInstanceOf(
'TYPO3\\CMS\Install\\Status\\StatusInterface', $node->_call(
'createFile'));
560 public function createFileCreatesFile() {
562 $node = $this->
getAccessibleMock(
'TYPO3\\CMS\\Install\\FolderStructure\\FileNode', array(
'exists',
'getAbsolutePath'), array(),
'', FALSE);
563 $path = PATH_site .
'typo3temp/' . $this->
getUniqueId(
'file_');
564 $this->testNodesToDelete[] = $path;
565 $node->expects($this->once())->method(
'exists')->will($this->returnValue(FALSE));
566 $node->expects($this->any())->method(
'getAbsolutePath')->will($this->returnValue($path));
567 $node->_call(
'createFile');
568 $this->assertTrue(is_file($path));
574 public function createFileReturnsErrorStatusIfFileWasNotCreated() {
575 if (TYPO3_OS ===
'WIN') {
576 $this->markTestSkipped(
'Test not available on Windows OS.');
579 $node = $this->
getAccessibleMock(
'TYPO3\\CMS\\Install\\FolderStructure\\FileNode', array(
'exists',
'getAbsolutePath'), array(),
'', FALSE);
580 $path = PATH_site .
'typo3temp/' . $this->
getUniqueId(
'root_');
583 $subPath = $path .
'/' . $this->
getUniqueId(
'file_');
584 $this->testNodesToDelete[] = $path;
585 $node->expects($this->once())->method(
'exists')->will($this->returnValue(FALSE));
586 $node->expects($this->any())->method(
'getAbsolutePath')->will($this->returnValue($subPath));
587 $this->assertInstanceOf(
'TYPO3\\CMS\Install\\Status\\StatusInterface', $node->_call(
'createFile'));
594 public function isContentCorrectThrowsExceptionIfTargetIsNotAFile() {
596 $node = $this->
getAccessibleMock(
'TYPO3\\CMS\\Install\\FolderStructure\\FileNode', array(
'getAbsolutePath'), array(),
'', FALSE);
597 $path = PATH_site .
'typo3temp/' . $this->
getUniqueId(
'dir_');
599 $this->testNodesToDelete[] = $path;
600 $node->expects($this->any())->method(
'getAbsolutePath')->will($this->returnValue($path));
601 $node->_call(
'isContentCorrect');
607 public function isContentCorrectReturnsTrueIfTargetContentPropertyIsNull() {
609 $node = $this->
getAccessibleMock(
'TYPO3\\CMS\\Install\\FolderStructure\\FileNode', array(
'getAbsolutePath'), array(),
'', FALSE);
610 $path = PATH_site .
'typo3temp/' . $this->
getUniqueId(
'file_');
612 $this->testNodesToDelete[] = $path;
613 $node->expects($this->any())->method(
'getAbsolutePath')->will($this->returnValue($path));
614 $node->_set(
'targetContent', NULL);
615 $this->assertTrue($node->_call(
'isContentCorrect'));
621 public function isContentCorrectReturnsTrueIfTargetContentEqualsCurrentContent() {
623 $node = $this->
getAccessibleMock(
'TYPO3\\CMS\\Install\\FolderStructure\\FileNode', array(
'getAbsolutePath'), array(),
'', FALSE);
624 $path = PATH_site .
'typo3temp/' . $this->
getUniqueId(
'file_');
626 file_put_contents($path, $content);
627 $this->testNodesToDelete[] = $path;
628 $node->expects($this->any())->method(
'getAbsolutePath')->will($this->returnValue($path));
629 $node->_set(
'targetContent', $content);
630 $this->assertTrue($node->_call(
'isContentCorrect'));
636 public function isContentCorrectReturnsFalseIfTargetContentNotEqualsCurrentContent() {
638 $node = $this->
getAccessibleMock(
'TYPO3\\CMS\\Install\\FolderStructure\\FileNode', array(
'getAbsolutePath'), array(),
'', FALSE);
639 $path = PATH_site .
'typo3temp/' . $this->
getUniqueId(
'file_');
642 file_put_contents($path, $content);
643 $this->testNodesToDelete[] = $path;
644 $node->expects($this->any())->method(
'getAbsolutePath')->will($this->returnValue($path));
645 $node->_set(
'targetContent', $targetContent);
646 $this->assertFalse($node->_call(
'isContentCorrect'));
652 public function isPermissionCorrectReturnsTrueIfTargetPermissionAndCurrentPermissionAreIdentical() {
653 $parent = $this->getMock(
'TYPO3\CMS\Install\FolderStructure\NodeInterface', array(), array(),
'', FALSE);
655 $node = $this->
getAccessibleMock(
'TYPO3\\CMS\\Install\\FolderStructure\\FileNode', array(
'getCurrentPermission',
'isWindowsOs'), array(),
'', FALSE);
656 $node->expects($this->any())->method(
'isWindowsOs')->will($this->returnValue(FALSE));
657 $node->expects($this->any())->method(
'getCurrentPermission')->will($this->returnValue(
'0664'));
658 $targetPermission =
'0664';
661 'targetPermission' => $targetPermission,
663 $node->__construct($structure, $parent);
664 $this->assertTrue($node->_call(
'isPermissionCorrect'));
671 public function setContentThrowsExceptionIfTargetIsNotAFile() {
673 $node = $this->
getAccessibleMock(
'TYPO3\\CMS\\Install\\FolderStructure\\FileNode', array(
'getAbsolutePath'), array(),
'', FALSE);
674 $path = PATH_site .
'typo3temp/' . $this->
getUniqueId(
'dir_');
676 $this->testNodesToDelete[] = $path;
677 $node->expects($this->any())->method(
'getAbsolutePath')->will($this->returnValue($path));
678 $node->_set(
'targetContent',
'foo');
679 $node->_call(
'setContent');
686 public function setContentThrowsExceptionIfTargetContentIsNull() {
688 $node = $this->
getAccessibleMock(
'TYPO3\\CMS\\Install\\FolderStructure\\FileNode', array(
'getAbsolutePath'), array(),
'', FALSE);
689 $path = PATH_site .
'typo3temp/' . $this->
getUniqueId(
'file_');
691 $this->testNodesToDelete[] = $path;
692 $node->expects($this->any())->method(
'getAbsolutePath')->will($this->returnValue($path));
693 $node->_set(
'targetContent', NULL);
694 $node->_call(
'setContent');
700 public function setContentSetsContentToFile() {
702 $node = $this->
getAccessibleMock(
'TYPO3\\CMS\\Install\\FolderStructure\\FileNode', array(
'getAbsolutePath',
'getRelativePathBelowSiteRoot'), array(),
'', FALSE);
703 $path = PATH_site .
'typo3temp/' . $this->
getUniqueId(
'file_');
705 $this->testNodesToDelete[] = $path;
706 $node->expects($this->any())->method(
'getAbsolutePath')->will($this->returnValue($path));
708 $node->_set(
'targetContent', $targetContent);
709 $node->_call(
'setContent');
710 $resultContent = file_get_contents($path);
711 $this->assertSame($targetContent, $resultContent);
717 public function setContentReturnsOkStatusIfContentWasSuccessfullySet() {
719 $node = $this->
getAccessibleMock(
'TYPO3\\CMS\\Install\\FolderStructure\\FileNode', array(
'getAbsolutePath',
'getRelativePathBelowSiteRoot'), array(),
'', FALSE);
720 $path = PATH_site .
'typo3temp/' . $this->
getUniqueId(
'file_');
722 $this->testNodesToDelete[] = $path;
723 $node->expects($this->any())->method(
'getAbsolutePath')->will($this->returnValue($path));
725 $node->_set(
'targetContent', $targetContent);
726 $this->assertInstanceOf(
'TYPO3\\CMS\\Install\\Status\\OkStatus', $node->_call(
'setContent'));
732 public function setContentReturnsErrorStatusIfContentCanNotBeSetSet() {
733 if (TYPO3_OS ===
'WIN') {
734 $this->markTestSkipped(
'Test not available on Windows OS.');
736 if (function_exists(
'posix_getegid') && posix_getegid() === 0) {
737 $this->markTestSkipped(
'Test skipped if run on linux as root');
740 $node = $this->
getAccessibleMock(
'TYPO3\\CMS\\Install\\FolderStructure\\FileNode', array(
'getAbsolutePath',
'getRelativePathBelowSiteRoot'), array(),
'', FALSE);
741 $dir = PATH_site .
'typo3temp/' . $this->
getUniqueId(
'dir_');
746 $this->testNodesToDelete[] = $dir;
747 $node->expects($this->any())->method(
'getAbsolutePath')->will($this->returnValue($file));
749 $node->_set(
'targetContent', $targetContent);
750 $this->assertInstanceOf(
'TYPO3\\CMS\\Install\\Status\\ErrorStatus', $node->_call(
'setContent'));
756 public function isFileReturnsTrueIfNameIsFile() {
758 $node = $this->
getAccessibleMock(
'TYPO3\\CMS\\Install\\FolderStructure\\FileNode', array(
'getAbsolutePath'), array(),
'', FALSE);
759 $path = PATH_site .
'typo3temp/' . $this->
getUniqueId(
'file_');
761 $this->testNodesToDelete[] = $path;
762 $node->expects($this->any())->method(
'getAbsolutePath')->will($this->returnValue($path));
763 $this->assertTrue($node->_call(
'isFile'));
769 public function isFileReturnsFalseIfNameIsALinkFile() {
770 if (TYPO3_OS ===
'WIN') {
771 $this->markTestSkipped(
'Test not available on Windows OS.');
774 $node = $this->
getAccessibleMock(
'TYPO3\\CMS\\Install\\FolderStructure\\FileNode', array(
'getAbsolutePath'), array(),
'', FALSE);
775 $path = PATH_site .
'typo3temp/' . $this->
getUniqueId(
'root_');
777 $this->testNodesToDelete[] = $path;
780 touch($path .
'/' . $file);
781 symlink($path .
'/' . $file, $path .
'/' . $link);
782 $node->expects($this->any())->method(
'getAbsolutePath')->will($this->returnValue($path .
'/' . $link));
783 $this->assertFalse($node->_call(
'isFile'));
static mkdir_deep($directory, $deepDirectory='')
static rmdir($path, $removeNonEmpty=FALSE)
fixSelfReturnsArrayOfStatusMessages()
getAccessibleMock( $originalClassName, array $methods=array(), array $arguments=array(), $mockClassName='', $callOriginalConstructor=TRUE, $callOriginalClone=TRUE, $callAutoload=TRUE)