[TASK] Use single quotes instead of double quotes
[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\CMS\Core\Tests\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 public function columnAndKeyDeletionDoesNotReturnAnError()
40 {
41
42 // Get the current database fields.
43 $currentDatabaseSchema = $this->sqlSchemaMigrationService->getFieldDefinitions_database();
44
45 // Limit our scope to the be_users table:
46 $currentDatabaseSchemaForBeUsers = array();
47 $currentDatabaseSchemaForBeUsers['be_users'] = $currentDatabaseSchema['be_users'];
48 unset($currentDatabaseSchema);
49
50 // Create a key and a field that belongs to that key:
51 $expectedDatabaseSchemaForBeUsers = $currentDatabaseSchemaForBeUsers;
52 $expectedDatabaseSchemaForBeUsers['be_users']['fields']['functional_test_field_1'] = "tinyint(1) unsigned NOT NULL default '0'";
53 $expectedDatabaseSchemaForBeUsers['be_users']['keys']['functional_test_key_1'] = 'KEY functional_test_key_1 (functional_test_field_1)';
54 $createFieldDiff = $this->sqlSchemaMigrationService->getDatabaseExtra($expectedDatabaseSchemaForBeUsers, $currentDatabaseSchemaForBeUsers);
55 $createFieldDiff = $this->sqlSchemaMigrationService->getUpdateSuggestions($createFieldDiff);
56 $this->sqlSchemaMigrationService->performUpdateQueries($createFieldDiff['add'], $createFieldDiff['add']);
57
58 // Now remove the fields again (without the renaming step).
59 unset($currentDatabaseSchemaForBeUsers['be_users']['fields']['functional_test_field_1']);
60 unset($currentDatabaseSchemaForBeUsers['be_users']['keys']['functional_test_key_1']);
61 $this->sqlSchemaMigrationService->setDeletedPrefixKey('');
62 $removeFieldDiff = $this->sqlSchemaMigrationService->getDatabaseExtra($expectedDatabaseSchemaForBeUsers, $currentDatabaseSchemaForBeUsers);
63 $removeFieldDiff = $this->sqlSchemaMigrationService->getUpdateSuggestions($removeFieldDiff, 'remove');
64 $result = $this->sqlSchemaMigrationService->performUpdateQueries($removeFieldDiff['drop'], $removeFieldDiff['drop']);
65 $this->assertTrue($result, 'performUpdateQueries() did not return TRUE, this means an error occurred: ' . (is_array($result) ? array_pop($result) : ''));
66 }
67 }