TYPO3 CMS  TYPO3_6-2
SqlSchemaMigrationServiceTest.php
Go to the documentation of this file.
1 <?php
3 
18 
25 
30  $subject = new SqlSchemaMigrationService();
31  // Multiple whitespaces and tabs in field definition
32  $inputString = 'CREATE table atable (' . LF . 'aFieldName int(11)' . TAB . TAB . TAB . 'unsigned DEFAULT \'0\'' . LF . ');';
33  $result = $subject->getFieldDefinitions_fileContent($inputString);
34 
35  $this->assertEquals(
36  array(
37  'atable' => array(
38  'fields' => array(
39  'aFieldName' => 'int(11) unsigned default \'0\'',
40  ),
41  'extra' => array(
42  'COLLATE' => '',
43  ),
44  ),
45  ),
46  $result
47  );
48  }
49 
54  $subject = new SqlSchemaMigrationService();
55  $differenceArray = $subject->getDatabaseExtra(
56  array(
57  'tx_foo' => array(
58  'fields' => array(
59  'foo' => 'varchar(999) DEFAULT \'0\' NOT NULL'
60  )
61  )
62  ),
63  array(
64  'tx_foo' => array(
65  'fields' => array(
66  'foo' => 'varchar(255) DEFAULT \'0\' NOT NULL'
67  )
68  )
69  )
70  );
71 
72  $this->assertEquals(
73  $differenceArray,
74  array(
75  'extra' => array(),
76  'diff' => array(
77  'tx_foo' => array(
78  'fields' => array(
79  'foo' => 'varchar(999) DEFAULT \'0\' NOT NULL'
80  )
81  )
82  ),
83  'diff_currentValues' => array(
84  'tx_foo' => array(
85  'fields' => array(
86  'foo' => 'varchar(255) DEFAULT \'0\' NOT NULL'
87  )
88  )
89  )
90  )
91  );
92  }
93 
98  $subject = new SqlSchemaMigrationService();
99  $differenceArray = $subject->getDatabaseExtra(
100  array(
101  'tx_foo' => array(
102  'fields' => array(
103  'foo' => 'varchar(999) NULL'
104  )
105  )
106  ),
107  array(
108  'tx_foo' => array(
109  'fields' => array(
110  'foo' => 'varchar(255) NULL'
111  )
112  )
113  )
114  );
115 
116  $this->assertEquals(
117  $differenceArray,
118  array(
119  'extra' => array(),
120  'diff' => array(
121  'tx_foo' => array(
122  'fields' => array(
123  'foo' => 'varchar(999) NULL'
124  )
125  )
126  ),
127  'diff_currentValues' => array(
128  'tx_foo' => array(
129  'fields' => array(
130  'foo' => 'varchar(255) NULL'
131  )
132  )
133  )
134  )
135  );
136  }
137 
142  $subject = new SqlSchemaMigrationService();
143  $differenceArray = $subject->getDatabaseExtra(
144  array(
145  'tx_foo' => array(
146  'fields' => array(
147  'foo' => 'varchar(999) DEFAULT \'0\' NOT NULL'
148  )
149  )
150  ),
151  array(
152  'tx_foo' => array(
153  'fields' => array(
154  'foo' => 'varchar(255) DEFAULT \'0\' NOT NULL'
155  )
156  )
157  ),
158  '',
159  TRUE
160  );
161 
162  $this->assertEquals(
163  $differenceArray,
164  array(
165  'extra' => array(),
166  'diff' => array(
167  'tx_foo' => array(
168  'fields' => array(
169  'foo' => 'varchar(999) DEFAULT \'0\''
170  )
171  )
172  ),
173  'diff_currentValues' => array(
174  'tx_foo' => array(
175  'fields' => array(
176  'foo' => 'varchar(255) DEFAULT \'0\''
177  )
178  )
179  )
180  )
181  );
182  }
183 
188  $subject = new SqlSchemaMigrationService();
189  $differenceArray = $subject->getDatabaseExtra(
190  array(
191  'tx_foo' => array(
192  'fields' => array(
193  'foo' => 'INT(11) DEFAULT \'0\' NOT NULL'
194  )
195  )
196  ),
197  array(
198  'tx_foo' => array(
199  'fields' => array(
200  'foo' => 'int(11) DEFAULT \'0\' NOT NULL'
201  )
202  )
203  )
204  );
205 
206 
207  $this->assertEquals(
208  $differenceArray,
209  array(
210  'extra' => array(),
211  'diff' => array(),
212  'diff_currentValues' => NULL
213  )
214  );
215  }
216 
221  $subject = new SqlSchemaMigrationService();
222  $differenceArray = $subject->getDatabaseExtra(
223  array(
224  'tx_foo' => array(
225  'fields' => array(
226  'subtype' => 'SET(\'Tx_MyExt_Domain_Model_Xyz\',\'Tx_MyExt_Domain_Model_Abc\',\'\') NOT NULL DEFAULT \'\',',
227  )
228  )
229  ),
230  array(
231  'tx_foo' => array(
232  'fields' => array(
233  'subtype' => 'set(\'Tx_MyExt_Domain_Model_Xyz\',\'Tx_MyExt_Domain_Model_Abc\',\'\') NOT NULL DEFAULT \'\',',
234  )
235  )
236  )
237  );
238 
239  $this->assertEquals(
240  $differenceArray,
241  array(
242  'extra' => array(),
243  'diff' => array(),
244  'diff_currentValues' => NULL,
245  )
246  );
247  }
248 
253  $subject = new SqlSchemaMigrationService();
254  $differenceArray = $subject->getDatabaseExtra(
255  array(
256  'tx_foo' => array(
257  'fields' => array(
258  'PRIMARY KEY (md5hash)'
259  )
260  )
261  ),
262  array(
263  'tx_foo' => array(
264  'fields' => array(
265  'PRIMARY KEY (md5hash)')
266  )
267  )
268  );
269 
270 
271  $this->assertEquals(
272  $differenceArray,
273  array(
274  'extra' => array(),
275  'diff' => array(),
276  'diff_currentValues' => NULL
277  )
278  );
279  }
280 }
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.