‪TYPO3CMS  10.4
FileNodeTest.php
Go to the documentation of this file.
1 <?php
2 
3 /*
4  * This file is part of the TYPO3 CMS project.
5  *
6  * It is free software; you can redistribute it and/or modify it under
7  * the terms of the GNU General Public License, either version 2
8  * of the License, or any later version.
9  *
10  * For the full copyright and license information, please read the
11  * LICENSE.txt file that was distributed with this source code.
12  *
13  * The TYPO3 project - inspiring people to share!
14  */
15 
17 
28 use TYPO3\TestingFramework\Core\AccessibleObjectInterface;
29 
34 {
39  {
40  $this->expectException(InvalidArgumentException::class);
41  $this->expectExceptionCode(1366927513);
43  $node = $this->getAccessibleMock(FileNode::class, ['dummy'], [], '', false);
44  $node->__construct([], null);
45  }
46 
51  {
52  $this->expectException(InvalidArgumentException::class);
53  $this->expectExceptionCode(1366222207);
54  $parent = $this->createMock(NodeInterface::class);
56  $node = $this->getAccessibleMock(FileNode::class, ['dummy'], [], '', false);
57  $structure = [
58  'name' => 'foo/bar',
59  ];
60  $node->__construct($structure, $parent);
61  }
62 
66  public function ‪constructorSetsParent()
67  {
68  $parent = $this->createMock(NodeInterface::class);
70  $node = $this->getAccessibleMock(FileNode::class, ['dummy'], [], '', false);
71  $structure = [
72  'name' => 'foo',
73  ];
74  $node->__construct($structure, $parent);
75  self::assertSame($parent, $node->_call('getParent'));
76  }
77 
82  {
83  $parent = $this->createMock(NodeInterface::class);
85  $node = $this->getAccessibleMock(FileNode::class, ['dummy'], [], '', false);
86  $targetPermission = '0660';
87  $structure = [
88  'name' => 'foo',
89  'targetPermission' => $targetPermission,
90  ];
91  $node->__construct($structure, $parent);
92  self::assertSame($targetPermission, $node->_call('getTargetPermission'));
93  }
94 
98  public function ‪constructorSetsName()
99  {
101  $node = $this->getAccessibleMock(FileNode::class, ['dummy'], [], '', false);
102  $parent = $this->createMock(RootNodeInterface::class);
103  $name = ‪StringUtility::getUniqueId('test_');
104  $node->__construct(['name' => $name], $parent);
105  self::assertSame($name, $node->getName());
106  }
107 
112  {
113  $this->expectException(InvalidArgumentException::class);
114  $this->expectExceptionCode(1380364361);
116  $node = $this->getAccessibleMock(FileNode::class, ['dummy'], [], '', false);
117  $parent = $this->createMock(RootNodeInterface::class);
118  $structure = [
119  'name' => 'foo',
120  'targetContent' => 'foo',
121  'targetContentFile' => 'aPath',
122  ];
123  $node->__construct($structure, $parent);
124  }
125 
130  {
132  $node = $this->getAccessibleMock(FileNode::class, ['dummy'], [], '', false);
133  $parent = $this->createMock(RootNodeInterface::class);
134  $targetContent = ‪StringUtility::getUniqueId('content_');
135  $structure = [
136  'name' => 'foo',
137  'targetContent' => $targetContent,
138  ];
139  $node->__construct($structure, $parent);
140  self::assertSame($targetContent, $node->_get('targetContent'));
141  }
142 
147  {
149  $node = $this->getAccessibleMock(FileNode::class, ['dummy'], [], '', false);
150  $parent = $this->createMock(RootNodeInterface::class);
151  $targetFile = $this->‪getVirtualTestFilePath('test_');
152  $targetContent = ‪StringUtility::getUniqueId('content_');
153  file_put_contents($targetFile, $targetContent);
154  $structure = [
155  'name' => 'foo',
156  'targetContentFile' => $targetFile,
157  ];
158  $node->__construct($structure, $parent);
159  self::assertSame($targetContent, $node->_get('targetContent'));
160  }
161 
166  {
167  $this->expectException(InvalidArgumentException::class);
168  $this->expectExceptionCode(1380364362);
170  $node = $this->getAccessibleMock(FileNode::class, ['dummy'], [], '', false);
171  $parent = $this->createMock(RootNodeInterface::class);
172  $targetFile = $this->‪getVirtualTestFilePath('test_');
173  $structure = [
174  'name' => 'foo',
175  'targetContentFile' => $targetFile,
176  ];
177  $node->__construct($structure, $parent);
178  }
179 
184  {
186  $node = $this->getAccessibleMock(FileNode::class, ['dummy'], [], '', false);
187  $parent = $this->createMock(RootNodeInterface::class);
188  $structure = [
189  'name' => 'foo',
190  ];
191  $node->__construct($structure, $parent);
192  self::assertNull($node->_get('targetContent'));
193  }
194 
198  public function ‪getStatusReturnsArray()
199  {
201  $node = $this->getAccessibleMock(
202  FileNode::class,
203  ['getAbsolutePath', 'exists', 'isFile', 'isWritable', 'isPermissionCorrect', 'isContentCorrect'],
204  [],
205  '',
206  false
207  );
208  // do not use var path here, as file nodes explicitly check for public path
209  $path = ‪Environment::getPublicPath() . '/typo3temp/tests/' . ‪StringUtility::getUniqueId('dir_');
210  $node->expects(self::any())->method('getAbsolutePath')->willReturn($path);
211  $node->expects(self::any())->method('exists')->willReturn(true);
212  $node->expects(self::any())->method('isFile')->willReturn(true);
213  $node->expects(self::any())->method('isPermissionCorrect')->willReturn(true);
214  $node->expects(self::any())->method('isWritable')->willReturn(true);
215  $node->expects(self::any())->method('isContentCorrect')->willReturn(true);
216  self::assertIsArray($node->getStatus());
217  }
218 
223  {
225  $node = $this->getAccessibleMock(
226  FileNode::class,
227  ['getAbsolutePath', 'getRelativePathBelowSiteRoot', 'exists', 'isFile', 'isWritable', 'isPermissionCorrect', 'isContentCorrect'],
228  [],
229  '',
230  false
231  );
232  $path = $this->‪getVirtualTestDir('dir_');
233  $node->expects(self::any())->method('getAbsolutePath')->willReturn($path);
234  $node->expects(self::any())->method('getRelativePathBelowSiteRoot')->willReturn($path);
235  $node->expects(self::any())->method('exists')->willReturn(false);
236  $node->expects(self::any())->method('isFile')->willReturn(true);
237  $node->expects(self::any())->method('isPermissionCorrect')->willReturn(true);
238  $node->expects(self::any())->method('isWritable')->willReturn(true);
239  $node->expects(self::any())->method('isContentCorrect')->willReturn(true);
240  $statusArray = $node->getStatus();
241  self::assertSame(‪FlashMessage::WARNING, $statusArray[0]->getSeverity());
242  }
243 
248  {
250  $node = $this->getAccessibleMock(
251  FileNode::class,
252  ['getAbsolutePath', 'getRelativePathBelowSiteRoot', 'exists', 'isFile', 'isWritable', 'isPermissionCorrect', 'isContentCorrect'],
253  [],
254  '',
255  false
256  );
257  $path = $this->‪getVirtualTestFilePath('dir_');
258  touch($path);
259  $node->expects(self::any())->method('getAbsolutePath')->willReturn($path);
260  $node->expects(self::any())->method('getRelativePathBelowSiteRoot')->willReturn($path);
261  $node->expects(self::any())->method('exists')->willReturn(true);
262  $node->expects(self::any())->method('isFile')->willReturn(false);
263  $node->expects(self::any())->method('isPermissionCorrect')->willReturn(true);
264  $node->expects(self::any())->method('isWritable')->willReturn(true);
265  $node->expects(self::any())->method('isContentCorrect')->willReturn(true);
266  $statusArray = $node->getStatus();
267  self::assertSame(‪FlashMessage::ERROR, $statusArray[0]->getSeverity());
268  }
269 
274  {
276  $node = $this->getAccessibleMock(
277  FileNode::class,
278  ['getAbsolutePath', 'getRelativePathBelowSiteRoot', 'exists', 'isFile', 'isWritable', 'isPermissionCorrect', 'isContentCorrect'],
279  [],
280  '',
281  false
282  );
283  $path = $this->‪getVirtualTestFilePath('dir_');
284  touch($path);
285  $node->expects(self::any())->method('getAbsolutePath')->willReturn($path);
286  $node->expects(self::any())->method('getRelativePathBelowSiteRoot')->willReturn($path);
287  $node->expects(self::any())->method('exists')->willReturn(true);
288  $node->expects(self::any())->method('isFile')->willReturn(true);
289  $node->expects(self::any())->method('isPermissionCorrect')->willReturn(true);
290  $node->expects(self::any())->method('isWritable')->willReturn(false);
291  $node->expects(self::any())->method('isContentCorrect')->willReturn(true);
292  $statusArray = $node->getStatus();
293  self::assertSame(‪FlashMessage::NOTICE, $statusArray[0]->getSeverity());
294  }
295 
300  {
302  $node = $this->getAccessibleMock(
303  FileNode::class,
304  ['getAbsolutePath', 'getRelativePathBelowSiteRoot', 'exists', 'isFile', 'isWritable', 'isPermissionCorrect', 'isContentCorrect'],
305  [],
306  '',
307  false
308  );
309  $path = $this->‪getVirtualTestFilePath('dir_');
310  touch($path);
311  $node->expects(self::any())->method('getAbsolutePath')->willReturn($path);
312  $node->expects(self::any())->method('getRelativePathBelowSiteRoot')->willReturn($path);
313  $node->expects(self::any())->method('exists')->willReturn(true);
314  $node->expects(self::any())->method('isFile')->willReturn(true);
315  $node->expects(self::any())->method('isPermissionCorrect')->willReturn(false);
316  $node->expects(self::any())->method('isWritable')->willReturn(true);
317  $node->expects(self::any())->method('isContentCorrect')->willReturn(true);
318  $statusArray = $node->getStatus();
319  self::assertSame(‪FlashMessage::NOTICE, $statusArray[0]->getSeverity());
320  }
321 
326  {
328  $node = $this->getAccessibleMock(
329  FileNode::class,
330  ['getAbsolutePath', 'getRelativePathBelowSiteRoot', 'exists', 'isFile', 'isWritable', 'isPermissionCorrect', 'isContentCorrect'],
331  [],
332  '',
333  false
334  );
335  $path = $this->‪getVirtualTestFilePath('dir_');
336  touch($path);
337  $node->expects(self::any())->method('getAbsolutePath')->willReturn($path);
338  $node->expects(self::any())->method('getRelativePathBelowSiteRoot')->willReturn($path);
339  $node->expects(self::any())->method('exists')->willReturn(true);
340  $node->expects(self::any())->method('isFile')->willReturn(true);
341  $node->expects(self::any())->method('isPermissionCorrect')->willReturn(true);
342  $node->expects(self::any())->method('isWritable')->willReturn(true);
343  $node->expects(self::any())->method('isContentCorrect')->willReturn(false);
344  $statusArray = $node->getStatus();
345  self::assertSame(‪FlashMessage::NOTICE, $statusArray[0]->getSeverity());
346  }
347 
352  {
354  $node = $this->getAccessibleMock(
355  FileNode::class,
356  ['getAbsolutePath', 'getRelativePathBelowSiteRoot', 'exists', 'isFile', 'isWritable', 'isPermissionCorrect', 'isContentCorrect'],
357  [],
358  '',
359  false
360  );
361  $path = $this->‪getVirtualTestFilePath('dir_');
362  touch($path);
363  $node->expects(self::any())->method('getAbsolutePath')->willReturn($path);
364  $node->expects(self::any())->method('getRelativePathBelowSiteRoot')->willReturn($path);
365  $node->expects(self::any())->method('exists')->willReturn(true);
366  $node->expects(self::any())->method('isFile')->willReturn(true);
367  $node->expects(self::any())->method('isPermissionCorrect')->willReturn(true);
368  $node->expects(self::any())->method('isWritable')->willReturn(true);
369  $node->expects(self::any())->method('isContentCorrect')->willReturn(true);
370  $statusArray = $node->getStatus();
371  self::assertSame(‪FlashMessage::OK, $statusArray[0]->getSeverity());
372  }
373 
378  {
380  $node = $this->getAccessibleMock(
381  FileNode::class,
382  ['fixSelf'],
383  [],
384  '',
385  false
386  );
387  $uniqueReturn = [‪StringUtility::getUniqueId('foo_')];
388  $node->expects(self::once())->method('fixSelf')->willReturn($uniqueReturn);
389  self::assertSame($uniqueReturn, $node->fix());
390  }
391 
396  {
398  $node = $this->getAccessibleMock(
399  FileNode::class,
400  ['exists', 'createFile', 'setContent', 'getAbsolutePath', 'isFile', 'isPermissionCorrect'],
401  [],
402  '',
403  false
404  );
405  $node->expects(self::any())->method('exists')->willReturn(false);
406  $node->expects(self::any())->method('isFile')->willReturn(true);
407  $node->expects(self::any())->method('isPermissionCorrect')->willReturn(true);
408  $message = new ‪FlashMessage('foo');
409  $node->expects(self::once())->method('createFile')->willReturn($message);
410  $actualReturn = $node->_call('fixSelf');
411  $actualReturn = $actualReturn[0];
412  self::assertSame($message, $actualReturn);
413  }
414 
419  {
421  $node = $this->getAccessibleMock(
422  FileNode::class,
423  ['exists', 'createFile', 'setContent', 'getAbsolutePath', 'isFile', 'isPermissionCorrect'],
424  [],
425  '',
426  false
427  );
428  $node->expects(self::any())->method('exists')->willReturn(false);
429  $node->expects(self::any())->method('isFile')->willReturn(true);
430  $node->expects(self::any())->method('isPermissionCorrect')->willReturn(true);
431  $message1 = new ‪FlashMessage('foo');
432  $node->expects(self::any())->method('createFile')->willReturn($message1);
433  $node->_set('targetContent', 'foo');
434  $message2 = new ‪FlashMessage('foo');
435  $node->expects(self::once())->method('setContent')->willReturn($message2);
436  $actualReturn = $node->_call('fixSelf');
437  $actualReturn = $actualReturn[1];
438  self::assertSame($message2, $actualReturn);
439  }
440 
445  {
447  $node = $this->getAccessibleMock(
448  FileNode::class,
449  ['exists', 'createFile', 'setContent', 'getAbsolutePath', 'isFile', 'isPermissionCorrect'],
450  [],
451  '',
452  false
453  );
454  $node->expects(self::any())->method('exists')->willReturn(false);
455  $node->expects(self::any())->method('isFile')->willReturn(true);
456  $node->expects(self::any())->method('isPermissionCorrect')->willReturn(true);
457  $message = new ‪FlashMessage('foo', '', ‪FlashMessage::ERROR);
458  $node->expects(self::any())->method('createFile')->willReturn($message);
459  $node->_set('targetContent', 'foo');
460  $node->expects(self::never())->method('setContent');
461  $node->_call('fixSelf');
462  }
463 
468  {
470  $node = $this->getAccessibleMock(
471  FileNode::class,
472  ['exists', 'createFile', 'setContent', 'getAbsolutePath', 'isFile', 'isPermissionCorrect'],
473  [],
474  '',
475  false
476  );
477  $node->expects(self::any())->method('exists')->willReturn(false);
478  $node->expects(self::any())->method('isFile')->willReturn(true);
479  $node->expects(self::any())->method('isPermissionCorrect')->willReturn(true);
480  $message = new ‪FlashMessage('foo');
481  $node->expects(self::any())->method('createFile')->willReturn($message);
482  $node->_set('targetContent', null);
483  $node->expects(self::never())->method('setContent');
484  $node->_call('fixSelf');
485  }
486 
491  {
493  $node = $this->getAccessibleMock(
494  FileNode::class,
495  ['exists', 'createFile', 'getAbsolutePath', 'isFile', 'isPermissionCorrect', 'fixPermission'],
496  [],
497  '',
498  false
499  );
500  $node->expects(self::any())->method('exists')->willReturn(true);
501  $node->expects(self::any())->method('isFile')->willReturn(true);
502  $node->expects(self::any())->method('isPermissionCorrect')->willReturn(false);
503  $message = new ‪FlashMessage('foo');
504  $node->expects(self::once())->method('fixPermission')->willReturn($message);
505  self::assertSame([$message], $node->_call('fixSelf'));
506  }
507 
512  {
514  $node = $this->getAccessibleMock(
515  FileNode::class,
516  ['exists', 'createFile', 'getAbsolutePath', 'isFile', 'isPermissionCorrect', 'getRelativePathBelowSiteRoot'],
517  [],
518  '',
519  false
520  );
521  $node->expects(self::any())->method('exists')->willReturn(true);
522  $node->expects(self::once())->method('isFile')->willReturn(false);
523  $node->expects(self::any())->method('isPermissionCorrect')->willReturn(true);
524  $resultArray = $node->_call('fixSelf');
525  }
526 
531  {
532  $node = $this->getAccessibleMock(
533  FileNode::class,
534  ['exists', 'isFile', 'isPermissionCorrect'],
535  [],
536  '',
537  false
538  );
539  $node->expects(self::any())->method('exists')->willReturn(true);
540  $node->expects(self::any())->method('isFile')->willReturn(true);
541  $node->expects(self::any())->method('isPermissionCorrect')->willReturn(true);
542  self::assertIsArray($node->_call('fixSelf'));
543  }
544 
549  {
550  $this->expectException(Exception::class);
551  $this->expectExceptionCode(1366398198);
553  $node = $this->getAccessibleMock(FileNode::class, ['exists', 'getAbsolutePath'], [], '', false);
554  $node->expects(self::once())->method('getAbsolutePath')->willReturn('');
555  $node->expects(self::once())->method('exists')->willReturn(true);
556  $node->_call('createFile');
557  }
558 
563  {
565  $node = $this->getAccessibleMock(FileNode::class, ['exists', 'getAbsolutePath', 'getRelativePathBelowSiteRoot'], [], '', false);
566  $path = $this->‪getVirtualTestFilePath('file_');
567  $node->expects(self::once())->method('exists')->willReturn(false);
568  $node->expects(self::any())->method('getAbsolutePath')->willReturn($path);
569  $node->expects(self::any())->method('getRelativePathBelowSiteRoot')->willReturn($path);
570  self::assertSame(‪FlashMessage::OK, $node->_call('createFile')->getSeverity());
571  }
572 
576  public function ‪createFileCreatesFile()
577  {
579  $node = $this->getAccessibleMock(FileNode::class, ['exists', 'getAbsolutePath', 'getRelativePathBelowSiteRoot'], [], '', false);
580  $path = $this->‪getVirtualTestFilePath('file_');
581  $node->expects(self::once())->method('exists')->willReturn(false);
582  $node->expects(self::any())->method('getAbsolutePath')->willReturn($path);
583  $node->expects(self::any())->method('getRelativePathBelowSiteRoot')->willReturn($path);
584  $node->_call('createFile');
585  self::assertTrue(is_file($path));
586  }
587 
592  {
594  $node = $this->getAccessibleMock(FileNode::class, ['exists', 'getAbsolutePath', 'getRelativePathBelowSiteRoot'], [], '', false);
595  $path = $this->‪getVirtualTestDir();
596  chmod($path, 02550);
597  $subPath = $path . '/' . ‪StringUtility::getUniqueId('file_');
598  $node->expects(self::once())->method('exists')->willReturn(false);
599  $node->expects(self::any())->method('getAbsolutePath')->willReturn($subPath);
600  $node->expects(self::any())->method('getRelativePathBelowSiteRoot')->willReturn($subPath);
601  self::assertSame(‪FlashMessage::ERROR, $node->_call('createFile')->getSeverity());
602  }
603 
608  {
609  $this->expectException(Exception::class);
610  $this->expectExceptionCode(1367056363);
612  $node = $this->getAccessibleMock(FileNode::class, ['getAbsolutePath'], [], '', false);
613  $path = $this->‪getVirtualTestDir('dir_');
614  $node->expects(self::any())->method('getAbsolutePath')->willReturn($path);
615  $node->_call('isContentCorrect');
616  }
617 
622  {
624  $node = $this->getAccessibleMock(FileNode::class, ['getAbsolutePath'], [], '', false);
625  $path = $this->‪getVirtualTestFilePath('file_');
626  touch($path);
627  $node->expects(self::any())->method('getAbsolutePath')->willReturn($path);
628  $node->_set('targetContent', null);
629  self::assertTrue($node->_call('isContentCorrect'));
630  }
631 
636  {
638  $node = $this->getAccessibleMock(FileNode::class, ['getAbsolutePath'], [], '', false);
639  $path = $this->‪getVirtualTestFilePath('file_');
640  $content = ‪StringUtility::getUniqueId('content_');
641  file_put_contents($path, $content);
642  $node->expects(self::any())->method('getAbsolutePath')->willReturn($path);
643  $node->_set('targetContent', $content);
644  self::assertTrue($node->_call('isContentCorrect'));
645  }
646 
651  {
653  $node = $this->getAccessibleMock(FileNode::class, ['getAbsolutePath'], [], '', false);
654  $path = $this->‪getVirtualTestFilePath('file_');
655  $content = ‪StringUtility::getUniqueId('content1_');
656  $targetContent = ‪StringUtility::getUniqueId('content2_');
657  file_put_contents($path, $content);
658  $node->expects(self::any())->method('getAbsolutePath')->willReturn($path);
659  $node->_set('targetContent', $targetContent);
660  self::assertFalse($node->_call('isContentCorrect'));
661  }
662 
667  {
668  $parent = $this->createMock(NodeInterface::class);
670  $node = $this->getAccessibleMock(FileNode::class, ['getCurrentPermission', 'isWindowsOs'], [], '', false);
671  $node->expects(self::any())->method('isWindowsOs')->willReturn(false);
672  $node->expects(self::any())->method('getCurrentPermission')->willReturn('0664');
673  $targetPermission = '0664';
674  $structure = [
675  'name' => 'foo',
676  'targetPermission' => $targetPermission,
677  ];
678  $node->__construct($structure, $parent);
679  self::assertTrue($node->_call('isPermissionCorrect'));
680  }
681 
686  {
687  $this->expectException(Exception::class);
688  $this->expectExceptionCode(1367060201);
690  $node = $this->getAccessibleMock(FileNode::class, ['getAbsolutePath'], [], '', false);
691  $path = $this->‪getVirtualTestDir('dir_');
692  $node->expects(self::any())->method('getAbsolutePath')->willReturn($path);
693  $node->_set('targetContent', 'foo');
694  $node->_call('setContent');
695  }
696 
701  {
702  $this->expectException(Exception::class);
703  $this->expectExceptionCode(1367060202);
705  $node = $this->getAccessibleMock(FileNode::class, ['getAbsolutePath'], [], '', false);
706  $path = $this->‪getVirtualTestFilePath('file_');
707  touch($path);
708  $node->expects(self::any())->method('getAbsolutePath')->willReturn($path);
709  $node->_set('targetContent', null);
710  $node->_call('setContent');
711  }
712 
717  {
719  $node = $this->getAccessibleMock(FileNode::class, ['getAbsolutePath', 'getRelativePathBelowSiteRoot'], [], '', false);
720  $path = $this->‪getVirtualTestFilePath('file_');
721  touch($path);
722  $node->expects(self::any())->method('getAbsolutePath')->willReturn($path);
723  $targetContent = ‪StringUtility::getUniqueId('content_');
724  $node->_set('targetContent', $targetContent);
725  $node->_call('setContent');
726  $resultContent = file_get_contents($path);
727  self::assertSame($targetContent, $resultContent);
728  }
729 
734  {
736  $node = $this->getAccessibleMock(FileNode::class, ['getAbsolutePath', 'getRelativePathBelowSiteRoot'], [], '', false);
737  $path = $this->‪getVirtualTestFilePath('file_');
738  touch($path);
739  $node->expects(self::any())->method('getAbsolutePath')->willReturn($path);
740  $targetContent = ‪StringUtility::getUniqueId('content_');
741  $node->_set('targetContent', $targetContent);
742  self::assertSame(‪FlashMessage::OK, $node->_call('setContent')->getSeverity());
743  }
744 
749  {
750  if (function_exists('posix_getegid') && posix_getegid() === 0) {
751  self::markTestSkipped('Test skipped if run on linux as root');
752  }
754  $node = $this->getAccessibleMock(FileNode::class, ['getAbsolutePath', 'getRelativePathBelowSiteRoot'], [], '', false);
755  ‪$dir = $this->‪getVirtualTestDir('dir_');
756  $file = ‪$dir . '/' . ‪StringUtility::getUniqueId('file_');
757  touch($file);
758  chmod($file, 0440);
759  $node->expects(self::any())->method('getAbsolutePath')->willReturn($file);
760  $targetContent = ‪StringUtility::getUniqueId('content_');
761  $node->_set('targetContent', $targetContent);
762  self::assertSame(‪FlashMessage::ERROR, $node->_call('setContent')->getSeverity());
763  }
764 
769  {
771  $node = $this->getAccessibleMock(FileNode::class, ['getAbsolutePath', 'getRelativePathBelowSiteRoot'], [], '', false);
772  $path = $this->‪getVirtualTestFilePath('file_');
773  touch($path);
774  $node->expects(self::any())->method('getAbsolutePath')->willReturn($path);
775  self::assertTrue($node->_call('isFile'));
776  }
777 
783  {
785  $node = $this->getAccessibleMock(FileNode::class, ['getAbsolutePath'], [], '', false);
786  $path = ‪Environment::getVarPath() . '/tests/' . ‪StringUtility::getUniqueId('root_');
788  $this->testFilesToDelete[] = $path;
789  $link = ‪StringUtility::getUniqueId('link_');
790  $file = ‪StringUtility::getUniqueId('file_');
791  touch($path . '/' . $file);
792  symlink($path . '/' . $file, $path . '/' . $link);
793  $node->expects(self::any())->method('getAbsolutePath')->willReturn($path . '/' . $link);
794  self::assertFalse($node->_call('isFile'));
795  }
796 }
‪TYPO3\CMS\Install\Tests\Unit\FolderStructure\FileNodeTest\getStatusReturnsArrayWithNoticeStatusIfFileExistsButContentIsNotCorrect
‪getStatusReturnsArrayWithNoticeStatusIfFileExistsButContentIsNotCorrect()
Definition: FileNodeTest.php:325
‪TYPO3\CMS\Install\Tests\Unit\FolderStructure\FileNodeTest
Definition: FileNodeTest.php:34
‪TYPO3\CMS\Install\Tests\Unit\FolderStructure\FileNodeTest\createFileReturnsOkStatusIfFileWasCreated
‪createFileReturnsOkStatusIfFileWasCreated()
Definition: FileNodeTest.php:562
‪TYPO3\CMS\Install\Tests\Unit\FolderStructure\FileNodeTest\fixSelfDoesNotCallSetContentIfFileTargetContentIsNull
‪fixSelfDoesNotCallSetContentIfFileTargetContentIsNull()
Definition: FileNodeTest.php:467
‪TYPO3\CMS\Install\Tests\Unit\FolderStructure\FileNodeTest\createFileReturnsErrorStatusIfFileWasNotCreated
‪createFileReturnsErrorStatusIfFileWasNotCreated()
Definition: FileNodeTest.php:591
‪TYPO3\CMS\Install\Tests\Unit\FolderStructureTestCase\getVirtualTestDir
‪string getVirtualTestDir($prefix='root_')
Definition: FolderStructureTestCase.php:34
‪TYPO3\CMS\Core\Core\Environment\getPublicPath
‪static string getPublicPath()
Definition: Environment.php:180
‪TYPO3\CMS\Install\Tests\Unit\FolderStructure\FileNodeTest\createFileCreatesFile
‪createFileCreatesFile()
Definition: FileNodeTest.php:576
‪TYPO3\CMS\Install\Tests\Unit\FolderStructure\FileNodeTest\getStatusReturnsArrayNoticeStatusIfFileExistsButIsNotWritable
‪getStatusReturnsArrayNoticeStatusIfFileExistsButIsNotWritable()
Definition: FileNodeTest.php:273
‪TYPO3\CMS\Install\Tests\Unit\FolderStructure\FileNodeTest\setContentReturnsOkStatusIfContentWasSuccessfullySet
‪setContentReturnsOkStatusIfContentWasSuccessfullySet()
Definition: FileNodeTest.php:733
‪TYPO3\CMS\Install\Tests\Unit\FolderStructure\FileNodeTest\setContentSetsContentToFile
‪setContentSetsContentToFile()
Definition: FileNodeTest.php:716
‪TYPO3\CMS\Install\Tests\Unit\FolderStructure\FileNodeTest\setContentThrowsExceptionIfTargetIsNotAFile
‪setContentThrowsExceptionIfTargetIsNotAFile()
Definition: FileNodeTest.php:685
‪TYPO3\CMS\Install\Tests\Unit\FolderStructure\FileNodeTest\fixSelfReturnsArrayOfStatusMessages
‪fixSelfReturnsArrayOfStatusMessages()
Definition: FileNodeTest.php:530
‪TYPO3\CMS\Install\Tests\Unit\FolderStructure\FileNodeTest\isContentCorrectReturnsTrueIfTargetContentEqualsCurrentContent
‪isContentCorrectReturnsTrueIfTargetContentEqualsCurrentContent()
Definition: FileNodeTest.php:635
‪TYPO3\CMS\Install\Tests\Unit\FolderStructure\FileNodeTest\getStatusReturnsArrayWithWarningStatusIFileNotExists
‪getStatusReturnsArrayWithWarningStatusIFileNotExists()
Definition: FileNodeTest.php:222
‪TYPO3\CMS\Install\Tests\Unit\FolderStructure\FileNodeTest\getStatusReturnsArrayWithOkStatusIfFileExistsAndPermissionAreCorrect
‪getStatusReturnsArrayWithOkStatusIfFileExistsAndPermissionAreCorrect()
Definition: FileNodeTest.php:351
‪TYPO3\CMS\Install\Tests\Unit\FolderStructure\FileNodeTest\createFileThrowsExceptionIfNodeExists
‪createFileThrowsExceptionIfNodeExists()
Definition: FileNodeTest.php:548
‪TYPO3\CMS\Install\FolderStructure\RootNodeInterface
Definition: RootNodeInterface.php:22
‪$dir
‪$dir
Definition: validateRstFiles.php:213
‪TYPO3\CMS\Install\Tests\Unit\FolderStructure\FileNodeTest\getStatusReturnsArray
‪getStatusReturnsArray()
Definition: FileNodeTest.php:198
‪TYPO3\CMS\Install\Tests\Unit\FolderStructure\FileNodeTest\getStatusReturnsArrayWithNoticeStatusIfFileExistsButPermissionAreNotCorrect
‪getStatusReturnsArrayWithNoticeStatusIfFileExistsButPermissionAreNotCorrect()
Definition: FileNodeTest.php:299
‪TYPO3\CMS\Install\Tests\Unit\FolderStructure\FileNodeTest\constructorSetsParent
‪constructorSetsParent()
Definition: FileNodeTest.php:66
‪TYPO3\CMS\Install\FolderStructure\Exception\InvalidArgumentException
Definition: InvalidArgumentException.php:24
‪TYPO3\CMS\Core\Messaging\AbstractMessage\WARNING
‪const WARNING
Definition: AbstractMessage.php:30
‪TYPO3\CMS\Install\Tests\Unit\FolderStructure\FileNodeTest\constructorThrowsExceptionIfNameContainsForwardSlash
‪constructorThrowsExceptionIfNameContainsForwardSlash()
Definition: FileNodeTest.php:50
‪TYPO3\CMS\Install\Tests\Unit\FolderStructure\FileNodeTest\setContentReturnsErrorStatusIfContentCanNotBeSetSet
‪setContentReturnsErrorStatusIfContentCanNotBeSetSet()
Definition: FileNodeTest.php:748
‪TYPO3\CMS\Core\Utility\GeneralUtility\mkdir_deep
‪static mkdir_deep($directory)
Definition: GeneralUtility.php:2022
‪TYPO3\CMS\Install\Tests\Unit\FolderStructure
Definition: AbstractNodeTest.php:16
‪TYPO3\CMS\Install\Tests\Unit\FolderStructure\FileNodeTest\fixSelfCallsCreateFileIfFileDoesNotExistAndReturnsResult
‪fixSelfCallsCreateFileIfFileDoesNotExistAndReturnsResult()
Definition: FileNodeTest.php:395
‪TYPO3\CMS\Install\Tests\Unit\FolderStructure\FileNodeTest\constructorSetsTargetPermission
‪constructorSetsTargetPermission()
Definition: FileNodeTest.php:81
‪TYPO3\CMS\Install\Tests\Unit\FolderStructure\FileNodeTest\isPermissionCorrectReturnsTrueIfTargetPermissionAndCurrentPermissionAreIdentical
‪isPermissionCorrectReturnsTrueIfTargetPermissionAndCurrentPermissionAreIdentical()
Definition: FileNodeTest.php:666
‪TYPO3\CMS\Install\FolderStructure\FileNode
Definition: FileNode.php:26
‪TYPO3\CMS\Install\Tests\Unit\FolderStructure\FileNodeTest\isFileReturnsTrueIfNameIsFile
‪isFileReturnsTrueIfNameIsFile()
Definition: FileNodeTest.php:768
‪TYPO3\CMS\Install\Tests\Unit\FolderStructure\FileNodeTest\fixSelfDoesNotCallSetContentIfFileCreationFailed
‪fixSelfDoesNotCallSetContentIfFileCreationFailed()
Definition: FileNodeTest.php:444
‪TYPO3\CMS\Install\Tests\Unit\FolderStructure\FileNodeTest\isContentCorrectThrowsExceptionIfTargetIsNotAFile
‪isContentCorrectThrowsExceptionIfTargetIsNotAFile()
Definition: FileNodeTest.php:607
‪TYPO3\CMS\Install\Tests\Unit\FolderStructure\FileNodeTest\getStatusReturnsArrayWithErrorStatusIfNodeIsNotAFile
‪getStatusReturnsArrayWithErrorStatusIfNodeIsNotAFile()
Definition: FileNodeTest.php:247
‪TYPO3\CMS\Install\Tests\Unit\FolderStructure\FileNodeTest\isContentCorrectReturnsTrueIfTargetContentPropertyIsNull
‪isContentCorrectReturnsTrueIfTargetContentPropertyIsNull()
Definition: FileNodeTest.php:621
‪TYPO3\CMS\Install\Tests\Unit\FolderStructure\FileNodeTest\fixSelfCallsFixPermissionIfFileExistsButPermissionAreWrong
‪fixSelfCallsFixPermissionIfFileExistsButPermissionAreWrong()
Definition: FileNodeTest.php:511
‪TYPO3\CMS\Install\Tests\Unit\FolderStructure\FileNodeTest\targetContentIsNullIfNotGiven
‪targetContentIsNullIfNotGiven()
Definition: FileNodeTest.php:183
‪TYPO3\CMS\Install\Tests\Unit\FolderStructure\FileNodeTest\fixSelfReturnsErrorStatusIfNodeExistsButIsNotAFileAndReturnsResult
‪fixSelfReturnsErrorStatusIfNodeExistsButIsNotAFileAndReturnsResult()
Definition: FileNodeTest.php:490
‪TYPO3\CMS\Core\Messaging\AbstractMessage\OK
‪const OK
Definition: AbstractMessage.php:29
‪TYPO3\CMS\Install\Tests\Unit\FolderStructure\FileNodeTest\isContentCorrectReturnsFalseIfTargetContentNotEqualsCurrentContent
‪isContentCorrectReturnsFalseIfTargetContentNotEqualsCurrentContent()
Definition: FileNodeTest.php:650
‪TYPO3\CMS\Install\Tests\Unit\FolderStructure\FileNodeTest\isFileReturnsFalseIfNameIsALinkFile
‪isFileReturnsFalseIfNameIsALinkFile()
Definition: FileNodeTest.php:782
‪TYPO3\CMS\Core\Utility\StringUtility\getUniqueId
‪static string getUniqueId($prefix='')
Definition: StringUtility.php:92
‪TYPO3\CMS\Core\Messaging\FlashMessage
Definition: FlashMessage.php:24
‪TYPO3\CMS\Install\Tests\Unit\FolderStructure\FileNodeTest\constructorThrowsExceptionIfBothTargetContentAndTargetContentFileAreSet
‪constructorThrowsExceptionIfBothTargetContentAndTargetContentFileAreSet()
Definition: FileNodeTest.php:111
‪TYPO3\CMS\Core\Core\Environment
Definition: Environment.php:40
‪TYPO3\CMS\Install\Tests\Unit\FolderStructure\FileNodeTest\constructorThrowsExceptionIfParentIsNull
‪constructorThrowsExceptionIfParentIsNull()
Definition: FileNodeTest.php:38
‪TYPO3\CMS\Core\Messaging\AbstractMessage\NOTICE
‪const NOTICE
Definition: AbstractMessage.php:27
‪TYPO3\CMS\Install\Tests\Unit\FolderStructure\FileNodeTest\constructorSetsTargetContentToContentOfTargetContentFile
‪constructorSetsTargetContentToContentOfTargetContentFile()
Definition: FileNodeTest.php:146
‪TYPO3\CMS\Install\Tests\Unit\FolderStructure\FileNodeTest\constructorSetsName
‪constructorSetsName()
Definition: FileNodeTest.php:98
‪TYPO3\CMS\Install\Tests\Unit\FolderStructure\FileNodeTest\constructorThrowsExceptionIfTargetContentFileDoesNotExist
‪constructorThrowsExceptionIfTargetContentFileDoesNotExist()
Definition: FileNodeTest.php:165
‪TYPO3\CMS\Install\Tests\Unit\FolderStructure\FileNodeTest\fixSelfCallsSetsContentIfFileCreationWasSuccessfulAndTargetContentIsNotNullAndReturnsResult
‪fixSelfCallsSetsContentIfFileCreationWasSuccessfulAndTargetContentIsNotNullAndReturnsResult()
Definition: FileNodeTest.php:418
‪TYPO3\CMS\Install\Tests\Unit\FolderStructureTestCase
Definition: FolderStructureTestCase.php:27
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:46
‪TYPO3\CMS\Core\Utility\StringUtility
Definition: StringUtility.php:22
‪TYPO3\CMS\Install\FolderStructure\NodeInterface
Definition: NodeInterface.php:24
‪TYPO3\CMS\Install\Tests\Unit\FolderStructure\FileNodeTest\constructorSetsTargetContent
‪constructorSetsTargetContent()
Definition: FileNodeTest.php:129
‪TYPO3\CMS\Install\FolderStructure\Exception
Definition: InvalidArgumentException.php:16
‪TYPO3\CMS\Core\Messaging\AbstractMessage\ERROR
‪const ERROR
Definition: AbstractMessage.php:31
‪TYPO3\CMS\Install\Tests\Unit\FolderStructure\FileNodeTest\fixCallsFixSelfAndReturnsItsResult
‪fixCallsFixSelfAndReturnsItsResult()
Definition: FileNodeTest.php:377
‪TYPO3\CMS\Install\Tests\Unit\FolderStructure\FileNodeTest\setContentThrowsExceptionIfTargetContentIsNull
‪setContentThrowsExceptionIfTargetContentIsNull()
Definition: FileNodeTest.php:700
‪TYPO3\CMS\Core\Core\Environment\getVarPath
‪static string getVarPath()
Definition: Environment.php:192
‪TYPO3\CMS\Install\Tests\Unit\FolderStructureTestCase\getVirtualTestFilePath
‪string getVirtualTestFilePath($prefix='file_')
Definition: FolderStructureTestCase.php:48