‪TYPO3CMS  ‪main
MigrateSiteSettingsConfigUpdateTest.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 
20 use PHPUnit\Framework\Attributes\Test;
25 use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase;
26 
27 final class ‪MigrateSiteSettingsConfigUpdateTest extends FunctionalTestCase
28 {
29  #[Test]
30  public function ‪upgradeSettingsUpdateWithSettings(): void
31  {
32  $siteconfigurationIdentifier = 'settings';
33 
34  GeneralUtility::makeInstance(SiteConfiguration::class)->write(
35  $siteconfigurationIdentifier,
36  [
37  'rootPageId' => 1,
38  'base' => 'www.test.org',
39  'languages' => [
40  0 => [
41  'title' => 'English',
42  'enabled' => true,
43  'languageId' => 0,
44  'base' => '/',
45  'locale' => 'en_US.UTF-8',
46  'navigationTitle' => 'English',
47  'flag' => 'us',
48  ],
49  ],
50  'settings' => [
51  'debug' => 1,
52  'test' => true,
53  ],
54  'errorHandling' => [],
55  'routes' => [],
56  ]
57  );
58 
59  $subject = new ‪MigrateSiteSettingsConfigUpdate();
60  $subject->executeUpdate();
61  self::assertFileExists($this->‪getSettingsFilePath($siteconfigurationIdentifier));
62  }
63 
64  #[Test]
66  {
67  $siteconfigurationIdentifier = 'withoutSettings';
68 
69  GeneralUtility::makeInstance(SiteConfiguration::class)->write(
70  $siteconfigurationIdentifier,
71  [
72  'rootPageId' => 2,
73  'base' => 'www.testTwo.org',
74  'languages' => [
75  0 => [
76  'title' => 'English',
77  'enabled' => true,
78  'languageId' => 0,
79  'base' => '/',
80  'locale' => 'en_US.UTF-8',
81  'navigationTitle' => 'English',
82  'flag' => 'us',
83  ],
84  ],
85  'errorHandling' => [],
86  'routes' => [],
87  ]
88  );
89 
90  $subject = new ‪MigrateSiteSettingsConfigUpdate();
91  $subject->executeUpdate();
92  self::assertFileDoesNotExist($this->‪getSettingsFilePath($siteconfigurationIdentifier));
93  }
94 
95  protected function ‪getSettingsFilePath(string ‪$identifier): string
96  {
97  return ‪Environment::getConfigPath() . '/sites/' . ‪$identifier . '/settings.yaml';
98  }
99 }
‪TYPO3\CMS\Install\Updates\MigrateSiteSettingsConfigUpdate
Definition: MigrateSiteSettingsConfigUpdate.php:33
‪TYPO3\CMS\Install\Tests\Functional\Updates\MigrateSiteSettingsConfigUpdateTest\upgradeSettingsUpdateWithoutSettings
‪upgradeSettingsUpdateWithoutSettings()
Definition: MigrateSiteSettingsConfigUpdateTest.php:65
‪TYPO3\CMS\Core\Configuration\SiteConfiguration
Definition: SiteConfiguration.php:47
‪TYPO3\CMS\Core\Core\Environment\getConfigPath
‪static getConfigPath()
Definition: Environment.php:212
‪TYPO3\CMS\Install\Tests\Functional\Updates\MigrateSiteSettingsConfigUpdateTest
Definition: MigrateSiteSettingsConfigUpdateTest.php:28
‪TYPO3\CMS\Install\Tests\Functional\Updates\MigrateSiteSettingsConfigUpdateTest\getSettingsFilePath
‪getSettingsFilePath(string $identifier)
Definition: MigrateSiteSettingsConfigUpdateTest.php:95
‪TYPO3\CMS\Core\Core\Environment
Definition: Environment.php:41
‪TYPO3\CMS\Install\Tests\Functional\Updates
Definition: BackendGroupsExplicitAllowDenyMigrationTest.php:18
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:52
‪TYPO3\CMS\Webhooks\Message\$identifier
‪identifier readonly string $identifier
Definition: FileAddedMessage.php:37
‪TYPO3\CMS\Install\Tests\Functional\Updates\MigrateSiteSettingsConfigUpdateTest\upgradeSettingsUpdateWithSettings
‪upgradeSettingsUpdateWithSettings()
Definition: MigrateSiteSettingsConfigUpdateTest.php:30