TYPO3 CMS  TYPO3_7-6
DirectoryNodeTest.php
Go to the documentation of this file.
1 <?php
3 
4 /*
5  * This file is part of the TYPO3 CMS project.
6  *
7  * It is free software; you can redistribute it and/or modify it under
8  * the terms of the GNU General Public License, either version 2
9  * of the License, or any later version.
10  *
11  * For the full copyright and license information, please read the
12  * LICENSE.txt file that was distributed with this source code.
13  *
14  * The TYPO3 project - inspiring people to share!
15  */
16 
21 {
26  public function constructorThrowsExceptionIfParentIsNull()
27  {
29  $node = $this->getAccessibleMock(\TYPO3\CMS\Install\FolderStructure\DirectoryNode::class, ['dummy'], [], '', false);
30  $node->__construct([], null);
31  }
32 
37  public function constructorThrowsExceptionIfNameContainsForwardSlash()
38  {
39  $parent = $this->getMock(\TYPO3\CMS\Install\FolderStructure\NodeInterface::class, [], [], '', false);
41  $node = $this->getAccessibleMock(\TYPO3\CMS\Install\FolderStructure\DirectoryNode::class, ['dummy'], [], '', false);
42  $structure = [
43  'name' => 'foo/bar',
44  ];
45  $node->__construct($structure, $parent);
46  }
47 
51  public function constructorCallsCreateChildrenIfChildrenAreSet()
52  {
53  $parent = $this->getMock(\TYPO3\CMS\Install\FolderStructure\NodeInterface::class, [], [], '', false);
55  $node = $this->getAccessibleMock(
56  \TYPO3\CMS\Install\FolderStructure\DirectoryNode::class,
57  ['createChildren'],
58  [],
59  '',
60  false
61  );
62  $childArray = [
63  'foo',
64  ];
65  $structure = [
66  'name' => 'foo',
67  'children' => $childArray,
68  ];
69  $node->expects($this->once())->method('createChildren')->with($childArray);
70  $node->__construct($structure, $parent);
71  }
72 
76  public function constructorSetsParent()
77  {
78  $parent = $this->getMock(\TYPO3\CMS\Install\FolderStructure\NodeInterface::class, [], [], '', false);
80  $node = $this->getAccessibleMock(\TYPO3\CMS\Install\FolderStructure\DirectoryNode::class, ['dummy'], [], '', false);
81  $structure = [
82  'name' => 'foo',
83  ];
84  $node->__construct($structure, $parent);
85  $this->assertSame($parent, $node->_call('getParent'));
86  }
87 
91  public function constructorSetsTargetPermission()
92  {
93  $parent = $this->getMock(\TYPO3\CMS\Install\FolderStructure\NodeInterface::class, [], [], '', false);
95  $node = $this->getAccessibleMock(\TYPO3\CMS\Install\FolderStructure\DirectoryNode::class, ['dummy'], [], '', false);
96  $targetPermission = '2550';
97  $structure = [
98  'name' => 'foo',
99  'targetPermission' => $targetPermission,
100  ];
101  $node->__construct($structure, $parent);
102  $this->assertSame($targetPermission, $node->_call('getTargetPermission'));
103  }
104 
108  public function constructorSetsName()
109  {
111  $node = $this->getAccessibleMock(\TYPO3\CMS\Install\FolderStructure\DirectoryNode::class, ['dummy'], [], '', false);
112  $parent = $this->getMock(\TYPO3\CMS\Install\FolderStructure\RootNodeInterface::class, [], [], '', false);
113  $name = $this->getUniqueId('test_');
114  $node->__construct(['name' => $name], $parent);
115  $this->assertSame($name, $node->getName());
116  }
117 
121  public function getStatusReturnsArray()
122  {
124  $node = $this->getAccessibleMock(
125  \TYPO3\CMS\Install\FolderStructure\DirectoryNode::class,
126  ['getAbsolutePath', 'getRelativePathBelowSiteRoot', 'exists', 'isDirectory', 'isWritable', 'isPermissionCorrect'],
127  [],
128  '',
129  false
130  );
131  $path = $this->getVirtualTestDir('dir_');
132  $node->expects($this->any())->method('getAbsolutePath')->will($this->returnValue($path));
133  $node->expects($this->any())->method('getRelativePathBelowSiteRoot')->will($this->returnValue($path));
134  $node->expects($this->any())->method('exists')->will($this->returnValue(true));
135  $node->expects($this->any())->method('isDirectory')->will($this->returnValue(true));
136  $node->expects($this->any())->method('isPermissionCorrect')->will($this->returnValue(true));
137  $node->expects($this->any())->method('isWritable')->will($this->returnValue(true));
138  $this->assertInternalType('array', $node->getStatus());
139  }
140 
144  public function getStatusReturnsArrayWithWarningStatusIfDirectoryNotExists()
145  {
147  $node = $this->getAccessibleMock(
148  \TYPO3\CMS\Install\FolderStructure\DirectoryNode::class,
149  ['getAbsolutePath', 'getRelativePathBelowSiteRoot', 'exists', 'isDirectory', 'isWritable', 'isPermissionCorrect'],
150  [],
151  '',
152  false
153  );
154  $path = $this->getVirtualTestDir('dir_');
155  $node->expects($this->any())->method('getAbsolutePath')->will($this->returnValue($path));
156  $node->expects($this->any())->method('getRelativePathBelowSiteRoot')->will($this->returnValue($path));
157  $node->expects($this->any())->method('exists')->will($this->returnValue(false));
158  $node->expects($this->any())->method('isDirectory')->will($this->returnValue(false));
159  $node->expects($this->any())->method('isPermissionCorrect')->will($this->returnValue(false));
160  $node->expects($this->any())->method('isWritable')->will($this->returnValue(false));
161  $statusArray = $node->getStatus();
163  $status = $statusArray[0];
164  $this->assertInstanceOf(\TYPO3\CMS\Install\Status\WarningStatus::class, $status);
165  }
166 
170  public function getStatusReturnsArrayWithErrorStatusIfNodeIsNotADirectory()
171  {
173  $node = $this->getAccessibleMock(
174  \TYPO3\CMS\Install\FolderStructure\DirectoryNode::class,
175  ['getAbsolutePath', 'getRelativePathBelowSiteRoot', 'exists', 'isDirectory', 'isWritable', 'isPermissionCorrect'],
176  [],
177  '',
178  false
179  );
180  $path = $this->getVirtualTestFilePath('dir_');
181  touch($path);
182  $node->expects($this->any())->method('getAbsolutePath')->will($this->returnValue($path));
183  $node->expects($this->any())->method('getRelativePathBelowSiteRoot')->will($this->returnValue($path));
184  $node->expects($this->any())->method('exists')->will($this->returnValue(true));
185  $node->expects($this->any())->method('isDirectory')->will($this->returnValue(false));
186  $node->expects($this->any())->method('isPermissionCorrect')->will($this->returnValue(true));
187  $node->expects($this->any())->method('isWritable')->will($this->returnValue(true));
188  $statusArray = $node->getStatus();
190  $status = $statusArray[0];
191  $this->assertInstanceOf(\TYPO3\CMS\Install\Status\ErrorStatus::class, $status);
192  }
193 
197  public function getStatusReturnsArrayWithErrorStatusIfDirectoryExistsButIsNotWritable()
198  {
200  $node = $this->getAccessibleMock(
201  \TYPO3\CMS\Install\FolderStructure\DirectoryNode::class,
202  ['getAbsolutePath', 'getRelativePathBelowSiteRoot', 'exists', 'isDirectory', 'isWritable', 'isPermissionCorrect'],
203  [],
204  '',
205  false
206  );
207  $path = $this->getVirtualTestFilePath('dir_');
208  touch($path);
209  $node->expects($this->any())->method('getAbsolutePath')->will($this->returnValue($path));
210  $node->expects($this->any())->method('getRelativePathBelowSiteRoot')->will($this->returnValue($path));
211  $node->expects($this->any())->method('exists')->will($this->returnValue(true));
212  $node->expects($this->any())->method('isDirectory')->will($this->returnValue(true));
213  $node->expects($this->any())->method('isPermissionCorrect')->will($this->returnValue(true));
214  $node->expects($this->any())->method('isWritable')->will($this->returnValue(false));
215  $statusArray = $node->getStatus();
217  $status = $statusArray[0];
218  $this->assertInstanceOf(\TYPO3\CMS\Install\Status\ErrorStatus::class, $status);
219  }
220 
224  public function getStatusReturnsArrayWithNoticeStatusIfDirectoryExistsButPermissionAreNotCorrect()
225  {
227  $node = $this->getAccessibleMock(
228  \TYPO3\CMS\Install\FolderStructure\DirectoryNode::class,
229  ['getAbsolutePath', 'getRelativePathBelowSiteRoot', 'exists', 'isDirectory', 'isWritable', 'isPermissionCorrect'],
230  [],
231  '',
232  false
233  );
234  $path = $this->getVirtualTestFilePath('dir_');
235  touch($path);
236  $node->expects($this->any())->method('getAbsolutePath')->will($this->returnValue($path));
237  $node->expects($this->any())->method('getRelativePathBelowSiteRoot')->will($this->returnValue($path));
238  $node->expects($this->any())->method('exists')->will($this->returnValue(true));
239  $node->expects($this->any())->method('isDirectory')->will($this->returnValue(true));
240  $node->expects($this->any())->method('isPermissionCorrect')->will($this->returnValue(false));
241  $node->expects($this->any())->method('isWritable')->will($this->returnValue(true));
242  $statusArray = $node->getStatus();
244  $status = $statusArray[0];
245  $this->assertInstanceOf(\TYPO3\CMS\Install\Status\NoticeStatus::class, $status);
246  }
247 
251  public function getStatusReturnsArrayWithOkStatusIfDirectoryExistsAndPermissionAreCorrect()
252  {
254  $node = $this->getAccessibleMock(
255  \TYPO3\CMS\Install\FolderStructure\DirectoryNode::class,
256  ['getAbsolutePath', 'getRelativePathBelowSiteRoot', 'exists', 'isDirectory', 'isWritable', 'isPermissionCorrect'],
257  [],
258  '',
259  false
260  );
261  $path = $this->getVirtualTestFilePath('dir_');
262  touch($path);
263  $node->expects($this->any())->method('getAbsolutePath')->will($this->returnValue($path));
264  $node->expects($this->any())->method('getRelativePathBelowSiteRoot')->will($this->returnValue($path));
265  $node->expects($this->any())->method('exists')->will($this->returnValue(true));
266  $node->expects($this->any())->method('isDirectory')->will($this->returnValue(true));
267  $node->expects($this->any())->method('isPermissionCorrect')->will($this->returnValue(true));
268  $node->expects($this->any())->method('isWritable')->will($this->returnValue(true));
269  $statusArray = $node->getStatus();
271  $status = $statusArray[0];
272  $this->assertInstanceOf(\TYPO3\CMS\Install\Status\OkStatus::class, $status);
273  }
274 
278  public function getStatusCallsGetStatusOnChildren()
279  {
281  $node = $this->getAccessibleMock(
282  \TYPO3\CMS\Install\FolderStructure\DirectoryNode::class,
283  ['exists', 'isDirectory', 'isPermissionCorrect', 'getRelativePathBelowSiteRoot', 'isWritable'],
284  [],
285  '',
286  false
287  );
288  $node->expects($this->any())->method('exists')->will($this->returnValue(true));
289  $node->expects($this->any())->method('isDirectory')->will($this->returnValue(true));
290  $node->expects($this->any())->method('isPermissionCorrect')->will($this->returnValue(true));
291  $node->expects($this->any())->method('isWritable')->will($this->returnValue(true));
292  $childMock1 = $this->getMock(\TYPO3\CMS\Install\FolderStructure\NodeInterface::class, [], [], '', false);
293  $childMock1->expects($this->once())->method('getStatus')->will($this->returnValue([]));
294  $childMock2 = $this->getMock(\TYPO3\CMS\Install\FolderStructure\NodeInterface::class, [], [], '', false);
295  $childMock2->expects($this->once())->method('getStatus')->will($this->returnValue([]));
296  $node->_set('children', [$childMock1, $childMock2]);
297  $node->getStatus();
298  }
299 
303  public function getStatusReturnsArrayWithOwnStatusAndStatusOfChild()
304  {
306  $node = $this->getAccessibleMock(
307  \TYPO3\CMS\Install\FolderStructure\DirectoryNode::class,
308  ['exists', 'isDirectory', 'isPermissionCorrect', 'getRelativePathBelowSiteRoot', 'isWritable'],
309  [],
310  '',
311  false
312  );
313  $node->expects($this->any())->method('exists')->will($this->returnValue(true));
314  $node->expects($this->any())->method('isDirectory')->will($this->returnValue(true));
315  $node->expects($this->any())->method('isPermissionCorrect')->will($this->returnValue(true));
316  $node->expects($this->any())->method('isWritable')->will($this->returnValue(true));
317  $childMock = $this->getMock(\TYPO3\CMS\Install\FolderStructure\NodeInterface::class, [], [], '', false);
318  $childStatusMock = $this->getMock(\TYPO3\CMS\Install\Status\ErrorStatus::class, [], [], '', false);
319  $childMock->expects($this->once())->method('getStatus')->will($this->returnValue([$childStatusMock]));
320  $node->_set('children', [$childMock]);
321  $status = $node->getStatus();
322  $statusOfDirectory = $status[0];
323  $statusOfChild = $status[1];
324  $this->assertInstanceOf(\TYPO3\CMS\Install\Status\OkStatus::class, $statusOfDirectory);
325  $this->assertInstanceOf(\TYPO3\CMS\Install\Status\ErrorStatus::class, $statusOfChild);
326  }
327 
331  public function fixCallsFixSelfAndReturnsItsResult()
332  {
334  $node = $this->getAccessibleMock(
335  \TYPO3\CMS\Install\FolderStructure\DirectoryNode::class,
336  ['fixSelf'],
337  [],
338  '',
339  false
340  );
341  $uniqueReturn = [$this->getUniqueId('foo_')];
342  $node->expects($this->once())->method('fixSelf')->will($this->returnValue($uniqueReturn));
343  $this->assertSame($uniqueReturn, $node->fix());
344  }
345 
349  public function fixCallsFixOnChildrenAndReturnsMergedResult()
350  {
352  $node = $this->getAccessibleMock(\TYPO3\CMS\Install\FolderStructure\DirectoryNode::class, ['fixSelf'], [], '', false);
353  $uniqueReturnSelf = $this->getUniqueId('foo_');
354  $node->expects($this->once())->method('fixSelf')->will($this->returnValue([$uniqueReturnSelf]));
355 
356  $childMock1 = $this->getMock(\TYPO3\CMS\Install\FolderStructure\NodeInterface::class, [], [], '', false);
357  $uniqueReturnChild1 = $this->getUniqueId('foo_');
358  $childMock1->expects($this->once())->method('fix')->will($this->returnValue([$uniqueReturnChild1]));
359 
360  $childMock2 = $this->getMock(\TYPO3\CMS\Install\FolderStructure\NodeInterface::class, [], [], '', false);
361  $uniqueReturnChild2 = $this->getUniqueId('foo_');
362  $childMock2->expects($this->once())->method('fix')->will($this->returnValue([$uniqueReturnChild2]));
363 
364  $node->_set('children', [$childMock1, $childMock2]);
365 
366  $this->assertSame([$uniqueReturnSelf, $uniqueReturnChild1, $uniqueReturnChild2], $node->fix());
367  }
368 
372  public function fixSelfCallsCreateDirectoryIfDirectoryDoesNotExistAndReturnsResult()
373  {
375  $node = $this->getAccessibleMock(
376  \TYPO3\CMS\Install\FolderStructure\DirectoryNode::class,
377  ['exists', 'createDirectory', 'isPermissionCorrect'],
378  [],
379  '',
380  false
381  );
382  $node->expects($this->once())->method('exists')->will($this->returnValue(false));
383  $node->expects($this->any())->method('isPermissionCorrect')->will($this->returnValue(true));
384  $uniqueReturn = $this->getUniqueId();
385  $node->expects($this->once())->method('createDirectory')->will($this->returnValue($uniqueReturn));
386  $this->assertSame([$uniqueReturn], $node->_call('fixSelf'));
387  }
388 
392  public function fixSelfReturnsErrorStatusIfNodeExistsButIsNotADirectoryAndReturnsResult()
393  {
395  $node = $this->getAccessibleMock(
396  \TYPO3\CMS\Install\FolderStructure\DirectoryNode::class,
397  ['exists', 'isWritable', 'getRelativePathBelowSiteRoot', 'isDirectory', 'getAbsolutePath'],
398  [],
399  '',
400  false
401  );
402  $node->expects($this->any())->method('exists')->will($this->returnValue(true));
403  $node->expects($this->any())->method('isWritable')->will($this->returnValue(true));
404  $node->expects($this->any())->method('isDirectory')->will($this->returnValue(false));
405  $node->expects($this->any())->method('getRelativePathBelowSiteRoot')->will($this->returnValue(''));
406  $node->expects($this->any())->method('getAbsolutePath')->will($this->returnValue(''));
407  $result = $node->_call('fixSelf');
408  $this->assertInstanceOf(\TYPO3\CMS\Install\Status\ErrorStatus::class, $result[0]);
409  }
410 
414  public function fixSelfCallsFixPermissionIfDirectoryExistsButIsNotWritable()
415  {
417  $node = $this->getAccessibleMock(
418  \TYPO3\CMS\Install\FolderStructure\DirectoryNode::class,
419  ['exists', 'isWritable', 'fixPermission'],
420  [],
421  '',
422  false
423  );
424  $node->expects($this->any())->method('exists')->will($this->returnValue(true));
425  $node->expects($this->any())->method('isWritable')->will($this->returnValue(false));
426  $node->expects($this->once())->method('fixPermission')->will($this->returnValue(true));
427  $this->assertSame([true], $node->_call('fixSelf'));
428  }
429 
434  public function createDirectoryThrowsExceptionIfNodeExists()
435  {
437  $node = $this->getAccessibleMock(\TYPO3\CMS\Install\FolderStructure\DirectoryNode::class, ['exists', 'getAbsolutePath'], [], '', false);
438  $node->expects($this->once())->method('getAbsolutePath')->will($this->returnValue(''));
439  $node->expects($this->once())->method('exists')->will($this->returnValue(true));
440  $node->_call('createDirectory');
441  }
442 
446  public function createDirectoryCreatesDirectory()
447  {
449  $node = $this->getAccessibleMock(\TYPO3\CMS\Install\FolderStructure\DirectoryNode::class, ['exists', 'getAbsolutePath', 'getRelativePathBelowSiteRoot'], [], '', false);
450  $path = $this->getVirtualTestFilePath('dir_');
451  $node->expects($this->once())->method('exists')->will($this->returnValue(false));
452  $node->expects($this->any())->method('getAbsolutePath')->will($this->returnValue($path));
453  $node->expects($this->any())->method('getRelativePathBelowSiteRoot')->will($this->returnValue($path));
454  $node->_call('createDirectory');
455  $this->assertTrue(is_dir($path));
456  }
457 
461  public function createDirectoryReturnsOkStatusIfDirectoryWasCreated()
462  {
464  $node = $this->getAccessibleMock(\TYPO3\CMS\Install\FolderStructure\DirectoryNode::class, ['exists', 'getAbsolutePath', 'getRelativePathBelowSiteRoot'], [], '', false);
465  $path = $this->getVirtualTestFilePath('dir_');
466  $node->expects($this->once())->method('exists')->will($this->returnValue(false));
467  $node->expects($this->any())->method('getAbsolutePath')->will($this->returnValue($path));
468  $node->expects($this->any())->method('getRelativePathBelowSiteRoot')->will($this->returnValue($path));
469  $this->assertInstanceOf(\TYPO3\CMS\Install\Status\StatusInterface::class, $node->_call('createDirectory'));
470  }
471 
475  public function createDirectoryReturnsErrorStatusIfDirectoryWasNotCreated()
476  {
477  if (TYPO3_OS === 'WIN') {
478  $this->markTestSkipped('Test not available on Windows OS.');
479  }
481  $node = $this->getAccessibleMock(\TYPO3\CMS\Install\FolderStructure\DirectoryNode::class, ['exists', 'getAbsolutePath', 'getRelativePathBelowSiteRoot'], [], '', false);
482  $path = $this->getVirtualTestDir('root_');
483  chmod($path, 02550);
484  $subPath = $path . '/' . $this->getUniqueId('dir_');
485  $node->expects($this->once())->method('exists')->will($this->returnValue(false));
486  $node->expects($this->any())->method('getAbsolutePath')->will($this->returnValue($subPath));
487  $node->expects($this->any())->method('getRelativePathBelowSiteRoot')->will($this->returnValue($subPath));
488  $this->assertInstanceOf(\TYPO3\CMS\Install\Status\StatusInterface::class, $node->_call('createDirectory'));
489  }
490 
495  public function createChildrenThrowsExceptionIfAChildTypeIsNotSet()
496  {
498  $node = $this->getAccessibleMock(\TYPO3\CMS\Install\FolderStructure\DirectoryNode::class, ['dummy'], [], '', false);
499  $brokenStructure = [
500  [
501  'name' => 'foo',
502  ],
503  ];
504  $node->_call('createChildren', $brokenStructure);
505  }
506 
511  public function createChildrenThrowsExceptionIfAChildNameIsNotSet()
512  {
514  $node = $this->getAccessibleMock(\TYPO3\CMS\Install\FolderStructure\DirectoryNode::class, ['dummy'], [], '', false);
515  $brokenStructure = [
516  [
517  'type' => 'foo',
518  ],
519  ];
520  $node->_call('createChildren', $brokenStructure);
521  }
522 
527  public function createChildrenThrowsExceptionForMultipleChildrenWithSameName()
528  {
530  $node = $this->getAccessibleMock(\TYPO3\CMS\Install\FolderStructure\DirectoryNode::class, ['dummy'], [], '', false);
531  $brokenStructure = [
532  [
533  'type' => \TYPO3\CMS\Install\FolderStructure\DirectoryNode::class,
534  'name' => 'foo',
535  ],
536  [
537  'type' => \TYPO3\CMS\Install\FolderStructure\DirectoryNode::class,
538  'name' => 'foo',
539  ],
540  ];
541  $node->_call('createChildren', $brokenStructure);
542  }
543 
547  public function getChildrenReturnsCreatedChild()
548  {
550  $node = $this->getAccessibleMock(\TYPO3\CMS\Install\FolderStructure\DirectoryNode::class, ['dummy'], [], '', false);
551  $parent = $this->getMock(\TYPO3\CMS\Install\FolderStructure\NodeInterface::class, [], [], '', false);
552  $childName = $this->getUniqueId('test_');
553  $structure = [
554  'name' => 'foo',
555  'type' => \TYPO3\CMS\Install\FolderStructure\DirectoryNode::class,
556  'children' => [
557  [
558  'type' => \TYPO3\CMS\Install\FolderStructure\DirectoryNode::class,
559  'name' => $childName,
560  ],
561  ],
562  ];
563  $node->__construct($structure, $parent);
564  $children = $node->_call('getChildren');
566  $child = $children[0];
567  $this->assertInstanceOf(\TYPO3\CMS\Install\FolderStructure\DirectoryNode::class, $children[0]);
568  $this->assertSame($childName, $child->getName());
569  }
570 
574  public function isWritableReturnsFalseIfNodeDoesNotExist()
575  {
577  $node = $this->getAccessibleMock(\TYPO3\CMS\Install\FolderStructure\DirectoryNode::class, ['getAbsolutePath'], [], '', false);
578  $path = $this->getVirtualTestFilePath('dir_');
579  $node->expects($this->any())->method('getAbsolutePath')->will($this->returnValue($path));
580  $this->assertFalse($node->isWritable());
581  }
582 
586  public function isWritableReturnsTrueIfNodeExistsAndFileCanBeCreated()
587  {
589  $node = $this->getAccessibleMock(\TYPO3\CMS\Install\FolderStructure\DirectoryNode::class, ['getAbsolutePath'], [], '', false);
590  $path = $this->getVirtualTestDir('root_');
591  $node->expects($this->any())->method('getAbsolutePath')->will($this->returnValue($path));
592  $this->assertTrue($node->isWritable());
593  }
594 
598  public function isWritableReturnsFalseIfNodeExistsButFileCanNotBeCreated()
599  {
600  if (TYPO3_OS === 'WIN') {
601  $this->markTestSkipped('Test not available on Windows OS.');
602  }
603  if (function_exists('posix_getegid') && posix_getegid() === 0) {
604  $this->markTestSkipped('Test skipped if run on linux as root');
605  }
607  $node = $this->getAccessibleMock(\TYPO3\CMS\Install\FolderStructure\DirectoryNode::class, ['getAbsolutePath'], [], '', false);
608  $path = $this->getVirtualTestDir('root_');
609  chmod($path, 02550);
610  $node->expects($this->any())->method('getAbsolutePath')->will($this->returnValue($path));
611  $this->assertFalse($node->isWritable());
612  }
613 
617  public function isDirectoryReturnsTrueIfNameIsADirectory()
618  {
620  $node = $this->getAccessibleMock(\TYPO3\CMS\Install\FolderStructure\DirectoryNode::class, ['getAbsolutePath'], [], '', false);
621  $path = $this->getVirtualTestDir('dir_');
622  $node->expects($this->any())->method('getAbsolutePath')->will($this->returnValue($path));
623  $this->assertTrue($node->_call('isDirectory'));
624  }
625 
630  public function isDirectoryReturnsFalseIfNameIsALinkToADirectory()
631  {
632  if (TYPO3_OS === 'WIN') {
633  $this->markTestSkipped('Test not available on Windows OS.');
634  }
636  $node = $this->getAccessibleMock(\TYPO3\CMS\Install\FolderStructure\DirectoryNode::class, ['getAbsolutePath'], [], '', false);
637  $path = PATH_site . 'typo3temp/' . $this->getUniqueId('root_');
639  $this->testFilesToDelete[] = $path;
640  $link = $this->getUniqueId('link_');
641  $dir = $this->getUniqueId('dir_');
642  mkdir($path . '/' . $dir);
643  symlink($path . '/' . $dir, $path . '/' . $link);
644  $node->expects($this->any())->method('getAbsolutePath')->will($this->returnValue($path . '/' . $link));
645  $this->assertFalse($node->_call('isDirectory'));
646  }
647 }
static mkdir_deep($directory, $deepDirectory='')
getAccessibleMock( $originalClassName, $methods=[], array $arguments=[], $mockClassName='', $callOriginalConstructor=true, $callOriginalClone=true, $callAutoload=true)