‪TYPO3CMS  11.5
ShortcutRecordsMigrationTest.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\StringType;
22 use Doctrine\DBAL\Types\TextType;
27 use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase;
28 
29 class ‪ShortcutRecordsMigrationTest extends FunctionalTestCase
30 {
31  private const ‪TABLE_NAME = 'sys_be_shortcuts';
32 
36  protected ‪$coreExtensionsToLoad = ['beuser', 'filelist', 'form', 'info', 'lowlevel'];
37 
38  protected string ‪$baseDataSet = __DIR__ . '/Fixtures/ShortcutsBase.csv';
39  protected string ‪$resultDataSet = __DIR__ . '/Fixtures/ShortcutsMigratedToRoutes.csv';
40 
44  public function ‪shortcutRecordsUpdated(): void
45  {
46  $subject = new ‪ShortcutRecordsMigration();
47 
48  $schemaManager = GeneralUtility::makeInstance(ConnectionPool::class)
49  ->getConnectionForTable(self::TABLE_NAME)
50  ->createSchemaManager();
51 
52  $schemaManager->alterTable(
53  new ‪TableDiff(
54  self::TABLE_NAME,
55  [
56  new Column('module_name', new StringType(), ['length' => 255, 'default' => '']),
57  new Column('url', new TextType(), ['notnull' => false]),
58  ]
59  )
60  );
61 
62  $this->importCSVDataSet($this->baseDataSet);
63  self::assertTrue($subject->updateNecessary());
64  $subject->executeUpdate();
65  self::assertFalse($subject->updateNecessary());
66  $this->assertCSVDataSet($this->resultDataSet);
67 
68  // Just ensure that running the upgrade again does not change anything
69  $subject->executeUpdate();
70  $this->assertCSVDataSet($this->resultDataSet);
71  }
72 }
‪TYPO3\CMS\Install\Tests\Functional\Updates\ShortcutRecordsMigrationTest
Definition: ShortcutRecordsMigrationTest.php:30
‪TYPO3\CMS\Install\Tests\Functional\Updates\ShortcutRecordsMigrationTest\$coreExtensionsToLoad
‪$coreExtensionsToLoad
Definition: ShortcutRecordsMigrationTest.php:36
‪TYPO3\CMS\Install\Tests\Functional\Updates\ShortcutRecordsMigrationTest\shortcutRecordsUpdated
‪shortcutRecordsUpdated()
Definition: ShortcutRecordsMigrationTest.php:44
‪TYPO3\CMS\Install\Tests\Functional\Updates\ShortcutRecordsMigrationTest\$baseDataSet
‪string $baseDataSet
Definition: ShortcutRecordsMigrationTest.php:38
‪TYPO3\CMS\Install\Tests\Functional\Updates\ShortcutRecordsMigrationTest\$resultDataSet
‪string $resultDataSet
Definition: ShortcutRecordsMigrationTest.php:39
‪TYPO3\CMS\Install\Updates\ShortcutRecordsMigration
Definition: ShortcutRecordsMigration.php:29
‪TYPO3\CMS\Install\Tests\Functional\Updates\ShortcutRecordsMigrationTest\TABLE_NAME
‪const TABLE_NAME
Definition: ShortcutRecordsMigrationTest.php:31
‪TYPO3\CMS\Core\Database\ConnectionPool
Definition: ConnectionPool.php:46
‪TYPO3\CMS\Install\Tests\Functional\Updates
‪TYPO3\CMS\Core\Utility\GeneralUtility
Definition: GeneralUtility.php:50
‪TYPO3\CMS\Core\Database\Schema\TableDiff
Definition: TableDiff.php:27