TYPO3 CMS  TYPO3_7-6
EnableFileServiceTest.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 
18 
23 {
30  {
31  return [
32  'first-install-file-present' => [
33  [
34  'FIRST_INSTALL2Folder' => [],
35  'FIRST_INSTALL' => '',
36  'FIRST_INStall' => '',
37  'FIRST_INSTALL.txt' => 'with content',
38  'somethingelse' => '',
39  'dadadaFIRST_INStall' => '',
40  ],
41  [
42  'FIRST_INSTALL',
43  'FIRST_INStall',
44  'FIRST_INSTALL.txt',
45  ],
46  ],
47  'no-first-install-file' => [
48  [
49  'FIRST_INSTALL2Folder' => [],
50  'foo' => '',
51  'bar' => '',
52  'ddd.txt' => 'with content',
53  'somethingelse' => '',
54  'dadadaFIRST_INStall' => '',
55  ],
56  [],
57  ],
58  ];
59  }
60 
65  public function getFirstInstallFilePaths($structure, $expected)
66  {
67  $vfs = vfsStream::setup('root');
68  vfsStream::create($structure, $vfs);
70  $instance = $this->getAccessibleMock(\TYPO3\CMS\Install\Service\EnableFileService::class, ['dummy'], [], '', false);
71  $instance->_setStatic('sitePath', 'vfs://root/');
72  $this->assertEquals([], array_diff($expected, $instance->_call('getFirstInstallFilePaths')));
73  }
74 
81  {
82  return [
83  'first-install-file-present' => [
84  [
85  'FIRST_INSTALL2Folder' => [],
86  'FIRST_INSTALL' => '',
87  'FIRST_INStall' => '',
88  'FIRST_INSTALL.txt' => 'with content',
89  'somethingelse' => '',
90  'dadadaFIRST_INStall' => '',
91  ],
92  [
93  '.',
94  '..',
95  'FIRST_INSTALL2Folder',
96  'somethingelse',
97  'dadadaFIRST_INStall',
98  ],
99  ],
100  'no-first-install-file' => [
101  [
102  'FIRST_INSTALL2Folder' => [],
103  'foo' => '',
104  'bar' => '',
105  'ddd.txt' => 'with content',
106  'somethingelse' => '',
107  'dadadaFIRST_INStall' => '',
108  ],
109  [
110  '.',
111  '..',
112  'FIRST_INSTALL2Folder',
113  'foo',
114  'bar',
115  'ddd.txt',
116  'somethingelse',
117  'dadadaFIRST_INStall',
118  ],
119  ],
120  ];
121  }
122 
127  public function removeFirstInstallFile($structure, $expected)
128  {
129  $vfs = vfsStream::setup('root');
130  vfsStream::create($structure, $vfs);
132  $instance = $this->getAccessibleMock(\TYPO3\CMS\Install\Service\EnableFileService::class, ['dummy'], [], '', false);
133  $instance->_setStatic('sitePath', 'vfs://root/');
134  $instance->_call('removeFirstInstallFile');
135 
136  $this->assertEquals([], array_diff($expected, scandir('vfs://root/')));
137  }
138 }
getAccessibleMock( $originalClassName, $methods=[], array $arguments=[], $mockClassName='', $callOriginalConstructor=true, $callOriginalClone=true, $callAutoload=true)