2 namespace TYPO3\CMS\Install\Tests\Unit\FolderStructure;
26 public function constructorThrowsExceptionIfParentIsNotNull()
29 $node = $this->getAccessibleMock(\TYPO3\CMS\Install\FolderStructure\RootNode::class, array(
'isWindowsOs'), array(),
'',
false);
30 $falseParent = $this->getMock(
31 \TYPO3\CMS\Install\FolderStructure\RootNodeInterface::class,
37 $node->__construct(array(), $falseParent);
44 public function constructorThrowsExceptionIfAbsolutePathIsNotSet()
47 $node = $this->getAccessibleMock(\TYPO3\CMS\Install\FolderStructure\RootNode::class, array(
'isWindowsOs'), array(),
'',
false);
51 $node->__construct($structure, null);
58 public function constructorThrowsExceptionIfAbsolutePathIsNotAbsoluteOnWindows()
61 $node = $this->getAccessibleMock(\TYPO3\CMS\Install\FolderStructure\RootNode::class, array(
'isWindowsOs'), array(),
'',
false);
63 ->expects($this->any())
64 ->method(
'isWindowsOs')
65 ->will($this->returnValue(
true));
69 $node->__construct($structure, null);
76 public function constructorThrowsExceptionIfAbsolutePathIsNotAbsoluteOnUnix()
79 $node = $this->getAccessibleMock(\TYPO3\CMS\Install\FolderStructure\RootNode::class, array(
'isWindowsOs'), array(),
'',
false);
81 ->expects($this->any())
82 ->method(
'isWindowsOs')
83 ->will($this->returnValue(
false));
87 $node->__construct($structure, null);
93 public function constructorSetsParentToNull()
96 $node = $this->getAccessibleMock(\TYPO3\CMS\Install\FolderStructure\RootNode::class, array(
'isWindowsOs'), array(),
'',
false);
98 ->expects($this->any())
99 ->method(
'isWindowsOs')
100 ->will($this->returnValue(
false));
104 $node->__construct($structure, null);
105 $this->assertNull($node->_call(
'getParent'));
111 public function getChildrenReturnsChildCreatedByConstructor()
114 $node = $this->getAccessibleMock(\TYPO3\CMS\Install\FolderStructure\RootNode::class, array(
'isWindowsOs'), array(),
'',
false);
116 ->expects($this->any())
117 ->method(
'isWindowsOs')
118 ->will($this->returnValue(
false));
119 $childName = $this->getUniqueId(
'test_');
124 'type' => \TYPO3\CMS\Install\FolderStructure\DirectoryNode::class,
125 'name' => $childName,
129 $node->__construct($structure, null);
130 $children = $node->_call(
'getChildren');
132 $child = $children[0];
133 $this->assertInstanceOf(\TYPO3\CMS\Install\FolderStructure\DirectoryNode::class, $child);
134 $this->assertSame($childName, $child->getName());
140 public function constructorSetsTargetPermission()
143 $node = $this->getAccessibleMock(\TYPO3\CMS\Install\FolderStructure\RootNode::class, array(
'isWindowsOs'), array(),
'',
false);
145 ->expects($this->any())
146 ->method(
'isWindowsOs')
147 ->will($this->returnValue(
false));
148 $targetPermission =
'2550';
151 'targetPermission' => $targetPermission,
153 $node->__construct($structure, null);
154 $this->assertSame($targetPermission, $node->_call(
'getTargetPermission'));
160 public function constructorSetsName()
163 $node = $this->getAccessibleMock(\TYPO3\CMS\Install\FolderStructure\RootNode::class, array(
'isWindowsOs'), array(),
'',
false);
165 ->expects($this->any())
166 ->method(
'isWindowsOs')
167 ->will($this->returnValue(
false));
168 $name =
'/' . $this->getUniqueId(
'test_');
169 $node->__construct(array(
'name' => $name), null);
170 $this->assertSame($name, $node->getName());
176 public function getStatusReturnsArrayWithOkStatusAndCallsOwnStatusMethods()
179 $node = $this->getAccessibleMock(
180 \TYPO3\CMS\Install\FolderStructure\RootNode::class,
181 array(
'getAbsolutePath',
'exists',
'isDirectory',
'isWritable',
'isPermissionCorrect'),
186 $path = PATH_site .
'typo3temp/' . $this->getUniqueId(
'dir_');
188 $this->testFilesToDelete[] = $path;
189 $node->expects($this->any())->method(
'getAbsolutePath')->will($this->returnValue($path));
190 $node->expects($this->once())->method(
'exists')->will($this->returnValue(
true));
191 $node->expects($this->once())->method(
'isDirectory')->will($this->returnValue(
true));
192 $node->expects($this->once())->method(
'isPermissionCorrect')->will($this->returnValue(
true));
193 $node->expects($this->once())->method(
'isWritable')->will($this->returnValue(
true));
194 $statusArray = $node->getStatus();
196 $status = $statusArray[0];
197 $this->assertInstanceOf(\TYPO3\CMS\Install\Status\OkStatus::class, $status);
203 public function getStatusCallsGetChildrenStatusForStatus()
206 $node = $this->getAccessibleMock(
207 \TYPO3\CMS\Install\FolderStructure\RootNode::class,
208 array(
'getAbsolutePath',
'exists',
'isDirectory',
'isWritable',
'isPermissionCorrect',
'getChildrenStatus'),
213 $path = PATH_site .
'typo3temp/' . $this->getUniqueId(
'dir_');
215 $this->testFilesToDelete[] = $path;
216 $node->expects($this->any())->method(
'getAbsolutePath')->will($this->returnValue($path));
217 $node->expects($this->any())->method(
'exists')->will($this->returnValue(
true));
218 $node->expects($this->any())->method(
'isDirectory')->will($this->returnValue(
true));
219 $node->expects($this->any())->method(
'isPermissionCorrect')->will($this->returnValue(
true));
220 $node->expects($this->any())->method(
'isWritable')->will($this->returnValue(
true));
221 $childStatusMock = $this->getMock(\TYPO3\CMS\Install\Status\ErrorStatus::class, array(), array(),
'',
false);
222 $node->expects($this->once())->method(
'getChildrenStatus')->will($this->returnValue(array($childStatusMock)));
223 $statusArray = $node->getStatus();
225 $statusSelf = $statusArray[0];
226 $statusOfChild = $statusArray[1];
227 $this->assertInstanceOf(\TYPO3\CMS\Install\Status\OkStatus::class, $statusSelf);
228 $this->assertInstanceOf(\TYPO3\CMS\Install\Status\ErrorStatus::class, $statusOfChild);
234 public function getAbsolutePathReturnsGivenName()
237 $node = $this->getAccessibleMock(\TYPO3\CMS\Install\FolderStructure\RootNode::class, array(
'isWindowsOs'), array(),
'',
false);
239 ->expects($this->any())
240 ->method(
'isWindowsOs')
241 ->will($this->returnValue(
false));
246 $node->__construct($structure, null);
247 $this->assertSame($path, $node->getAbsolutePath());