[TASK] Disable a series of functional tests with mssql
[Packages/TYPO3.CMS.git] / typo3 / sysext / install / Tests / Functional / SqlSchemaMigrationServiceTest.php
1 <?php
2 namespace TYPO3\CMS\Install\Tests\Functional;
3
4 /*
5 * This file is part of the TYPO3 CMS project.
6 *
7 * It is free software; you can redistribute it and/or modify it under
8 * the terms of the GNU General Public License, either version 2
9 * of the License, or any later version.
10 *
11 * For the full copyright and license information, please read the
12 * LICENSE.txt file that was distributed with this source code.
13 *
14 * The TYPO3 project - inspiring people to share!
15 */
16
17 /**
18 * Functional tests for the SQL schema migration service.
19 */
20 class SqlSchemaMigrationServiceTest extends \TYPO3\TestingFramework\Core\Functional\FunctionalTestCase
21 {
22 /**
23 * @var \TYPO3\CMS\Install\Service\SqlSchemaMigrationService
24 */
25 protected $sqlSchemaMigrationService;
26
27 /**
28 * Initializes a SqlSchemaMigrationService instance.
29 */
30 protected function setUp()
31 {
32 parent::setUp();
33 $this->sqlSchemaMigrationService = new \TYPO3\CMS\Install\Service\SqlSchemaMigrationService();
34 }
35
36 /**
37 * @test
38 *
39 * @group not-postgres
40 * @group not-mssql
41 */
42 public function columnAndKeyDeletionDoesNotReturnAnError()
43 {
44
45 // Get the current database fields.
46 $currentDatabaseSchema = $this->sqlSchemaMigrationService->getFieldDefinitions_database();
47
48 // Limit our scope to the be_users table:
49 $currentDatabaseSchemaForBeUsers = [];
50 $currentDatabaseSchemaForBeUsers['be_users'] = $currentDatabaseSchema['be_users'];
51 unset($currentDatabaseSchema);
52
53 // Create a key and a field that belongs to that key:
54 $expectedDatabaseSchemaForBeUsers = $currentDatabaseSchemaForBeUsers;
55 $expectedDatabaseSchemaForBeUsers['be_users']['fields']['functional_test_field_1'] = "tinyint(1) unsigned NOT NULL default '0'";
56 $expectedDatabaseSchemaForBeUsers['be_users']['keys']['functional_test_key_1'] = 'KEY functional_test_key_1 (functional_test_field_1)';
57 $createFieldDiff = $this->sqlSchemaMigrationService->getDatabaseExtra($expectedDatabaseSchemaForBeUsers, $currentDatabaseSchemaForBeUsers);
58 $createFieldDiff = $this->sqlSchemaMigrationService->getUpdateSuggestions($createFieldDiff);
59 $this->sqlSchemaMigrationService->performUpdateQueries($createFieldDiff['add'], $createFieldDiff['add']);
60
61 // Now remove the fields again (without the renaming step).
62 unset($currentDatabaseSchemaForBeUsers['be_users']['fields']['functional_test_field_1']);
63 unset($currentDatabaseSchemaForBeUsers['be_users']['keys']['functional_test_key_1']);
64 $this->sqlSchemaMigrationService->setDeletedPrefixKey('');
65 $removeFieldDiff = $this->sqlSchemaMigrationService->getDatabaseExtra($expectedDatabaseSchemaForBeUsers, $currentDatabaseSchemaForBeUsers);
66 $removeFieldDiff = $this->sqlSchemaMigrationService->getUpdateSuggestions($removeFieldDiff, 'remove');
67 $result = $this->sqlSchemaMigrationService->performUpdateQueries($removeFieldDiff['drop'], $removeFieldDiff['drop']);
68 $this->assertTrue($result, 'performUpdateQueries() did not return TRUE, this means an error occurred: ' . (is_array($result) ? array_pop($result) : ''));
69 }
70 }