TYPO3 CMS  TYPO3_8-7
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  */
18 
23 {
27  public function constructorThrowsExceptionIfParentIsNull()
28  {
29  $this->expectException(InvalidArgumentException::class);
30  $this->expectExceptionCode(1366222203);
32  $node = $this->getAccessibleMock(\TYPO3\CMS\Install\FolderStructure\DirectoryNode::class, ['dummy'], [], '', false);
33  $node->__construct([], null);
34  }
35 
39  public function constructorThrowsExceptionIfNameContainsForwardSlash()
40  {
41  $this->expectException(InvalidArgumentException::class);
42  $this->expectExceptionCode(1366226639);
43  $parent = $this->createMock(\TYPO3\CMS\Install\FolderStructure\NodeInterface::class);
45  $node = $this->getAccessibleMock(\TYPO3\CMS\Install\FolderStructure\DirectoryNode::class, ['dummy'], [], '', false);
46  $structure = [
47  'name' => 'foo/bar',
48  ];
49  $node->__construct($structure, $parent);
50  }
51 
55  public function constructorCallsCreateChildrenIfChildrenAreSet()
56  {
57  $parent = $this->createMock(\TYPO3\CMS\Install\FolderStructure\NodeInterface::class);
59  $node = $this->getAccessibleMock(
60  \TYPO3\CMS\Install\FolderStructure\DirectoryNode::class,
61  ['createChildren'],
62  [],
63  '',
64  false
65  );
66  $childArray = [
67  'foo',
68  ];
69  $structure = [
70  'name' => 'foo',
71  'children' => $childArray,
72  ];
73  $node->expects($this->once())->method('createChildren')->with($childArray);
74  $node->__construct($structure, $parent);
75  }
76 
80  public function constructorSetsParent()
81  {
82  $parent = $this->createMock(\TYPO3\CMS\Install\FolderStructure\NodeInterface::class);
84  $node = $this->getAccessibleMock(\TYPO3\CMS\Install\FolderStructure\DirectoryNode::class, ['dummy'], [], '', false);
85  $structure = [
86  'name' => 'foo',
87  ];
88  $node->__construct($structure, $parent);
89  $this->assertSame($parent, $node->_call('getParent'));
90  }
91 
95  public function constructorSetsTargetPermission()
96  {
97  $parent = $this->createMock(\TYPO3\CMS\Install\FolderStructure\NodeInterface::class);
99  $node = $this->getAccessibleMock(\TYPO3\CMS\Install\FolderStructure\DirectoryNode::class, ['dummy'], [], '', false);
100  $targetPermission = '2550';
101  $structure = [
102  'name' => 'foo',
103  'targetPermission' => $targetPermission,
104  ];
105  $node->__construct($structure, $parent);
106  $this->assertSame($targetPermission, $node->_call('getTargetPermission'));
107  }
108 
112  public function constructorSetsName()
113  {
115  $node = $this->getAccessibleMock(\TYPO3\CMS\Install\FolderStructure\DirectoryNode::class, ['dummy'], [], '', false);
116  $parent = $this->createMock(\TYPO3\CMS\Install\FolderStructure\RootNodeInterface::class);
117  $name = $this->getUniqueId('test_');
118  $node->__construct(['name' => $name], $parent);
119  $this->assertSame($name, $node->getName());
120  }
121 
125  public function getStatusReturnsArray()
126  {
128  $node = $this->getAccessibleMock(
129  \TYPO3\CMS\Install\FolderStructure\DirectoryNode::class,
130  ['getAbsolutePath', 'getRelativePathBelowSiteRoot', 'exists', 'isDirectory', 'isWritable', 'isPermissionCorrect'],
131  [],
132  '',
133  false
134  );
135  $path = $this->getVirtualTestDir('dir_');
136  $node->expects($this->any())->method('getAbsolutePath')->will($this->returnValue($path));
137  $node->expects($this->any())->method('getRelativePathBelowSiteRoot')->will($this->returnValue($path));
138  $node->expects($this->any())->method('exists')->will($this->returnValue(true));
139  $node->expects($this->any())->method('isDirectory')->will($this->returnValue(true));
140  $node->expects($this->any())->method('isPermissionCorrect')->will($this->returnValue(true));
141  $node->expects($this->any())->method('isWritable')->will($this->returnValue(true));
142  $this->assertInternalType('array', $node->getStatus());
143  }
144 
148  public function getStatusReturnsArrayWithWarningStatusIfDirectoryNotExists()
149  {
151  $node = $this->getAccessibleMock(
152  \TYPO3\CMS\Install\FolderStructure\DirectoryNode::class,
153  ['getAbsolutePath', 'getRelativePathBelowSiteRoot', 'exists', 'isDirectory', 'isWritable', 'isPermissionCorrect'],
154  [],
155  '',
156  false
157  );
158  $path = $this->getVirtualTestDir('dir_');
159  $node->expects($this->any())->method('getAbsolutePath')->will($this->returnValue($path));
160  $node->expects($this->any())->method('getRelativePathBelowSiteRoot')->will($this->returnValue($path));
161  $node->expects($this->any())->method('exists')->will($this->returnValue(false));
162  $node->expects($this->any())->method('isDirectory')->will($this->returnValue(false));
163  $node->expects($this->any())->method('isPermissionCorrect')->will($this->returnValue(false));
164  $node->expects($this->any())->method('isWritable')->will($this->returnValue(false));
165  $statusArray = $node->getStatus();
167  $status = $statusArray[0];
168  $this->assertInstanceOf(\TYPO3\CMS\Install\Status\WarningStatus::class, $status);
169  }
170 
174  public function getStatusReturnsArrayWithErrorStatusIfNodeIsNotADirectory()
175  {
177  $node = $this->getAccessibleMock(
178  \TYPO3\CMS\Install\FolderStructure\DirectoryNode::class,
179  ['getAbsolutePath', 'getRelativePathBelowSiteRoot', 'exists', 'isDirectory', 'isWritable', 'isPermissionCorrect'],
180  [],
181  '',
182  false
183  );
184  $path = $this->getVirtualTestFilePath('dir_');
185  touch($path);
186  $node->expects($this->any())->method('getAbsolutePath')->will($this->returnValue($path));
187  $node->expects($this->any())->method('getRelativePathBelowSiteRoot')->will($this->returnValue($path));
188  $node->expects($this->any())->method('exists')->will($this->returnValue(true));
189  $node->expects($this->any())->method('isDirectory')->will($this->returnValue(false));
190  $node->expects($this->any())->method('isPermissionCorrect')->will($this->returnValue(true));
191  $node->expects($this->any())->method('isWritable')->will($this->returnValue(true));
192  $statusArray = $node->getStatus();
194  $status = $statusArray[0];
195  $this->assertInstanceOf(\TYPO3\CMS\Install\Status\ErrorStatus::class, $status);
196  }
197 
201  public function getStatusReturnsArrayWithErrorStatusIfDirectoryExistsButIsNotWritable()
202  {
204  $node = $this->getAccessibleMock(
205  \TYPO3\CMS\Install\FolderStructure\DirectoryNode::class,
206  ['getAbsolutePath', 'getRelativePathBelowSiteRoot', 'exists', 'isDirectory', 'isWritable', 'isPermissionCorrect'],
207  [],
208  '',
209  false
210  );
211  $path = $this->getVirtualTestFilePath('dir_');
212  touch($path);
213  $node->expects($this->any())->method('getAbsolutePath')->will($this->returnValue($path));
214  $node->expects($this->any())->method('getRelativePathBelowSiteRoot')->will($this->returnValue($path));
215  $node->expects($this->any())->method('exists')->will($this->returnValue(true));
216  $node->expects($this->any())->method('isDirectory')->will($this->returnValue(true));
217  $node->expects($this->any())->method('isPermissionCorrect')->will($this->returnValue(true));
218  $node->expects($this->any())->method('isWritable')->will($this->returnValue(false));
219  $statusArray = $node->getStatus();
221  $status = $statusArray[0];
222  $this->assertInstanceOf(\TYPO3\CMS\Install\Status\ErrorStatus::class, $status);
223  }
224 
228  public function getStatusReturnsArrayWithNoticeStatusIfDirectoryExistsButPermissionAreNotCorrect()
229  {
231  $node = $this->getAccessibleMock(
232  \TYPO3\CMS\Install\FolderStructure\DirectoryNode::class,
233  ['getAbsolutePath', 'getRelativePathBelowSiteRoot', 'exists', 'isDirectory', 'isWritable', 'isPermissionCorrect'],
234  [],
235  '',
236  false
237  );
238  $path = $this->getVirtualTestFilePath('dir_');
239  touch($path);
240  $node->expects($this->any())->method('getAbsolutePath')->will($this->returnValue($path));
241  $node->expects($this->any())->method('getRelativePathBelowSiteRoot')->will($this->returnValue($path));
242  $node->expects($this->any())->method('exists')->will($this->returnValue(true));
243  $node->expects($this->any())->method('isDirectory')->will($this->returnValue(true));
244  $node->expects($this->any())->method('isPermissionCorrect')->will($this->returnValue(false));
245  $node->expects($this->any())->method('isWritable')->will($this->returnValue(true));
246  $statusArray = $node->getStatus();
248  $status = $statusArray[0];
249  $this->assertInstanceOf(\TYPO3\CMS\Install\Status\NoticeStatus::class, $status);
250  }
251 
255  public function getStatusReturnsArrayWithOkStatusIfDirectoryExistsAndPermissionAreCorrect()
256  {
258  $node = $this->getAccessibleMock(
259  \TYPO3\CMS\Install\FolderStructure\DirectoryNode::class,
260  ['getAbsolutePath', 'getRelativePathBelowSiteRoot', 'exists', 'isDirectory', 'isWritable', 'isPermissionCorrect'],
261  [],
262  '',
263  false
264  );
265  $path = $this->getVirtualTestFilePath('dir_');
266  touch($path);
267  $node->expects($this->any())->method('getAbsolutePath')->will($this->returnValue($path));
268  $node->expects($this->any())->method('getRelativePathBelowSiteRoot')->will($this->returnValue($path));
269  $node->expects($this->any())->method('exists')->will($this->returnValue(true));
270  $node->expects($this->any())->method('isDirectory')->will($this->returnValue(true));
271  $node->expects($this->any())->method('isPermissionCorrect')->will($this->returnValue(true));
272  $node->expects($this->any())->method('isWritable')->will($this->returnValue(true));
273  $statusArray = $node->getStatus();
275  $status = $statusArray[0];
276  $this->assertInstanceOf(\TYPO3\CMS\Install\Status\OkStatus::class, $status);
277  }
278 
282  public function getStatusCallsGetStatusOnChildren()
283  {
285  $node = $this->getAccessibleMock(
286  \TYPO3\CMS\Install\FolderStructure\DirectoryNode::class,
287  ['exists', 'isDirectory', 'isPermissionCorrect', 'getRelativePathBelowSiteRoot', 'isWritable'],
288  [],
289  '',
290  false
291  );
292  $node->expects($this->any())->method('exists')->will($this->returnValue(true));
293  $node->expects($this->any())->method('isDirectory')->will($this->returnValue(true));
294  $node->expects($this->any())->method('isPermissionCorrect')->will($this->returnValue(true));
295  $node->expects($this->any())->method('isWritable')->will($this->returnValue(true));
296  $childMock1 = $this->createMock(\TYPO3\CMS\Install\FolderStructure\NodeInterface::class);
297  $childMock1->expects($this->once())->method('getStatus')->will($this->returnValue([]));
298  $childMock2 = $this->createMock(\TYPO3\CMS\Install\FolderStructure\NodeInterface::class);
299  $childMock2->expects($this->once())->method('getStatus')->will($this->returnValue([]));
300  $node->_set('children', [$childMock1, $childMock2]);
301  $node->getStatus();
302  }
303 
307  public function getStatusReturnsArrayWithOwnStatusAndStatusOfChild()
308  {
310  $node = $this->getAccessibleMock(
311  \TYPO3\CMS\Install\FolderStructure\DirectoryNode::class,
312  ['exists', 'isDirectory', 'isPermissionCorrect', 'getRelativePathBelowSiteRoot', 'isWritable'],
313  [],
314  '',
315  false
316  );
317  $node->expects($this->any())->method('exists')->will($this->returnValue(true));
318  $node->expects($this->any())->method('isDirectory')->will($this->returnValue(true));
319  $node->expects($this->any())->method('isPermissionCorrect')->will($this->returnValue(true));
320  $node->expects($this->any())->method('isWritable')->will($this->returnValue(true));
321  $childMock = $this->createMock(\TYPO3\CMS\Install\FolderStructure\NodeInterface::class);
322  $childStatusMock = $this->createMock(\TYPO3\CMS\Install\Status\ErrorStatus::class);
323  $childMock->expects($this->once())->method('getStatus')->will($this->returnValue([$childStatusMock]));
324  $node->_set('children', [$childMock]);
325  $status = $node->getStatus();
326  $statusOfDirectory = $status[0];
327  $statusOfChild = $status[1];
328  $this->assertInstanceOf(\TYPO3\CMS\Install\Status\OkStatus::class, $statusOfDirectory);
329  $this->assertInstanceOf(\TYPO3\CMS\Install\Status\ErrorStatus::class, $statusOfChild);
330  }
331 
335  public function fixCallsFixSelfAndReturnsItsResult()
336  {
338  $node = $this->getAccessibleMock(
339  \TYPO3\CMS\Install\FolderStructure\DirectoryNode::class,
340  ['fixSelf'],
341  [],
342  '',
343  false
344  );
345  $uniqueReturn = [$this->getUniqueId('foo_')];
346  $node->expects($this->once())->method('fixSelf')->will($this->returnValue($uniqueReturn));
347  $this->assertSame($uniqueReturn, $node->fix());
348  }
349 
353  public function fixCallsFixOnChildrenAndReturnsMergedResult()
354  {
356  $node = $this->getAccessibleMock(\TYPO3\CMS\Install\FolderStructure\DirectoryNode::class, ['fixSelf'], [], '', false);
357  $uniqueReturnSelf = $this->getUniqueId('foo_');
358  $node->expects($this->once())->method('fixSelf')->will($this->returnValue([$uniqueReturnSelf]));
359 
360  $childMock1 = $this->createMock(\TYPO3\CMS\Install\FolderStructure\NodeInterface::class);
361  $uniqueReturnChild1 = $this->getUniqueId('foo_');
362  $childMock1->expects($this->once())->method('fix')->will($this->returnValue([$uniqueReturnChild1]));
363 
364  $childMock2 = $this->createMock(\TYPO3\CMS\Install\FolderStructure\NodeInterface::class);
365  $uniqueReturnChild2 = $this->getUniqueId('foo_');
366  $childMock2->expects($this->once())->method('fix')->will($this->returnValue([$uniqueReturnChild2]));
367 
368  $node->_set('children', [$childMock1, $childMock2]);
369 
370  $this->assertSame([$uniqueReturnSelf, $uniqueReturnChild1, $uniqueReturnChild2], $node->fix());
371  }
372 
376  public function fixSelfCallsCreateDirectoryIfDirectoryDoesNotExistAndReturnsResult()
377  {
379  $node = $this->getAccessibleMock(
380  \TYPO3\CMS\Install\FolderStructure\DirectoryNode::class,
381  ['exists', 'createDirectory', 'isPermissionCorrect'],
382  [],
383  '',
384  false
385  );
386  $node->expects($this->once())->method('exists')->will($this->returnValue(false));
387  $node->expects($this->any())->method('isPermissionCorrect')->will($this->returnValue(true));
388  $uniqueReturn = $this->getUniqueId();
389  $node->expects($this->once())->method('createDirectory')->will($this->returnValue($uniqueReturn));
390  $this->assertSame([$uniqueReturn], $node->_call('fixSelf'));
391  }
392 
396  public function fixSelfReturnsErrorStatusIfNodeExistsButIsNotADirectoryAndReturnsResult()
397  {
399  $node = $this->getAccessibleMock(
400  \TYPO3\CMS\Install\FolderStructure\DirectoryNode::class,
401  ['exists', 'isWritable', 'getRelativePathBelowSiteRoot', 'isDirectory', 'getAbsolutePath'],
402  [],
403  '',
404  false
405  );
406  $node->expects($this->any())->method('exists')->will($this->returnValue(true));
407  $node->expects($this->any())->method('isWritable')->will($this->returnValue(true));
408  $node->expects($this->any())->method('isDirectory')->will($this->returnValue(false));
409  $node->expects($this->any())->method('getRelativePathBelowSiteRoot')->will($this->returnValue(''));
410  $node->expects($this->any())->method('getAbsolutePath')->will($this->returnValue(''));
411  $result = $node->_call('fixSelf');
412  $this->assertInstanceOf(\TYPO3\CMS\Install\Status\ErrorStatus::class, $result[0]);
413  }
414 
418  public function fixSelfCallsFixPermissionIfDirectoryExistsButIsNotWritable()
419  {
421  $node = $this->getAccessibleMock(
422  \TYPO3\CMS\Install\FolderStructure\DirectoryNode::class,
423  ['exists', 'isWritable', 'fixPermission'],
424  [],
425  '',
426  false
427  );
428  $node->expects($this->any())->method('exists')->will($this->returnValue(true));
429  $node->expects($this->any())->method('isWritable')->will($this->returnValue(false));
430  $node->expects($this->once())->method('fixPermission')->will($this->returnValue(true));
431  $this->assertSame([true], $node->_call('fixSelf'));
432  }
433 
437  public function createDirectoryThrowsExceptionIfNodeExists()
438  {
439  $this->expectException(Exception::class);
440  $this->expectExceptionCode(1366740091);
442  $node = $this->getAccessibleMock(\TYPO3\CMS\Install\FolderStructure\DirectoryNode::class, ['exists', 'getAbsolutePath'], [], '', false);
443  $node->expects($this->once())->method('getAbsolutePath')->will($this->returnValue(''));
444  $node->expects($this->once())->method('exists')->will($this->returnValue(true));
445  $node->_call('createDirectory');
446  }
447 
451  public function createDirectoryCreatesDirectory()
452  {
454  $node = $this->getAccessibleMock(\TYPO3\CMS\Install\FolderStructure\DirectoryNode::class, ['exists', 'getAbsolutePath', 'getRelativePathBelowSiteRoot'], [], '', false);
455  $path = $this->getVirtualTestFilePath('dir_');
456  $node->expects($this->once())->method('exists')->will($this->returnValue(false));
457  $node->expects($this->any())->method('getAbsolutePath')->will($this->returnValue($path));
458  $node->expects($this->any())->method('getRelativePathBelowSiteRoot')->will($this->returnValue($path));
459  $node->_call('createDirectory');
460  $this->assertTrue(is_dir($path));
461  }
462 
466  public function createDirectoryReturnsOkStatusIfDirectoryWasCreated()
467  {
469  $node = $this->getAccessibleMock(\TYPO3\CMS\Install\FolderStructure\DirectoryNode::class, ['exists', 'getAbsolutePath', 'getRelativePathBelowSiteRoot'], [], '', false);
470  $path = $this->getVirtualTestFilePath('dir_');
471  $node->expects($this->once())->method('exists')->will($this->returnValue(false));
472  $node->expects($this->any())->method('getAbsolutePath')->will($this->returnValue($path));
473  $node->expects($this->any())->method('getRelativePathBelowSiteRoot')->will($this->returnValue($path));
474  $this->assertInstanceOf(\TYPO3\CMS\Install\Status\StatusInterface::class, $node->_call('createDirectory'));
475  }
476 
480  public function createDirectoryReturnsErrorStatusIfDirectoryWasNotCreated()
481  {
483  $node = $this->getAccessibleMock(\TYPO3\CMS\Install\FolderStructure\DirectoryNode::class, ['exists', 'getAbsolutePath', 'getRelativePathBelowSiteRoot'], [], '', false);
484  $path = $this->getVirtualTestDir('root_');
485  chmod($path, 02550);
486  $subPath = $path . '/' . $this->getUniqueId('dir_');
487  $node->expects($this->once())->method('exists')->will($this->returnValue(false));
488  $node->expects($this->any())->method('getAbsolutePath')->will($this->returnValue($subPath));
489  $node->expects($this->any())->method('getRelativePathBelowSiteRoot')->will($this->returnValue($subPath));
490  $this->assertInstanceOf(\TYPO3\CMS\Install\Status\StatusInterface::class, $node->_call('createDirectory'));
491  }
492 
496  public function createChildrenThrowsExceptionIfAChildTypeIsNotSet()
497  {
498  $this->expectException(InvalidArgumentException::class);
499  $this->expectExceptionCode(1366222204);
501  $node = $this->getAccessibleMock(\TYPO3\CMS\Install\FolderStructure\DirectoryNode::class, ['dummy'], [], '', false);
502  $brokenStructure = [
503  [
504  'name' => 'foo',
505  ],
506  ];
507  $node->_call('createChildren', $brokenStructure);
508  }
509 
513  public function createChildrenThrowsExceptionIfAChildNameIsNotSet()
514  {
515  $this->expectException(InvalidArgumentException::class);
516  $this->expectExceptionCode(1366222205);
518  $node = $this->getAccessibleMock(\TYPO3\CMS\Install\FolderStructure\DirectoryNode::class, ['dummy'], [], '', false);
519  $brokenStructure = [
520  [
521  'type' => 'foo',
522  ],
523  ];
524  $node->_call('createChildren', $brokenStructure);
525  }
526 
530  public function createChildrenThrowsExceptionForMultipleChildrenWithSameName()
531  {
532  $this->expectException(InvalidArgumentException::class);
533  $this->expectExceptionCode(1366222206);
535  $node = $this->getAccessibleMock(\TYPO3\CMS\Install\FolderStructure\DirectoryNode::class, ['dummy'], [], '', false);
536  $brokenStructure = [
537  [
538  'type' => \TYPO3\CMS\Install\FolderStructure\DirectoryNode::class,
539  'name' => 'foo',
540  ],
541  [
542  'type' => \TYPO3\CMS\Install\FolderStructure\DirectoryNode::class,
543  'name' => 'foo',
544  ],
545  ];
546  $node->_call('createChildren', $brokenStructure);
547  }
548 
552  public function getChildrenReturnsCreatedChild()
553  {
555  $node = $this->getAccessibleMock(\TYPO3\CMS\Install\FolderStructure\DirectoryNode::class, ['dummy'], [], '', false);
556  $parent = $this->createMock(\TYPO3\CMS\Install\FolderStructure\NodeInterface::class);
557  $childName = $this->getUniqueId('test_');
558  $structure = [
559  'name' => 'foo',
560  'type' => \TYPO3\CMS\Install\FolderStructure\DirectoryNode::class,
561  'children' => [
562  [
563  'type' => \TYPO3\CMS\Install\FolderStructure\DirectoryNode::class,
564  'name' => $childName,
565  ],
566  ],
567  ];
568  $node->__construct($structure, $parent);
569  $children = $node->_call('getChildren');
571  $child = $children[0];
572  $this->assertInstanceOf(\TYPO3\CMS\Install\FolderStructure\DirectoryNode::class, $children[0]);
573  $this->assertSame($childName, $child->getName());
574  }
575 
579  public function isWritableReturnsFalseIfNodeDoesNotExist()
580  {
582  $node = $this->getAccessibleMock(\TYPO3\CMS\Install\FolderStructure\DirectoryNode::class, ['getAbsolutePath'], [], '', false);
583  $path = $this->getVirtualTestFilePath('dir_');
584  $node->expects($this->any())->method('getAbsolutePath')->will($this->returnValue($path));
585  $this->assertFalse($node->isWritable());
586  }
587 
591  public function isWritableReturnsTrueIfNodeExistsAndFileCanBeCreated()
592  {
594  $node = $this->getAccessibleMock(\TYPO3\CMS\Install\FolderStructure\DirectoryNode::class, ['getAbsolutePath'], [], '', false);
595  $path = $this->getVirtualTestDir('root_');
596  $node->expects($this->any())->method('getAbsolutePath')->will($this->returnValue($path));
597  $this->assertTrue($node->isWritable());
598  }
599 
603  public function isWritableReturnsFalseIfNodeExistsButFileCanNotBeCreated()
604  {
605  if (function_exists('posix_getegid') && posix_getegid() === 0) {
606  $this->markTestSkipped('Test skipped if run on linux as root');
607  }
609  $node = $this->getAccessibleMock(\TYPO3\CMS\Install\FolderStructure\DirectoryNode::class, ['getAbsolutePath'], [], '', false);
610  $path = $this->getVirtualTestDir('root_');
611  chmod($path, 02550);
612  $node->expects($this->any())->method('getAbsolutePath')->will($this->returnValue($path));
613  $this->assertFalse($node->isWritable());
614  }
615 
619  public function isDirectoryReturnsTrueIfNameIsADirectory()
620  {
622  $node = $this->getAccessibleMock(\TYPO3\CMS\Install\FolderStructure\DirectoryNode::class, ['getAbsolutePath'], [], '', false);
623  $path = $this->getVirtualTestDir('dir_');
624  $node->expects($this->any())->method('getAbsolutePath')->will($this->returnValue($path));
625  $this->assertTrue($node->_call('isDirectory'));
626  }
627 
632  public function isDirectoryReturnsFalseIfNameIsALinkToADirectory()
633  {
635  $node = $this->getAccessibleMock(\TYPO3\CMS\Install\FolderStructure\DirectoryNode::class, ['getAbsolutePath'], [], '', false);
636  $path = PATH_site . 'typo3temp/var/tests/' . $this->getUniqueId('root_');
638  $this->testFilesToDelete[] = $path;
639  $link = $this->getUniqueId('link_');
640  $dir = $this->getUniqueId('dir_');
641  mkdir($path . '/' . $dir);
642  symlink($path . '/' . $dir, $path . '/' . $link);
643  $node->expects($this->any())->method('getAbsolutePath')->will($this->returnValue($path . '/' . $link));
644  $this->assertFalse($node->_call('isDirectory'));
645  }
646 }
static mkdir_deep($directory, $deepDirectory='')