‪TYPO3CMS  ‪main
SysFileCollectionIdentifierMigrationTest.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 ‪SysFileCollectionIdentifierMigrationTest extends FunctionalTestCase
31 {
32  private const ‪TABLE_NAME = 'sys_file_collection';
33 
34  protected string ‪$baseDataSet = __DIR__ . '/Fixtures/FileCollectionBase.csv';
35  protected string ‪$resultDataSet = __DIR__ . '/Fixtures/FileCollectionMigrated.csv';
36 
37  #[Test]
38  public function ‪sysFileCollectionRecordsUpdated(): void
39  {
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  'storage' => new Column('storage', new IntegerType(), ['default' => '0', 'notnull' => true]),
52  'folder' => new Column('folder', 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\SysFileCollectionIdentifierMigrationTest
Definition: SysFileCollectionIdentifierMigrationTest.php:31
‪TYPO3\CMS\Install\Updates\SysFileCollectionIdentifierMigration
Definition: SysFileCollectionIdentifierMigration.php:32
‪TYPO3\CMS\Install\Tests\Functional\Updates\SysFileCollectionIdentifierMigrationTest\$resultDataSet
‪string $resultDataSet
Definition: SysFileCollectionIdentifierMigrationTest.php:35
‪TYPO3\CMS\Install\Tests\Functional\Updates\SysFileCollectionIdentifierMigrationTest\TABLE_NAME
‪const TABLE_NAME
Definition: SysFileCollectionIdentifierMigrationTest.php:32
‪TYPO3\CMS\Install\Tests\Functional\Updates\SysFileCollectionIdentifierMigrationTest\$baseDataSet
‪string $baseDataSet
Definition: SysFileCollectionIdentifierMigrationTest.php:34
‪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\Install\Tests\Functional\Updates\SysFileCollectionIdentifierMigrationTest\sysFileCollectionRecordsUpdated
‪sysFileCollectionRecordsUpdated()
Definition: SysFileCollectionIdentifierMigrationTest.php:38
‪TYPO3\CMS\Core\Database\Schema\TableDiff
Definition: TableDiff.php:33