2 namespace TYPO3\CMS\Install\Tests\Unit\FolderStructure;
26 public function constructorThrowsExceptionIfParentIsNull()
29 $node = $this->getAccessibleMock(\TYPO3\CMS\Install\FolderStructure\LinkNode::class, array(
'dummy'), array(),
'',
false);
30 $node->__construct(array(), null);
37 public function constructorThrowsExceptionIfNameContainsForwardSlash()
39 $parent = $this->getMock(\TYPO3\CMS\Install\FolderStructure\NodeInterface::class, array(), array(),
'',
false);
41 $node = $this->getAccessibleMock(\TYPO3\CMS\Install\FolderStructure\LinkNode::class, array(
'dummy'), array(),
'',
false);
45 $node->__construct($structure, $parent);
51 public function constructorSetsParent()
53 $parent = $this->getMock(\TYPO3\CMS\Install\FolderStructure\NodeInterface::class, array(), array(),
'',
false);
55 $node = $this->getAccessibleMock(\TYPO3\CMS\Install\FolderStructure\LinkNode::class, array(
'dummy'), array(),
'',
false);
59 $node->__construct($structure, $parent);
60 $this->assertSame($parent, $node->_call(
'getParent'));
66 public function constructorSetsName()
69 $node = $this->getAccessibleMock(\TYPO3\CMS\Install\FolderStructure\LinkNode::class, array(
'dummy'), array(),
'',
false);
70 $parent = $this->getMock(\TYPO3\CMS\Install\FolderStructure\RootNodeInterface::class, array(), array(),
'',
false);
71 $name = $this->getUniqueId(
'test_');
72 $node->__construct(array(
'name' => $name), $parent);
73 $this->assertSame($name, $node->getName());
79 public function constructorSetsTarget()
82 $node = $this->getAccessibleMock(\TYPO3\CMS\Install\FolderStructure\LinkNode::class, array(
'dummy'), array(),
'',
false);
83 $parent = $this->getMock(\TYPO3\CMS\Install\FolderStructure\RootNodeInterface::class, array(), array(),
'',
false);
84 $target =
'../' . $this->getUniqueId(
'test_');
85 $node->__construct(array(
'target' => $target), $parent);
86 $this->assertSame($target, $node->_call(
'getTarget'));
92 public function getStatusReturnsArray()
95 $node = $this->getAccessibleMock(
96 \TYPO3\CMS\Install\FolderStructure\LinkNode::class,
97 array(
'isWindowsOs',
'getAbsolutePath',
'exists'),
102 $path = PATH_site .
'typo3temp/' . $this->getUniqueId(
'dir_');
103 $node->expects($this->any())->method(
'getAbsolutePath')->will($this->returnValue($path));
104 $this->assertInternalType(
'array', $node->getStatus());
110 public function getStatusReturnsArrayWithInformationStatusIfRunningOnWindows()
113 $node = $this->getAccessibleMock(
114 \TYPO3\CMS\Install\FolderStructure\LinkNode::class,
115 array(
'isWindowsOs',
'getAbsolutePath',
'exists'),
120 $path = PATH_site .
'typo3temp/' . $this->getUniqueId(
'dir_');
121 $node->expects($this->any())->method(
'getAbsolutePath')->will($this->returnValue($path));
122 $node->expects($this->once())->method(
'isWindowsOs')->will($this->returnValue(
true));
123 $statusArray = $node->getStatus();
125 $status = $statusArray[0];
126 $this->assertInstanceOf(\TYPO3\CMS\Install\Status\InfoStatus::class, $status);
132 public function getStatusReturnsArrayWithErrorStatusIfLinkNotExists()
135 $node = $this->getAccessibleMock(
136 \TYPO3\CMS\Install\FolderStructure\LinkNode::class,
137 array(
'isWindowsOs',
'getAbsolutePath',
'exists'),
142 $path = PATH_site .
'typo3temp/' . $this->getUniqueId(
'dir_');
143 $node->expects($this->any())->method(
'getAbsolutePath')->will($this->returnValue($path));
144 $node->expects($this->any())->method(
'isWindowsOs')->will($this->returnValue(
false));
145 $node->expects($this->once())->method(
'exists')->will($this->returnValue(
false));
146 $statusArray = $node->getStatus();
148 $status = $statusArray[0];
149 $this->assertInstanceOf(\TYPO3\CMS\Install\Status\ErrorStatus::class, $status);
155 public function getStatusReturnsArrayWithWarningStatusIfNodeIsNotALink()
158 $node = $this->getAccessibleMock(
159 \TYPO3\CMS\Install\FolderStructure\LinkNode::class,
160 array(
'isWindowsOs',
'getAbsolutePath',
'exists',
'isLink',
'getRelativePathBelowSiteRoot'),
165 $node->expects($this->any())->method(
'getAbsolutePath')->will($this->returnValue($path));
166 $node->expects($this->any())->method(
'exists')->will($this->returnValue(
true));
167 $node->expects($this->once())->method(
'isLink')->will($this->returnValue(
false));
168 $statusArray = $node->getStatus();
170 $status = $statusArray[0];
171 $this->assertInstanceOf(\TYPO3\CMS\Install\Status\WarningStatus::class, $status);
177 public function getStatusReturnsErrorStatusIfLinkTargetIsNotCorrect()
180 $node = $this->getAccessibleMock(
181 \TYPO3\CMS\Install\FolderStructure\LinkNode::class,
182 array(
'isWindowsOs',
'getAbsolutePath',
'exists',
'isLink',
'isTargetCorrect',
'getCurrentTarget',
'getRelativePathBelowSiteRoot'),
187 $node->expects($this->any())->method(
'getAbsolutePath')->will($this->returnValue($path));
188 $node->expects($this->any())->method(
'getCurrentTarget')->will($this->returnValue(
''));
189 $node->expects($this->any())->method(
'exists')->will($this->returnValue(
true));
190 $node->expects($this->any())->method(
'isLink')->will($this->returnValue(
true));
191 $node->expects($this->once())->method(
'isLink')->will($this->returnValue(
false));
192 $statusArray = $node->getStatus();
194 $status = $statusArray[0];
195 $this->assertInstanceOf(\TYPO3\CMS\Install\Status\ErrorStatus::class, $status);
201 public function getStatusReturnsOkStatusIfLinkExistsAndTargetIsCorrect()
204 $node = $this->getAccessibleMock(
205 \TYPO3\CMS\Install\FolderStructure\LinkNode::class,
206 array(
'isWindowsOs',
'getAbsolutePath',
'exists',
'isLink',
'isTargetCorrect',
'getRelativePathBelowSiteRoot'),
211 $node->expects($this->any())->method(
'getAbsolutePath')->will($this->returnValue($path));
212 $node->expects($this->any())->method(
'exists')->will($this->returnValue(
true));
213 $node->expects($this->once())->method(
'isLink')->will($this->returnValue(
true));
214 $node->expects($this->once())->method(
'isTargetCorrect')->will($this->returnValue(
true));
215 $statusArray = $node->getStatus();
217 $status = $statusArray[0];
218 $this->assertInstanceOf(\TYPO3\CMS\Install\Status\OkStatus::class, $status);
224 public function fixReturnsEmptyArray()
227 $node = $this->getAccessibleMock(
228 \TYPO3\CMS\Install\FolderStructure\LinkNode::class,
229 array(
'getRelativePathBelowSiteRoot'),
234 $statusArray = $node->fix();
235 $this->assertEmpty($statusArray);
242 public function isLinkThrowsExceptionIfLinkNotExists()
245 $node = $this->getAccessibleMock(\TYPO3\CMS\Install\FolderStructure\LinkNode::class, array(
'exists'), array(),
'',
false);
246 $node->expects($this->once())->method(
'exists')->will($this->returnValue(
false));
247 $this->assertFalse($node->_call(
'isLink'));
253 public function isLinkReturnsTrueIfNameIsLink()
255 if (TYPO3_OS ===
'WIN') {
256 $this->markTestSkipped(
'Test not available on Windows OS.');
259 $node = $this->getAccessibleMock(\TYPO3\CMS\Install\FolderStructure\LinkNode::class, array(
'exists',
'getAbsolutePath'), array(),
'',
false);
260 $path = PATH_site .
'typo3temp/' . $this->getUniqueId(
'link_');
261 $target = PATH_site . $this->getUniqueId(
'linkTarget_');
262 symlink($target, $path);
263 $this->testFilesToDelete[] = $path;
264 $node->expects($this->any())->method(
'exists')->will($this->returnValue(
true));
265 $node->expects($this->any())->method(
'getAbsolutePath')->will($this->returnValue($path));
266 $this->assertTrue($node->_call(
'isLink'));
272 public function isFileReturnsFalseIfNameIsAFile()
274 if (TYPO3_OS ===
'WIN') {
275 $this->markTestSkipped(
'Test not available on Windows OS.');
278 $node = $this->getAccessibleMock(\TYPO3\CMS\Install\FolderStructure\LinkNode::class, array(
'exists',
'getAbsolutePath'), array(),
'',
false);
279 $path = PATH_site .
'typo3temp/' . $this->getUniqueId(
'file_');
281 $this->testFilesToDelete[] = $path;
282 $node->expects($this->any())->method(
'exists')->will($this->returnValue(
true));
283 $node->expects($this->any())->method(
'getAbsolutePath')->will($this->returnValue($path));
284 $this->assertFalse($node->_call(
'isLink'));
291 public function isTargetCorrectThrowsExceptionIfLinkNotExists()
294 $node = $this->getAccessibleMock(\TYPO3\CMS\Install\FolderStructure\LinkNode::class, array(
'exists'), array(),
'',
false);
295 $node->expects($this->once())->method(
'exists')->will($this->returnValue(
false));
296 $this->assertFalse($node->_call(
'isTargetCorrect'));
303 public function isTargetCorrectThrowsExceptionIfNodeIsNotALink()
306 $node = $this->getAccessibleMock(\TYPO3\CMS\Install\FolderStructure\LinkNode::class, 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()
318 $node = $this->getAccessibleMock(\TYPO3\CMS\Install\FolderStructure\LinkNode::class, array(
'exists',
'isLink',
'getTarget'), array(),
'',
false);
319 $node->expects($this->any())->method(
'exists')->will($this->returnValue(
true));
320 $node->expects($this->any())->method(
'isLink')->will($this->returnValue(
true));
321 $node->expects($this->once())->method(
'getTarget')->will($this->returnValue(
''));
322 $this->assertTrue($node->_call(
'isTargetCorrect'));
328 public function isTargetCorrectAcceptsATargetWithATrailingSlash()
331 $node = $this->getAccessibleMock(\TYPO3\CMS\Install\FolderStructure\LinkNode::class, array(
'exists',
'isLink',
'getCurrentTarget',
'getTarget'), array(),
'',
false);
332 $node->expects($this->any())->method(
'exists')->will($this->returnValue(
true));
333 $node->expects($this->any())->method(
'isLink')->will($this->returnValue(
true));
334 $node->expects($this->once())->method(
'getCurrentTarget')->will($this->returnValue(
'someLinkTarget/'));
335 $node->expects($this->once())->method(
'getTarget')->will($this->returnValue(
'someLinkTarget'));
336 $this->assertTrue($node->_call(
'isTargetCorrect'));
343 public function isTargetCorrectReturnsTrueIfActualTargetIsIdenticalToSpecifiedTarget()
345 if (TYPO3_OS ===
'WIN') {
346 $this->markTestSkipped(
'Test not available on Windows OS.');
348 $path = PATH_site .
'typo3temp/' . $this->getUniqueId(
'link_');
349 $target = $this->getUniqueId(
'linkTarget_');
350 symlink($target, $path);
351 $this->testFilesToDelete[] = $path;
353 $node = $this->getAccessibleMock(\TYPO3\CMS\Install\FolderStructure\LinkNode::class,
354 array(
'exists',
'isLink',
'getTarget',
'getAbsolutePath'),
359 $node->expects($this->any())->method(
'exists')->will($this->returnValue(
true));
360 $node->expects($this->any())->method(
'isLink')->will($this->returnValue(
true));
361 $node->expects($this->once())->method(
'getTarget')->will($this->returnValue($target));
362 $node->expects($this->once())->method(
'getAbsolutePath')->will($this->returnValue($path));
363 $this->assertTrue($node->_call(
'isTargetCorrect'));
370 public function isTargetCorrectReturnsFalseIfActualTargetIsNotIdenticalToSpecifiedTarget()
372 if (TYPO3_OS ===
'WIN') {
373 $this->markTestSkipped(
'Test not available on Windows OS.');
375 $path = PATH_site .
'typo3temp/' . $this->getUniqueId(
'link_');
376 $target = $this->getUniqueId(
'linkTarget_');
377 symlink($target, $path);
378 $this->testFilesToDelete[] = $path;
380 $node = $this->getAccessibleMock(\TYPO3\CMS\Install\FolderStructure\LinkNode::class,
381 array(
'exists',
'isLink',
'getTarget',
'getAbsolutePath'),
386 $node->expects($this->any())->method(
'exists')->will($this->returnValue(
true));
387 $node->expects($this->any())->method(
'isLink')->will($this->returnValue(
true));
388 $node->expects($this->once())->method(
'getTarget')->will($this->returnValue(
'foo'));
389 $node->expects($this->once())->method(
'getAbsolutePath')->will($this->returnValue($path));
390 $this->assertFalse($node->_call(
'isTargetCorrect'));