‪TYPO3CMS  10.4
EnableFileServiceTest.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 
18 use org\bovigo\vfs\vfsStream;
21 use TYPO3\TestingFramework\Core\AccessibleObjectInterface;
22 use TYPO3\TestingFramework\Core\Unit\UnitTestCase;
23 
27 class ‪EnableFileServiceTest extends UnitTestCase
28 {
32  protected ‪$backupEnvironment = true;
33 
40  {
41  return [
42  'first-install-file-present' => [
43  [
44  'FIRST_INSTALL2Folder' => [],
45  'FIRST_INSTALL' => '',
46  'FIRST_INStall' => '',
47  'FIRST_INSTALL.txt' => 'with content',
48  'somethingelse' => '',
49  'dadadaFIRST_INStall' => '',
50  ],
51  [
52  'FIRST_INSTALL',
53  'FIRST_INStall',
54  'FIRST_INSTALL.txt',
55  ],
56  ],
57  'no-first-install-file' => [
58  [
59  'FIRST_INSTALL2Folder' => [],
60  'foo' => '',
61  'bar' => '',
62  'ddd.txt' => 'with content',
63  'somethingelse' => '',
64  'dadadaFIRST_INStall' => '',
65  ],
66  [],
67  ],
68  ];
69  }
70 
75  public function ‪getFirstInstallFilePaths($structure, $expected)
76  {
77  $vfs = vfsStream::setup('root');
78  vfsStream::create($structure, $vfs);
80  $subject = $this->getAccessibleMock(EnableFileService::class, ['dummy'], [], '', false);
86  'vfs://root',
90  'UNIX'
91  );
92  self::assertEquals([], array_diff($expected, $subject->_call('getFirstInstallFilePaths')));
93  }
94 
100  public function ‪removeFirstInstallFileDataProvider()
101  {
102  return [
103  'first-install-file-present' => [
104  [
105  'FIRST_INSTALL2Folder' => [],
106  'FIRST_INSTALL' => '',
107  'FIRST_INStall' => '',
108  'FIRST_INSTALL.txt' => 'with content',
109  'somethingelse' => '',
110  'dadadaFIRST_INStall' => '',
111  ],
112  [
113  '.',
114  '..',
115  'FIRST_INSTALL2Folder',
116  'somethingelse',
117  'dadadaFIRST_INStall',
118  ],
119  ],
120  'no-first-install-file' => [
121  [
122  'FIRST_INSTALL2Folder' => [],
123  'foo' => '',
124  'bar' => '',
125  'ddd.txt' => 'with content',
126  'somethingelse' => '',
127  'dadadaFIRST_INStall' => '',
128  ],
129  [
130  '.',
131  '..',
132  'FIRST_INSTALL2Folder',
133  'foo',
134  'bar',
135  'ddd.txt',
136  'somethingelse',
137  'dadadaFIRST_INStall',
138  ],
139  ],
140  ];
141  }
142 
147  public function ‪removeFirstInstallFile($structure, $expected)
148  {
149  $vfs = vfsStream::setup('root');
150  vfsStream::create($structure, $vfs);
152  $subject = $this->getAccessibleMock(EnableFileService::class, ['dummy'], [], '', false);
158  'vfs://root',
162  'UNIX'
163  );
164  $subject->_call('removeFirstInstallFile');
165 
166  self::assertEquals([], array_diff($expected, scandir('vfs://root/')));
167  }
168 }
‪TYPO3\CMS\Install\Tests\Unit\Service\EnableFileServiceTest\removeFirstInstallFileDataProvider
‪array removeFirstInstallFileDataProvider()
Definition: EnableFileServiceTest.php:99
‪TYPO3\CMS\Core\Core\Environment\getCurrentScript
‪static string getCurrentScript()
Definition: Environment.php:220
‪TYPO3\CMS\Install\Service\EnableFileService
Definition: EnableFileService.php:26
‪TYPO3\CMS\Core\Core\Environment\getContext
‪static ApplicationContext getContext()
Definition: Environment.php:133
‪TYPO3\CMS\Install\Tests\Unit\Service\EnableFileServiceTest\getFirstInstallFilePaths
‪getFirstInstallFilePaths($structure, $expected)
Definition: EnableFileServiceTest.php:74
‪TYPO3\CMS\Core\Core\Environment\getProjectPath
‪static string getProjectPath()
Definition: Environment.php:169
‪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:104
‪TYPO3\CMS\Install\Tests\Unit\Service\EnableFileServiceTest\getFirstInstallFilePathsDataProvider
‪array getFirstInstallFilePathsDataProvider()
Definition: EnableFileServiceTest.php:38
‪TYPO3\CMS\Core\Core\Environment\isComposerMode
‪static bool isComposerMode()
Definition: Environment.php:144
‪TYPO3\CMS\Install\Tests\Unit\Service\EnableFileServiceTest\removeFirstInstallFile
‪removeFirstInstallFile($structure, $expected)
Definition: EnableFileServiceTest.php:146
‪TYPO3\CMS\Install\Tests\Unit\Service\EnableFileServiceTest
Definition: EnableFileServiceTest.php:28
‪TYPO3\CMS\Core\Core\Environment
Definition: Environment.php:40
‪TYPO3\CMS\Core\Core\Environment\getConfigPath
‪static string getConfigPath()
Definition: Environment.php:210
‪TYPO3\CMS\Install\Tests\Unit\Service\EnableFileServiceTest\$backupEnvironment
‪bool $backupEnvironment
Definition: EnableFileServiceTest.php:31
‪TYPO3\CMS\Core\Core\Environment\isCli
‪static bool isCli()
Definition: Environment.php:154
‪TYPO3\CMS\Install\Tests\Unit\Service
Definition: ClearTableServiceTest.php:16
‪TYPO3\CMS\Core\Core\Environment\getVarPath
‪static string getVarPath()
Definition: Environment.php:192