‪TYPO3CMS  9.5
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 
17 use org\bovigo\vfs\vfsStream;
20 use TYPO3\TestingFramework\Core\AccessibleObjectInterface;
21 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
22 
26 class ‪EnableFileServiceTest extends UnitTestCase
27 {
31  protected ‪$backupEnvironment = true;
32 
39  {
40  return [
41  'first-install-file-present' => [
42  [
43  'FIRST_INSTALL2Folder' => [],
44  'FIRST_INSTALL' => '',
45  'FIRST_INStall' => '',
46  'FIRST_INSTALL.txt' => 'with content',
47  'somethingelse' => '',
48  'dadadaFIRST_INStall' => '',
49  ],
50  [
51  'FIRST_INSTALL',
52  'FIRST_INStall',
53  'FIRST_INSTALL.txt',
54  ],
55  ],
56  'no-first-install-file' => [
57  [
58  'FIRST_INSTALL2Folder' => [],
59  'foo' => '',
60  'bar' => '',
61  'ddd.txt' => 'with content',
62  'somethingelse' => '',
63  'dadadaFIRST_INStall' => '',
64  ],
65  [],
66  ],
67  ];
68  }
69 
74  public function ‪getFirstInstallFilePaths($structure, $expected)
75  {
76  $vfs = vfsStream::setup('root');
77  vfsStream::create($structure, $vfs);
79  $subject = $this->getAccessibleMock(EnableFileService::class, ['dummy'], [], '', false);
85  'vfs://root',
89  'UNIX'
90  );
91  $this->assertEquals([], array_diff($expected, $subject->_call('getFirstInstallFilePaths')));
92  }
93 
100  {
101  return [
102  'first-install-file-present' => [
103  [
104  'FIRST_INSTALL2Folder' => [],
105  'FIRST_INSTALL' => '',
106  'FIRST_INStall' => '',
107  'FIRST_INSTALL.txt' => 'with content',
108  'somethingelse' => '',
109  'dadadaFIRST_INStall' => '',
110  ],
111  [
112  '.',
113  '..',
114  'FIRST_INSTALL2Folder',
115  'somethingelse',
116  'dadadaFIRST_INStall',
117  ],
118  ],
119  'no-first-install-file' => [
120  [
121  'FIRST_INSTALL2Folder' => [],
122  'foo' => '',
123  'bar' => '',
124  'ddd.txt' => 'with content',
125  'somethingelse' => '',
126  'dadadaFIRST_INStall' => '',
127  ],
128  [
129  '.',
130  '..',
131  'FIRST_INSTALL2Folder',
132  'foo',
133  'bar',
134  'ddd.txt',
135  'somethingelse',
136  'dadadaFIRST_INStall',
137  ],
138  ],
139  ];
140  }
141 
146  public function ‪removeFirstInstallFile($structure, $expected)
147  {
148  $vfs = vfsStream::setup('root');
149  vfsStream::create($structure, $vfs);
151  $subject = $this->getAccessibleMock(EnableFileService::class, ['dummy'], [], '', false);
157  'vfs://root',
161  'UNIX'
162  );
163  $subject->_call('removeFirstInstallFile');
164 
165  $this->assertEquals([], array_diff($expected, scandir('vfs://root/')));
166  }
167 }
‪TYPO3\CMS\Install\Tests\Unit\Service\EnableFileServiceTest\removeFirstInstallFileDataProvider
‪array removeFirstInstallFileDataProvider()
Definition: EnableFileServiceTest.php:98
‪TYPO3\CMS\Core\Core\Environment\getCurrentScript
‪static string getCurrentScript()
Definition: Environment.php:193
‪TYPO3\CMS\Install\Service\EnableFileService
Definition: EnableFileService.php:24
‪TYPO3\CMS\Core\Core\Environment\getContext
‪static ApplicationContext getContext()
Definition: Environment.php:106
‪TYPO3\CMS\Install\Tests\Unit\Service\EnableFileServiceTest\getFirstInstallFilePaths
‪getFirstInstallFilePaths($structure, $expected)
Definition: EnableFileServiceTest.php:73
‪TYPO3\CMS\Core\Core\Environment\getProjectPath
‪static string getProjectPath()
Definition: Environment.php:142
‪TYPO3\CMS\Core\Core\Environment\initialize
‪static initialize(ApplicationContext $context, bool $cli, bool $composerMode, string $projectPath, string $publicPath, string $varPath, string $configPath, string $currentScript, string $os)
Definition: Environment.php:77
‪TYPO3\CMS\Install\Tests\Unit\Service\EnableFileServiceTest\getFirstInstallFilePathsDataProvider
‪array getFirstInstallFilePathsDataProvider()
Definition: EnableFileServiceTest.php:37
‪TYPO3\CMS\Core\Core\Environment\isComposerMode
‪static bool isComposerMode()
Definition: Environment.php:117
‪TYPO3\CMS\Install\Tests\Unit\Service\EnableFileServiceTest\removeFirstInstallFile
‪removeFirstInstallFile($structure, $expected)
Definition: EnableFileServiceTest.php:145
‪TYPO3\CMS\Install\Tests\Unit\Service\EnableFileServiceTest
Definition: EnableFileServiceTest.php:27
‪TYPO3\CMS\Core\Core\Environment
Definition: Environment.php:39
‪TYPO3\CMS\Core\Core\Environment\getConfigPath
‪static string getConfigPath()
Definition: Environment.php:183
‪TYPO3\CMS\Install\Tests\Unit\Service\EnableFileServiceTest\$backupEnvironment
‪bool $backupEnvironment
Definition: EnableFileServiceTest.php:30
‪TYPO3\CMS\Core\Core\Environment\isCli
‪static bool isCli()
Definition: Environment.php:127
‪TYPO3\CMS\Install\Tests\Unit\Service
Definition: ClearTableServiceTest.php:2
‪TYPO3\CMS\Core\Core\Environment\getVarPath
‪static string getVarPath()
Definition: Environment.php:165