‪TYPO3CMS  ‪main
SysFileMountIdentifierMigrationTest.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 Doctrine\DBAL\Schema\Column;
21 use Doctrine\DBAL\Types\IntegerType;
22 use Doctrine\DBAL\Types\StringType;
23 use PHPUnit\Framework\Attributes\Test;
28 use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase;
29 
30 final class ‪SysFileMountIdentifierMigrationTest extends FunctionalTestCase
31 {
32  private const ‪TABLE_NAME = 'sys_filemounts';
33 
34  protected string ‪$baseDataSet = __DIR__ . '/Fixtures/FilemountsBase.csv';
35  protected string ‪$resultDataSet = __DIR__ . '/Fixtures/FilemountsMigrated.csv';
36 
37  #[Test]
38  public function ‪sysFileMountRecordsUpdated(): void
39  {
40  $subject = new ‪SysFileMountIdentifierMigration();
41 
42  $schemaManager = GeneralUtility::makeInstance(ConnectionPool::class)
43  ->getConnectionForTable(self::TABLE_NAME)
44  ->createSchemaManager();
45 
46  $tableDetails = $schemaManager->introspectTable(self::TABLE_NAME);
47  $schemaManager->alterTable(
48  new ‪TableDiff(
49  $tableDetails,
50  [
51  'base' => new Column('base', new IntegerType(), ['default' => '0', 'notnull' => true]),
52  'path' => new Column('path', new StringType(), ['length' => 255, 'default' => '', 'notnull' => true]),
53  ],
54  [],
55  [],
56  [],
57  [],
58  [],
59  [],
60  [],
61  [],
62  [],
63  [],
64  )
65  );
66 
67  $this->importCSVDataSet($this->baseDataSet);
68  self::assertTrue($subject->updateNecessary());
69  $subject->executeUpdate();
70  self::assertFalse($subject->updateNecessary());
71  $this->assertCSVDataSet($this->resultDataSet);
72 
73  // Just ensure that running the upgrade again does not change anything
74  $subject->executeUpdate();
75  $this->assertCSVDataSet($this->resultDataSet);
76  }
77 }
‪TYPO3\CMS\Install\Tests\Functional\Updates\SysFileMountIdentifierMigrationTest\$resultDataSet
‪string $resultDataSet
Definition: SysFileMountIdentifierMigrationTest.php:35
‪TYPO3\CMS\Install\Tests\Functional\Updates\SysFileMountIdentifierMigrationTest\$baseDataSet
‪string $baseDataSet
Definition: SysFileMountIdentifierMigrationTest.php:34
‪TYPO3\CMS\Install\Tests\Functional\Updates\SysFileMountIdentifierMigrationTest\TABLE_NAME
‪const TABLE_NAME
Definition: SysFileMountIdentifierMigrationTest.php:32
‪TYPO3\CMS\Install\Tests\Functional\Updates\SysFileMountIdentifierMigrationTest\sysFileMountRecordsUpdated
‪sysFileMountRecordsUpdated()
Definition: SysFileMountIdentifierMigrationTest.php:38
‪TYPO3\CMS\Install\Updates\SysFileMountIdentifierMigration
Definition: SysFileMountIdentifierMigration.php:32
‪TYPO3\CMS\Install\Tests\Functional\Updates\SysFileMountIdentifierMigrationTest
Definition: SysFileMountIdentifierMigrationTest.php:31
‪TYPO3\CMS\Core\Database\ConnectionPool
Definition: ConnectionPool.php:46
‪TYPO3\CMS\Install\Tests\Functional\Updates
Definition: BackendGroupsExplicitAllowDenyMigrationTest.php:18
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:52
‪TYPO3\CMS\Core\Database\Schema\TableDiff
Definition: TableDiff.php:33