‪TYPO3CMS  ‪main
EnableFileServiceTest.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
5 /*
6  * This file is part of the TYPO3 CMS project.
7  *
8  * It is free software; you can redistribute it and/or modify it under
9  * the terms of the GNU General Public License, either version 2
10  * of the License, or any later version.
11  *
12  * For the full copyright and license information, please read the
13  * LICENSE.txt file that was distributed with this source code.
14  *
15  * The TYPO3 project - inspiring people to share!
16  */
17 
19 
22 use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase;
23 
24 final class ‪EnableFileServiceTest extends FunctionalTestCase
25 {
26  protected bool ‪$initializeDatabase = false;
27 
28  public function ‪tearDown(): void
29  {
30  $publicPath = ‪Environment::getPublicPath();
31  @rmdir($publicPath . '/FIRST_INSTALL2Folder');
32  @unlink($publicPath . '/FIRST_INSTALL');
33  @unlink($publicPath . '/FIRST_INStall');
34  @unlink($publicPath . '/FIRST_INSTALL.txt');
35  @unlink($publicPath . '/foo');
36  @unlink($publicPath . '/bar');
37  @unlink($publicPath . '/ddd.txt');
38  @unlink($publicPath . '/somethingelse');
39  @unlink($publicPath . '/dadadaFIRST_INStall');
40  parent::tearDown();
41  }
42 
47  {
48  $publicPath = ‪Environment::getPublicPath();
49  mkdir($publicPath . '/FIRST_INSTALL2Folder');
50  file_put_contents($publicPath . '/FIRST_INSTALL', '');
51  file_put_contents($publicPath . '/FIRST_INStall', '');
52  file_put_contents($publicPath . '/FIRST_INSTALL.txt', 'with content');
53  file_put_contents($publicPath . '/somethingelse', '');
54  file_put_contents($publicPath . '/dadadaFIRST_INStall', '');
55  $expected = [
56  'FIRST_INSTALL',
57  'FIRST_INStall',
58  'FIRST_INSTALL.txt',
59  ];
60  $subject = $this->getAccessibleMock(EnableFileService::class, null);
61  self::assertEquals([], array_diff($expected, $subject->_call('getFirstInstallFilePaths')));
62  }
63 
68  {
69  $publicPath = ‪Environment::getPublicPath();
70  mkdir($publicPath . '/FIRST_INSTALL2Folder');
71  file_put_contents($publicPath . '/foo', '');
72  file_put_contents($publicPath . '/bar', '');
73  file_put_contents($publicPath . '/ddd.txt', 'with content');
74  file_put_contents($publicPath . '/somethingelse', '');
75  file_put_contents($publicPath . '/dadadaFIRST_INStall', '');
76  $subject = $this->getAccessibleMock(EnableFileService::class, null);
77  self::assertEquals([], array_diff([], $subject->_call('getFirstInstallFilePaths')));
78  }
79 
84  {
85  $publicPath = ‪Environment::getPublicPath();
86  mkdir($publicPath . '/FIRST_INSTALL2Folder');
87  file_put_contents($publicPath . '/FIRST_INSTALL', '');
88  file_put_contents($publicPath . '/FIRST_INStall', '');
89  file_put_contents($publicPath . '/FIRST_INSTALL.txt', 'with content');
90  file_put_contents($publicPath . '/somethingelse', '');
91  file_put_contents($publicPath . '/dadadaFIRST_INStall', '');
92  $expected = scandir($publicPath);
93  unset($expected[2], $expected[3], $expected[5]);
94  $subject = $this->getAccessibleMock(EnableFileService::class, null);
95  $subject->_call('removeFirstInstallFile');
96  self::assertEquals(array_values($expected), array_values(scandir($publicPath)));
97  }
98 
103  {
104  $publicPath = ‪Environment::getPublicPath();
105  mkdir($publicPath . '/FIRST_INSTALL2Folder');
106  file_put_contents($publicPath . '/foo', '');
107  file_put_contents($publicPath . '/bar', '');
108  file_put_contents($publicPath . '/ddd.txt', 'with content');
109  file_put_contents($publicPath . '/somethingelse', '');
110  file_put_contents($publicPath . '/dadadaFIRST_INStall', '');
111  $expected = scandir($publicPath);
112  $subject = $this->getAccessibleMock(EnableFileService::class, null);
113  $subject->_call('removeFirstInstallFile');
114  self::assertEquals(array_values($expected), array_values(scandir($publicPath)));
115  }
116 
121  {
125  @mkdir(dirname($defaultLocation));
126  @mkdir(dirname($permanentLocation));
127  @mkdir(dirname($legacyLocation));
128  file_put_contents($defaultLocation, 'abc');
129  file_put_contents($permanentLocation, 'abc');
130  file_put_contents($legacyLocation, 'abc');
131  $subject = new ‪EnableFileService();
132  $result = $subject::removeInstallToolEnableFile();
133  self::assertTrue($result);
134  self::assertFileDoesNotExist($defaultLocation);
135  self::assertFileDoesNotExist($permanentLocation);
136  self::assertFileDoesNotExist($legacyLocation);
137  }
138 }
‪TYPO3\CMS\Install\Tests\Functional\Service\EnableFileServiceTest\removeFirstInstallFileRemovesNoFileIfThereAreNoValidFiles
‪removeFirstInstallFileRemovesNoFileIfThereAreNoValidFiles()
Definition: EnableFileServiceTest.php:102
‪TYPO3\CMS\Core\Core\Environment\getPublicPath
‪static getPublicPath()
Definition: Environment.php:187
‪TYPO3\CMS\Install\Service\EnableFileService\INSTALL_TOOL_ENABLE_FILE_PATH
‪const INSTALL_TOOL_ENABLE_FILE_PATH
Definition: EnableFileService.php:30
‪TYPO3\CMS\Install\Tests\Functional\Service\EnableFileServiceTest\removeInstallToolEnableFileRemovesAllAvailableFiles
‪removeInstallToolEnableFileRemovesAllAvailableFiles()
Definition: EnableFileServiceTest.php:120
‪TYPO3\CMS\Install\Service\EnableFileService
Definition: EnableFileService.php:26
‪TYPO3\CMS\Core\Core\Environment\getVarPath
‪static getVarPath()
Definition: Environment.php:197
‪TYPO3\CMS\Core\Core\Environment\getLegacyConfigPath
‪static getLegacyConfigPath()
Definition: Environment.php:268
‪TYPO3\CMS\Core\Core\Environment\getConfigPath
‪static getConfigPath()
Definition: Environment.php:212
‪TYPO3\CMS\Install\Tests\Functional\Service\EnableFileServiceTest\getFirstInstallFilePathsReturnsEmptyArrayWithOnlyInvalidFiles
‪getFirstInstallFilePathsReturnsEmptyArrayWithOnlyInvalidFiles()
Definition: EnableFileServiceTest.php:67
‪TYPO3\CMS\Install\Tests\Functional\Service\EnableFileServiceTest\$initializeDatabase
‪bool $initializeDatabase
Definition: EnableFileServiceTest.php:26
‪TYPO3\CMS\Install\Tests\Functional\Service\EnableFileServiceTest
Definition: EnableFileServiceTest.php:25
‪TYPO3\CMS\Install\Tests\Functional\Service\EnableFileServiceTest\tearDown
‪tearDown()
Definition: EnableFileServiceTest.php:28
‪TYPO3\CMS\Install\Tests\Functional\Service\EnableFileServiceTest\getFirstInstallFilePathsFindsValidFiles
‪getFirstInstallFilePathsFindsValidFiles()
Definition: EnableFileServiceTest.php:46
‪TYPO3\CMS\Core\Core\Environment
Definition: Environment.php:41
‪TYPO3\CMS\Install\Tests\Functional\Service\EnableFileServiceTest\removeFirstInstallFileRemovesValidFiles
‪removeFirstInstallFileRemovesValidFiles()
Definition: EnableFileServiceTest.php:83
‪TYPO3\CMS\Install\Tests\Functional\Service
Definition: EnableFileServiceTest.php:18