TYPO3 CMS  TYPO3_6-2
DirectoryNodeTest.php
Go to the documentation of this file.
1 <?php
3 
21 
25  protected $testNodesToDelete = array();
26 
30  public function tearDown() {
31  foreach ($this->testNodesToDelete as $node) {
32  if (\TYPO3\CMS\Core\Utility\GeneralUtility::isFirstPartOfStr($node, PATH_site . 'typo3temp/')) {
34  }
35  }
36  parent::tearDown();
37  }
38 
43  public function constructorThrowsExceptionIfParentIsNull() {
45  $node = $this->getAccessibleMock('TYPO3\\CMS\\Install\\FolderStructure\\DirectoryNode', array('dummy'), array(), '', FALSE);
46  $node->__construct(array(), NULL);
47  }
48 
53  public function constructorThrowsExceptionIfNameContainsForwardSlash() {
54  $parent = $this->getMock('TYPO3\CMS\Install\FolderStructure\NodeInterface', array(), array(), '', FALSE);
56  $node = $this->getAccessibleMock('TYPO3\\CMS\\Install\\FolderStructure\\DirectoryNode', array('dummy'), array(), '', FALSE);
57  $structure = array(
58  'name' => 'foo/bar',
59  );
60  $node->__construct($structure, $parent);
61  }
62 
66  public function constructorCallsCreateChildrenIfChildrenAreSet() {
67  $parent = $this->getMock('TYPO3\CMS\Install\FolderStructure\NodeInterface', array(), array(), '', FALSE);
69  $node = $this->getAccessibleMock(
70  'TYPO3\\CMS\\Install\\FolderStructure\\DirectoryNode',
71  array('createChildren'),
72  array(),
73  '',
74  FALSE
75  );
76  $childArray = array(
77  'foo',
78  );
79  $structure = array(
80  'name' => 'foo',
81  'children' => $childArray,
82  );
83  $node->expects($this->once())->method('createChildren')->with($childArray);
84  $node->__construct($structure, $parent);
85  }
86 
90  public function constructorSetsParent() {
91  $parent = $this->getMock('TYPO3\CMS\Install\FolderStructure\NodeInterface', array(), array(), '', FALSE);
93  $node = $this->getAccessibleMock('TYPO3\\CMS\\Install\\FolderStructure\\DirectoryNode', array('dummy'), array(), '', FALSE);
94  $structure = array(
95  'name' => 'foo',
96  );
97  $node->__construct($structure, $parent);
98  $this->assertSame($parent, $node->_call('getParent'));
99  }
100 
104  public function constructorSetsTargetPermission() {
105  $parent = $this->getMock('TYPO3\CMS\Install\FolderStructure\NodeInterface', array(), array(), '', FALSE);
107  $node = $this->getAccessibleMock('TYPO3\\CMS\\Install\\FolderStructure\\DirectoryNode', array('dummy'), array(), '', FALSE);
108  $targetPermission = '2550';
109  $structure = array(
110  'name' => 'foo',
111  'targetPermission' => $targetPermission,
112  );
113  $node->__construct($structure, $parent);
114  $this->assertSame($targetPermission, $node->_call('getTargetPermission'));
115  }
116 
120  public function constructorSetsName() {
122  $node = $this->getAccessibleMock('TYPO3\\CMS\\Install\\FolderStructure\\DirectoryNode', array('dummy'), array(), '', FALSE);
123  $parent = $this->getMock('TYPO3\CMS\Install\FolderStructure\RootNodeInterface', array(), array(), '', FALSE);
124  $name = $this->getUniqueId('test_');
125  $node->__construct(array('name' => $name), $parent);
126  $this->assertSame($name, $node->getName());
127  }
128 
132  public function getStatusReturnsArray() {
134  $node = $this->getAccessibleMock(
135  'TYPO3\\CMS\\Install\\FolderStructure\\DirectoryNode',
136  array('getAbsolutePath', 'exists', 'isDirectory', 'isWritable', 'isPermissionCorrect'),
137  array(),
138  '',
139  FALSE
140  );
141  $path = PATH_site . 'typo3temp/' . $this->getUniqueId('dir_');
142  $node->expects($this->any())->method('getAbsolutePath')->will($this->returnValue($path));
143  $node->expects($this->any())->method('exists')->will($this->returnValue(TRUE));
144  $node->expects($this->any())->method('isDirectory')->will($this->returnValue(TRUE));
145  $node->expects($this->any())->method('isPermissionCorrect')->will($this->returnValue(TRUE));
146  $node->expects($this->any())->method('isWritable')->will($this->returnValue(TRUE));
147  $this->assertInternalType('array', $node->getStatus());
148  }
149 
153  public function getStatusReturnsArrayWithWarningStatusIfDirectoryNotExists() {
155  $node = $this->getAccessibleMock(
156  'TYPO3\\CMS\\Install\\FolderStructure\\DirectoryNode',
157  array('getAbsolutePath', 'exists', 'isDirectory', 'isWritable', 'isPermissionCorrect'),
158  array(),
159  '',
160  FALSE
161  );
162  $path = PATH_site . 'typo3temp/' . $this->getUniqueId('dir_');
163  $node->expects($this->any())->method('getAbsolutePath')->will($this->returnValue($path));
164  $node->expects($this->any())->method('exists')->will($this->returnValue(FALSE));
165  $node->expects($this->any())->method('isDirectory')->will($this->returnValue(FALSE));
166  $node->expects($this->any())->method('isPermissionCorrect')->will($this->returnValue(FALSE));
167  $node->expects($this->any())->method('isWritable')->will($this->returnValue(FALSE));
168  $statusArray = $node->getStatus();
170  $status = $statusArray[0];
171  $this->assertInstanceOf('\TYPO3\CMS\Install\Status\WarningStatus', $status);
172  }
173 
177  public function getStatusReturnsArrayWithErrorStatusIfNodeIsNotADirectory() {
179  $node = $this->getAccessibleMock(
180  'TYPO3\\CMS\\Install\\FolderStructure\\DirectoryNode',
181  array('getAbsolutePath', 'exists', 'isDirectory', 'isWritable', 'isPermissionCorrect'),
182  array(),
183  '',
184  FALSE
185  );
186  $path = PATH_site . 'typo3temp/' . $this->getUniqueId('dir_');
187  touch ($path);
188  $this->testNodesToDelete[] = $path;
189  $node->expects($this->any())->method('getAbsolutePath')->will($this->returnValue($path));
190  $node->expects($this->any())->method('exists')->will($this->returnValue(TRUE));
191  $node->expects($this->any())->method('isDirectory')->will($this->returnValue(FALSE));
192  $node->expects($this->any())->method('isPermissionCorrect')->will($this->returnValue(TRUE));
193  $node->expects($this->any())->method('isWritable')->will($this->returnValue(TRUE));
194  $statusArray = $node->getStatus();
196  $status = $statusArray[0];
197  $this->assertInstanceOf('\TYPO3\CMS\Install\Status\ErrorStatus', $status);
198  }
199 
203  public function getStatusReturnsArrayWithErrorStatusIfDirectoryExistsButIsNotWritable() {
205  $node = $this->getAccessibleMock(
206  'TYPO3\\CMS\\Install\\FolderStructure\\DirectoryNode',
207  array('getAbsolutePath', 'exists', 'isDirectory', 'isWritable', 'isPermissionCorrect'),
208  array(),
209  '',
210  FALSE
211  );
212  $path = PATH_site . 'typo3temp/' . $this->getUniqueId('dir_');
213  touch ($path);
214  $this->testNodesToDelete[] = $path;
215  $node->expects($this->any())->method('getAbsolutePath')->will($this->returnValue($path));
216  $node->expects($this->any())->method('exists')->will($this->returnValue(TRUE));
217  $node->expects($this->any())->method('isDirectory')->will($this->returnValue(TRUE));
218  $node->expects($this->any())->method('isPermissionCorrect')->will($this->returnValue(TRUE));
219  $node->expects($this->any())->method('isWritable')->will($this->returnValue(FALSE));
220  $statusArray = $node->getStatus();
222  $status = $statusArray[0];
223  $this->assertInstanceOf('\TYPO3\CMS\Install\Status\ErrorStatus', $status);
224  }
225 
229  public function getStatusReturnsArrayWithNoticeStatusIfDirectoryExistsButPermissionAreNotCorrect() {
231  $node = $this->getAccessibleMock(
232  'TYPO3\\CMS\\Install\\FolderStructure\\DirectoryNode',
233  array('getAbsolutePath', 'exists', 'isDirectory', 'isWritable', 'isPermissionCorrect'),
234  array(),
235  '',
236  FALSE
237  );
238  $path = PATH_site . 'typo3temp/' . $this->getUniqueId('dir_');
239  touch ($path);
240  $this->testNodesToDelete[] = $path;
241  $node->expects($this->any())->method('getAbsolutePath')->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', $status);
250  }
251 
255  public function getStatusReturnsArrayWithOkStatusIfDirectoryExistsAndPermissionAreCorrect() {
257  $node = $this->getAccessibleMock(
258  'TYPO3\\CMS\\Install\\FolderStructure\\DirectoryNode',
259  array('getAbsolutePath', 'exists', 'isDirectory', 'isWritable', 'isPermissionCorrect'),
260  array(),
261  '',
262  FALSE
263  );
264  $path = PATH_site . 'typo3temp/' . $this->getUniqueId('dir_');
265  touch ($path);
266  $this->testNodesToDelete[] = $path;
267  $node->expects($this->any())->method('getAbsolutePath')->will($this->returnValue($path));
268  $node->expects($this->any())->method('exists')->will($this->returnValue(TRUE));
269  $node->expects($this->any())->method('isDirectory')->will($this->returnValue(TRUE));
270  $node->expects($this->any())->method('isPermissionCorrect')->will($this->returnValue(TRUE));
271  $node->expects($this->any())->method('isWritable')->will($this->returnValue(TRUE));
272  $statusArray = $node->getStatus();
274  $status = $statusArray[0];
275  $this->assertInstanceOf('\TYPO3\CMS\Install\Status\OkStatus', $status);
276  }
277 
281  public function getStatusCallsGetStatusOnChildren() {
283  $node = $this->getAccessibleMock(
284  'TYPO3\\CMS\\Install\\FolderStructure\\DirectoryNode',
285  array('exists', 'isDirectory', 'isPermissionCorrect', 'getRelativePathBelowSiteRoot', 'isWritable'),
286  array(),
287  '',
288  FALSE
289  );
290  $node->expects($this->any())->method('exists')->will($this->returnValue(TRUE));
291  $node->expects($this->any())->method('isDirectory')->will($this->returnValue(TRUE));
292  $node->expects($this->any())->method('isPermissionCorrect')->will($this->returnValue(TRUE));
293  $node->expects($this->any())->method('isWritable')->will($this->returnValue(TRUE));
294  $childMock1 = $this->getMock('TYPO3\\CMS\\Install\\FolderStructure\\NodeInterface', array(), array(), '', FALSE);
295  $childMock1->expects($this->once())->method('getStatus')->will($this->returnValue(array()));
296  $childMock2 = $this->getMock('TYPO3\\CMS\\Install\\FolderStructure\\NodeInterface', array(), array(), '', FALSE);
297  $childMock2->expects($this->once())->method('getStatus')->will($this->returnValue(array()));
298  $node->_set('children', array($childMock1, $childMock2));
299  $node->getStatus();
300  }
301 
305  public function getStatusReturnsArrayWithOwnStatusAndStatusOfChild() {
307  $node = $this->getAccessibleMock(
308  'TYPO3\\CMS\\Install\\FolderStructure\\DirectoryNode',
309  array('exists', 'isDirectory', 'isPermissionCorrect', 'getRelativePathBelowSiteRoot', 'isWritable'),
310  array(),
311  '',
312  FALSE
313  );
314  $node->expects($this->any())->method('exists')->will($this->returnValue(TRUE));
315  $node->expects($this->any())->method('isDirectory')->will($this->returnValue(TRUE));
316  $node->expects($this->any())->method('isPermissionCorrect')->will($this->returnValue(TRUE));
317  $node->expects($this->any())->method('isWritable')->will($this->returnValue(TRUE));
318  $childMock = $this->getMock('TYPO3\\CMS\\Install\\FolderStructure\\NodeInterface', array(), array(), '', FALSE);
319  $childStatusMock = $this->getMock('TYPO3\\CMS\\Install\\Status\\ErrorStatus', array(), array(), '', FALSE);
320  $childMock->expects($this->once())->method('getStatus')->will($this->returnValue(array($childStatusMock)));
321  $node->_set('children', array($childMock));
322  $status = $node->getStatus();
323  $statusOfDirectory = $status[0];
324  $statusOfChild = $status[1];
325  $this->assertInstanceOf('\TYPO3\CMS\Install\Status\OkStatus', $statusOfDirectory);
326  $this->assertInstanceOf('\TYPO3\CMS\Install\Status\ErrorStatus', $statusOfChild);
327  }
328 
332  public function fixCallsFixSelfAndReturnsItsResult() {
334  $node = $this->getAccessibleMock(
335  'TYPO3\\CMS\\Install\\FolderStructure\\DirectoryNode',
336  array('fixSelf'),
337  array(),
338  '',
339  FALSE
340  );
341  $uniqueReturn = array($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() {
351  $node = $this->getAccessibleMock('TYPO3\\CMS\\Install\\FolderStructure\\DirectoryNode', array('fixSelf'), array(), '', FALSE);
352  $uniqueReturnSelf = $this->getUniqueId('foo_');
353  $node->expects($this->once())->method('fixSelf')->will($this->returnValue(array($uniqueReturnSelf)));
354 
355  $childMock1 = $this->getMock('TYPO3\\CMS\\Install\\FolderStructure\\NodeInterface', array(), array(), '', FALSE);
356  $uniqueReturnChild1 = $this->getUniqueId('foo_');
357  $childMock1->expects($this->once())->method('fix')->will($this->returnValue(array($uniqueReturnChild1)));
358 
359  $childMock2 = $this->getMock('TYPO3\\CMS\\Install\\FolderStructure\\NodeInterface', array(), array(), '', FALSE);
360  $uniqueReturnChild2 = $this->getUniqueId('foo_');
361  $childMock2->expects($this->once())->method('fix')->will($this->returnValue(array($uniqueReturnChild2)));
362 
363  $node->_set('children', array($childMock1, $childMock2));
364 
365  $this->assertSame(array($uniqueReturnSelf, $uniqueReturnChild1, $uniqueReturnChild2), $node->fix());
366  }
367 
371  public function fixSelfCallsCreateDirectoryIfDirectoryDoesNotExistAndReturnsResult() {
373  $node = $this->getAccessibleMock(
374  'TYPO3\\CMS\\Install\\FolderStructure\\DirectoryNode',
375  array('exists', 'createDirectory', 'isPermissionCorrect'),
376  array(),
377  '',
378  FALSE
379  );
380  $node->expects($this->once())->method('exists')->will($this->returnValue(FALSE));
381  $node->expects($this->any())->method('isPermissionCorrect')->will($this->returnValue(TRUE));
382  $uniqueReturn = $this->getUniqueId();
383  $node->expects($this->once())->method('createDirectory')->will($this->returnValue($uniqueReturn));
384  $this->assertSame(array($uniqueReturn), $node->_call('fixSelf'));
385  }
386 
390  public function fixSelfReturnsErrorStatusIfNodeExistsButIsNotADirectoryAndReturnsResult() {
392  $node = $this->getAccessibleMock(
393  'TYPO3\\CMS\\Install\\FolderStructure\\DirectoryNode',
394  array('exists', 'isWritable', 'getRelativePathBelowSiteRoot', 'isDirectory', 'getAbsolutePath'),
395  array(),
396  '',
397  FALSE
398  );
399  $node->expects($this->any())->method('exists')->will($this->returnValue(TRUE));
400  $node->expects($this->any())->method('isWritable')->will($this->returnValue(TRUE));
401  $node->expects($this->any())->method('isDirectory')->will($this->returnValue(FALSE));
402  $node->expects($this->any())->method('getRelativePathBelowSiteRoot')->will($this->returnValue(''));
403  $node->expects($this->any())->method('getAbsolutePath')->will($this->returnValue(''));
404  $result = $node->_call('fixSelf');
405  $this->assertInstanceOf('TYPO3\\CMS\\Install\\Status\\ErrorStatus', $result[0]);
406  }
407 
411  public function fixSelfCallsFixPermissionIfDirectoryExistsButIsNotWritable() {
413  $node = $this->getAccessibleMock(
414  'TYPO3\\CMS\\Install\\FolderStructure\\DirectoryNode',
415  array('exists', 'isWritable', 'fixPermission'),
416  array(),
417  '',
418  FALSE
419  );
420  $node->expects($this->any())->method('exists')->will($this->returnValue(TRUE));
421  $node->expects($this->any())->method('isWritable')->will($this->returnValue(FALSE));
422  $node->expects($this->once())->method('fixPermission')->will($this->returnValue(TRUE));
423  $this->assertSame(array(TRUE), $node->_call('fixSelf'));
424  }
425 
430  public function createDirectoryThrowsExceptionIfNodeExists() {
432  $node = $this->getAccessibleMock('TYPO3\\CMS\\Install\\FolderStructure\\DirectoryNode', array('exists', 'getAbsolutePath'), array(), '', FALSE);
433  $node->expects($this->once())->method('getAbsolutePath')->will($this->returnValue(''));
434  $node->expects($this->once())->method('exists')->will($this->returnValue(TRUE));
435  $node->_call('createDirectory');
436  }
437 
441  public function createDirectoryCreatesDirectory() {
443  $node = $this->getAccessibleMock('TYPO3\\CMS\\Install\\FolderStructure\\DirectoryNode', array('exists', 'getAbsolutePath'), array(), '', FALSE);
444  $path = PATH_site . 'typo3temp/' . $this->getUniqueId('dir_');
445  $this->testNodesToDelete[] = $path;
446  $node->expects($this->once())->method('exists')->will($this->returnValue(FALSE));
447  $node->expects($this->any())->method('getAbsolutePath')->will($this->returnValue($path));
448  $node->_call('createDirectory');
449  $this->assertTrue(is_dir($path));
450  }
451 
455  public function createDirectoryReturnsOkStatusIfDirectoryWasCreated() {
457  $node = $this->getAccessibleMock('TYPO3\\CMS\\Install\\FolderStructure\\DirectoryNode', array('exists', 'getAbsolutePath'), array(), '', FALSE);
458  $path = PATH_site . 'typo3temp/' . $this->getUniqueId('dir_');
459  $this->testNodesToDelete[] = $path;
460  $node->expects($this->once())->method('exists')->will($this->returnValue(FALSE));
461  $node->expects($this->any())->method('getAbsolutePath')->will($this->returnValue($path));
462  $this->assertInstanceOf('TYPO3\\CMS\Install\\Status\\StatusInterface', $node->_call('createDirectory'));
463  }
464 
468  public function createDirectoryReturnsErrorStatusIfDirectoryWasNotCreated() {
469  if (TYPO3_OS === 'WIN') {
470  $this->markTestSkipped('Test not available on Windows OS.');
471  }
473  $node = $this->getAccessibleMock('TYPO3\\CMS\\Install\\FolderStructure\\DirectoryNode', array('exists', 'getAbsolutePath'), array(), '', FALSE);
474  $path = PATH_site . 'typo3temp/' . $this->getUniqueId('root_');
475  mkdir($path);
476  chmod($path, 02550);
477  $subPath = $path . '/' . $this->getUniqueId('dir_');
478  $this->testNodesToDelete[] = $path;
479  $node->expects($this->once())->method('exists')->will($this->returnValue(FALSE));
480  $node->expects($this->any())->method('getAbsolutePath')->will($this->returnValue($subPath));
481  $this->assertInstanceOf('TYPO3\\CMS\Install\\Status\\StatusInterface', $node->_call('createDirectory'));
482  }
483 
488  public function createChildrenThrowsExceptionIfAChildTypeIsNotSet() {
490  $node = $this->getAccessibleMock('TYPO3\\CMS\\Install\\FolderStructure\\DirectoryNode', array('dummy'), array(), '', FALSE);
491  $brokenStructure = array(
492  array(
493  'name' => 'foo',
494  ),
495  );
496  $node->_call('createChildren', $brokenStructure);
497  }
498 
503  public function createChildrenThrowsExceptionIfAChildNameIsNotSet() {
505  $node = $this->getAccessibleMock('TYPO3\\CMS\\Install\\FolderStructure\\DirectoryNode', array('dummy'), array(), '', FALSE);
506  $brokenStructure = array(
507  array(
508  'type' => 'foo',
509  ),
510  );
511  $node->_call('createChildren', $brokenStructure);
512  }
513 
518  public function createChildrenThrowsExceptionForMultipleChildrenWithSameName() {
520  $node = $this->getAccessibleMock('TYPO3\\CMS\\Install\\FolderStructure\\DirectoryNode', array('dummy'), array(), '', FALSE);
521  $brokenStructure = array(
522  array(
523  'type' => 'TYPO3\\CMS\\install\\FolderStructure\\DirectoryNode',
524  'name' => 'foo',
525  ),
526  array(
527  'type' => 'TYPO3\\CMS\\install\\FolderStructure\\DirectoryNode',
528  'name' => 'foo',
529  ),
530  );
531  $node->_call('createChildren', $brokenStructure);
532  }
533 
537  public function getChildrenReturnsCreatedChild() {
539  $node = $this->getAccessibleMock('TYPO3\\CMS\\Install\\FolderStructure\\DirectoryNode', array('dummy'), array(), '', FALSE);
540  $parent = $this->getMock('TYPO3\CMS\Install\FolderStructure\NodeInterface', array(), array(), '', FALSE);
541  $childName = $this->getUniqueId('test_');
542  $structure = array(
543  'name' => 'foo',
544  'type' => 'TYPO3\\CMS\\install\\FolderStructure\\DirectoryNode',
545  'children' => array(
546  array(
547  'type' => 'TYPO3\\CMS\\install\\FolderStructure\\DirectoryNode',
548  'name' => $childName,
549  ),
550  ),
551  );
552  $node->__construct($structure, $parent);
553  $children = $node->_call('getChildren');
555  $child = $children[0];
556  $this->assertInstanceOf('TYPO3\\CMS\\install\\FolderStructure\\DirectoryNode', $children[0]);
557  $this->assertSame($childName, $child->getName());
558  }
559 
563  public function isWritableReturnsFalseIfNodeDoesNotExist() {
565  $node = $this->getAccessibleMock('TYPO3\\CMS\\Install\\FolderStructure\\DirectoryNode', array('getAbsolutePath'), array(), '', FALSE);
566  $path = PATH_site . 'typo3temp/' . $this->getUniqueId('dir_');
567  $node->expects($this->any())->method('getAbsolutePath')->will($this->returnValue($path));
568  $this->assertFalse($node->isWritable());
569  }
570 
574  public function isWritableReturnsTrueIfNodeExistsAndFileCanBeCreated() {
576  $node = $this->getAccessibleMock('TYPO3\\CMS\\Install\\FolderStructure\\DirectoryNode', array('getAbsolutePath'), array(), '', FALSE);
577  $path = PATH_site . 'typo3temp/' . $this->getUniqueId('root_');
579  $this->testNodesToDelete[] = $path;
580  $node->expects($this->any())->method('getAbsolutePath')->will($this->returnValue($path));
581  $this->assertTrue($node->isWritable());
582  }
583 
587  public function isWritableReturnsFalseIfNodeExistsButFileCanNotBeCreated() {
588  if (TYPO3_OS === 'WIN') {
589  $this->markTestSkipped('Test not available on Windows OS.');
590  }
591  if (function_exists('posix_getegid') && posix_getegid() === 0) {
592  $this->markTestSkipped('Test skipped if run on linux as root');
593  }
595  $node = $this->getAccessibleMock('TYPO3\\CMS\\Install\\FolderStructure\\DirectoryNode', array('getAbsolutePath'), array(), '', FALSE);
596  $path = PATH_site . 'typo3temp/' . $this->getUniqueId('root_');
598  $this->testNodesToDelete[] = $path;
599  chmod($path, 02550);
600  $node->expects($this->any())->method('getAbsolutePath')->will($this->returnValue($path));
601  $this->assertFalse($node->isWritable());
602  }
603 
607  public function isDirectoryReturnsTrueIfNameIsADirectory() {
609  $node = $this->getAccessibleMock('TYPO3\\CMS\\Install\\FolderStructure\\DirectoryNode', array('getAbsolutePath'), array(), '', FALSE);
610  $path = PATH_site . 'typo3temp/' . $this->getUniqueId('dir_');
612  $this->testNodesToDelete[] = $path;
613  $node->expects($this->any())->method('getAbsolutePath')->will($this->returnValue($path));
614  $this->assertTrue($node->_call('isDirectory'));
615  }
616 
620  public function isDirectoryReturnsFalseIfNameIsALinkToADirectory() {
621  if (TYPO3_OS === 'WIN') {
622  $this->markTestSkipped('Test not available on Windows OS.');
623  }
625  $node = $this->getAccessibleMock('TYPO3\\CMS\\Install\\FolderStructure\\DirectoryNode', array('getAbsolutePath'), array(), '', FALSE);
626  $path = PATH_site . 'typo3temp/' . $this->getUniqueId('root_');
628  $this->testNodesToDelete[] = $path;
629  $link = $this->getUniqueId('link_');
630  $dir = $this->getUniqueId('dir_');
631  mkdir($path . '/' . $dir);
632  symlink($path . '/' . $dir, $path . '/' . $link);
633  $node->expects($this->any())->method('getAbsolutePath')->will($this->returnValue($path . '/' . $link));
634  $this->assertFalse($node->_call('isDirectory'));
635  }
636 }
static mkdir_deep($directory, $deepDirectory='')
static rmdir($path, $removeNonEmpty=FALSE)
getAccessibleMock( $originalClassName, array $methods=array(), array $arguments=array(), $mockClassName='', $callOriginalConstructor=TRUE, $callOriginalClone=TRUE, $callAutoload=TRUE)
if($list_of_literals) if(!empty($literals)) if(!empty($literals)) $result
Analyse literals to prepend the N char to them if their contents aren&#39;t numeric.