[!!!][TASK] Rewrite install tool
[Packages/TYPO3.CMS.git] / typo3 / sysext / install / Tests / Unit / Service / SqlSchemaMigrationServiceTest.php
1 <?php
2 namespace TYPO3\CMS\Install\Tests\Unit\Service;
3
4 /***************************************************************
5 * Copyright notice
6 *
7 * (c) 2013 Mario Rimann <mario.rimann@typo3.org>
8 * All rights reserved
9 *
10 * This script is part of the TYPO3 project. The TYPO3 project is
11 * free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
15 *
16 * The GNU General Public License can be found at
17 * http://www.gnu.org/copyleft/gpl.html.
18 * A copy is found in the textfile GPL.txt and important notices to the license
19 * from the author is found in LICENSE.txt distributed with these scripts.
20 *
21 *
22 * This script is distributed in the hope that it will be useful,
23 * but WITHOUT ANY WARRANTY; without even the implied warranty of
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 * GNU General Public License for more details.
26 *
27 * This copyright notice MUST APPEAR in all copies of the script!
28 ***************************************************************/
29
30 use TYPO3\CMS\Install\Service\SqlSchemaMigrationService;
31
32 /**
33 * Test case
34 *
35 * @author Mario Rimann <mario.rimann@typo3.org>
36 */
37 class SqlSchemaMigrationServiceTest extends \TYPO3\CMS\Core\Tests\UnitTestCase {
38
39 /**
40 * @var \TYPO3\CMS\Install\Service\SqlSchemaMigrationService
41 */
42 protected $fixture;
43
44 /**
45 * Sets up the fixture for testing
46 */
47 public function setUp() {
48 $this->fixture = new SqlSchemaMigrationService();
49 }
50
51 /**
52 * Tears down the fixture
53 */
54 public function tearDown() {
55 unset($this->fixture);
56 }
57
58 /**
59 * @test
60 */
61 public function getDatabaseExtraFindsChangedFields() {
62 $differenceArray = $this->fixture->getDatabaseExtra(
63 array(
64 'tx_foo' => array(
65 'fields' => array(
66 'foo' => 'varchar(999) DEFAULT \'0\' NOT NULL'
67 )
68 )
69 ),
70 array(
71 'tx_foo' => array(
72 'fields' => array(
73 'foo' => 'varchar(255) DEFAULT \'0\' NOT NULL'
74 )
75 )
76 )
77 );
78
79
80
81 $this->assertEquals(
82 $differenceArray,
83 array(
84 'extra' => array(),
85 'diff' => array(
86 'tx_foo' => array(
87 'fields' => array(
88 'foo' => 'varchar(999) DEFAULT \'0\''
89 )
90 )
91 ),
92 'diff_currentValues' => array(
93 'tx_foo' => array(
94 'fields' => array(
95 'foo' => 'varchar(255) DEFAULT \'0\''
96 )
97 )
98 )
99 )
100 );
101 }
102
103 /**
104 * @test
105 */
106 public function getDatabaseExtraIgnoresCaseDifference() {
107 $differenceArray = $this->fixture->getDatabaseExtra(
108 array(
109 'tx_foo' => array(
110 'fields' => array(
111 'foo' => 'INT(11) DEFAULT \'0\' NOT NULL'
112 )
113 )
114 ),
115 array(
116 'tx_foo' => array(
117 'fields' => array(
118 'foo' => 'int(11) DEFAULT \'0\' NOT NULL'
119 )
120 )
121 )
122 );
123
124
125 $this->assertEquals(
126 $differenceArray,
127 array(
128 'extra' => array(),
129 'diff' => array(),
130 'diff_currentValues' => NULL
131 )
132 );
133 }
134
135 /**
136 * @test
137 */
138 public function getDatabaseExtraDoesNotLowercaseReservedWordsForTheComparison() {
139 $differenceArray = $this->fixture->getDatabaseExtra(
140 array(
141 'tx_foo' => array(
142 'fields' => array(
143 'PRIMARY KEY (md5hash)'
144 )
145 )
146 ),
147 array(
148 'tx_foo' => array(
149 'fields' => array(
150 'PRIMARY KEY (md5hash)')
151 )
152 )
153 );
154
155
156 $this->assertEquals(
157 $differenceArray,
158 array(
159 'extra' => array(),
160 'diff' => array(),
161 'diff_currentValues' => NULL
162 )
163 );
164 }
165 }
166
167 ?>