TYPO3 CMS  TYPO3_6-2
SqlSchemaMigrationServiceTest.php
Go to the documentation of this file.
1 <?php
3 
21 
26 
30  public function setUp() {
31  parent::setUp();
32  $this->sqlSchemaMigrationService = new \TYPO3\CMS\Install\Service\SqlSchemaMigrationService();
33  }
34 
39 
40  // Get the current database fields.
41  $currentDatabaseSchema = $this->sqlSchemaMigrationService->getFieldDefinitions_database();
42 
43  // Limit our scope to the be_users table:
44  $currentDatabaseSchemaForBeUsers = array();
45  $currentDatabaseSchemaForBeUsers['be_users'] = $currentDatabaseSchema['be_users'];
46  unset($currentDatabaseSchema);
47 
48  // Create a key and a field that belongs to that key:
49  $expectedDatabaseSchemaForBeUsers = $currentDatabaseSchemaForBeUsers;
50  $expectedDatabaseSchemaForBeUsers['be_users']['fields']['functional_test_field_1'] = "tinyint(1) unsigned NOT NULL default '0'";
51  $expectedDatabaseSchemaForBeUsers['be_users']['keys']['functional_test_key_1'] = "KEY functional_test_key_1 (functional_test_field_1)";
52  $createFieldDiff = $this->sqlSchemaMigrationService->getDatabaseExtra($expectedDatabaseSchemaForBeUsers, $currentDatabaseSchemaForBeUsers);
53  $createFieldDiff = $this->sqlSchemaMigrationService->getUpdateSuggestions($createFieldDiff);
54  $this->sqlSchemaMigrationService->performUpdateQueries($createFieldDiff['add'], $createFieldDiff['add']);
55 
56  // Now remove the fields again (without the renaming step).
57  unset($currentDatabaseSchemaForBeUsers['be_users']['fields']['functional_test_field_1']);
58  unset($currentDatabaseSchemaForBeUsers['be_users']['keys']['functional_test_key_1']);
59  $this->sqlSchemaMigrationService->setDeletedPrefixKey('');
60  $removeFieldDiff = $this->sqlSchemaMigrationService->getDatabaseExtra($expectedDatabaseSchemaForBeUsers, $currentDatabaseSchemaForBeUsers);
61  $removeFieldDiff = $this->sqlSchemaMigrationService->getUpdateSuggestions($removeFieldDiff, 'remove');
62  $result = $this->sqlSchemaMigrationService->performUpdateQueries($removeFieldDiff['drop'], $removeFieldDiff['drop']);
63  $this->assertTrue($result, 'performUpdateQueries() did not return TRUE, this means an error occurred: ' . (is_array($result) ? array_pop($result) : ''));
64  }
65 }
if($list_of_literals) if(!empty($literals)) if(!empty($literals)) $result
Analyse literals to prepend the N char to them if their contents aren&#39;t numeric.