2 namespace TYPO3\CMS\Install\Tests\Unit\Service;
30 protected function getSqlSchemaMigrationService()
33 $subject = $this->getAccessibleMock(SqlSchemaMigrationService::class, array(
'isDbalEnabled'), array(),
'',
false);
34 $subject->expects($this->any())->method(
'isDbalEnabled')->will($this->returnValue(
false));
44 protected function getDbalEnabledSqlSchemaMigrationService()
47 $databaseConnection = $this->getAccessibleMock(\TYPO3\CMS\Dbal\Database\DatabaseConnection::class, array(
'dummy'), array(),
'',
false);
50 $subject = $this->getAccessibleMock(SqlSchemaMigrationService::class, array(
'isDbalEnabled',
'getDatabaseConnection'), array(),
'',
false);
51 $subject->expects($this->any())->method(
'isDbalEnabled')->will($this->returnValue(
true));
52 $subject->expects($this->any())->method(
'getDatabaseConnection')->will($this->returnValue($databaseConnection));
62 $subject = $this->getSqlSchemaMigrationService();
64 $inputString =
'CREATE table atable (' . LF .
'aFieldName int(11)' . TAB . TAB . TAB .
'unsigned DEFAULT \'0\'' . LF .
');';
65 $result = $subject->getFieldDefinitions_fileContent($inputString);
71 'aFieldName' =>
'int(11) unsigned default \'0\'',
87 $subject = $this->getSqlSchemaMigrationService();
88 $differenceArray = $subject->getDatabaseExtra(
92 'foo' =>
'varchar(999) DEFAULT \'0\' NOT NULL'
99 'foo' =>
'varchar(255) DEFAULT \'0\' NOT NULL'
112 'foo' =>
'varchar(999) DEFAULT \'0\' NOT NULL'
116 'diff_currentValues' => array(
119 'foo' =>
'varchar(255) DEFAULT \'0\' NOT NULL'
132 $subject = $this->getSqlSchemaMigrationService();
133 $differenceArray = $subject->getDatabaseExtra(
137 'foo' =>
'varchar(999) NULL'
144 'foo' =>
'varchar(255) NULL'
157 'foo' =>
'varchar(999) NULL'
161 'diff_currentValues' => array(
164 'foo' =>
'varchar(255) NULL'
177 $subject = $this->getSqlSchemaMigrationService();
178 $differenceArray = $subject->getDatabaseExtra(
182 'foo' =>
'varchar(999) DEFAULT \'0\' NOT NULL'
189 'foo' =>
'varchar(255) DEFAULT \'0\' NOT NULL'
204 'foo' =>
'varchar(999) DEFAULT \'0\''
208 'diff_currentValues' => array(
211 'foo' =>
'varchar(255) DEFAULT \'0\''
224 $subject = $this->getSqlSchemaMigrationService();
225 $differenceArray = $subject->getDatabaseExtra(
229 'foo' =>
'INT(11) DEFAULT \'0\' NOT NULL',
236 'foo' =>
'int(11) DEFAULT \'0\' NOT NULL',
248 'diff_currentValues' => null,
258 $subject = $this->getSqlSchemaMigrationService();
259 $differenceArray = $subject->getDatabaseExtra(
263 'subtype' =>
'SET(\'Tx_MyExt_Domain_Model_Xyz\',\'Tx_MyExt_Domain_Model_Abc\',\'\') NOT NULL DEFAULT \'\',',
270 'subtype' =>
'set(\'Tx_MyExt_Domain_Model_Xyz\',\'Tx_MyExt_Domain_Model_Abc\',\'\') NOT NULL DEFAULT \'\',',
281 'diff_currentValues' => null,
291 $subject = $this->getSqlSchemaMigrationService();
292 $differenceArray = $subject->getDatabaseExtra(
296 'PRIMARY KEY (md5hash)',
303 'PRIMARY KEY (md5hash)'),
314 'diff_currentValues' => null,
324 $subject = $this->getSqlSchemaMigrationService();
325 $differenceArray = $subject->getDatabaseExtra(
329 'foo' =>
'SPATIAL foo (foo)'
346 'foo' =>
'SPATIAL foo (foo)'
351 'diff_currentValues' => null
361 $subject = $this->getSqlSchemaMigrationService();
362 $fieldDefinition = $subject->assembleFieldDefinition(
369 'Extra' =>
'auto_increment',
370 'Comment' =>
'I am a comment',
376 'int(11) NOT NULL auto_increment COMMENT \'I am a comment\'',
386 $subject = $this->getSqlSchemaMigrationService();
387 $fieldDefinition = $subject->assembleFieldDefinition(
394 'Extra' =>
'auto_increment',
400 'int(11) NOT NULL auto_increment',
410 $subject = $this->getSqlSchemaMigrationService();
411 $differenceArray = $subject->getDatabaseExtra(
415 'foo' =>
'INT(11) DEFAULT \'0\' NOT NULL',
425 'foo' =>
'int(11) DEFAULT \'0\' NOT NULL',
439 'diff_currentValues' => null,
449 $subject = $this->getDbalEnabledSqlSchemaMigrationService();
450 $differenceArray = $subject->getDatabaseExtra(
454 'foo' =>
'INT(11) DEFAULT \'0\' NOT NULL',
464 'foo' =>
'int(11) DEFAULT \'0\' NOT NULL',
476 'diff_currentValues' => null,
486 $subject = $this->getSqlSchemaMigrationService();
487 $differenceArray = $subject->getDatabaseExtra(
491 'foo' =>
'INT(11) UNSIGNED DEFAULT \'0\' NOT NULL',
501 'foo' =>
'int(11) DEFAULT \'0\' NOT NULL',
517 'foo' =>
'int(11) UNSIGNED DEFAULT \'0\' NOT NULL',
521 'diff_currentValues' => array(
524 'foo' =>
'int(11) DEFAULT \'0\' NOT NULL',
537 $subject = $this->getDbalEnabledSqlSchemaMigrationService();
538 $differenceArray = $subject->getDatabaseExtra(
542 'foo' =>
'INT(11) UNSIGNED DEFAULT \'0\' NOT NULL',
552 'foo' =>
'int(11) DEFAULT \'0\' NOT NULL',
566 'diff_currentValues' => null
576 $subject = $this->getDbalEnabledSqlSchemaMigrationService();
577 $differenceArray = $subject->getDatabaseExtra(
581 'foo' =>
'KEY foo (foo(199))'
588 'foo' =>
'KEY foo (foo)'
599 'diff_currentValues' => null,
609 $subject = $this->getSqlSchemaMigrationService();
610 $differenceArray = $subject->getDatabaseExtra(
614 'foo' =>
'KEY foo (foo(199))'
621 'foo' =>
'KEY foo (foo)'
634 'foo' =>
'KEY foo (foo(199))'
638 'diff_currentValues' => array(
641 'foo' =>
'KEY foo (foo)'