diff --git a/typo3/sysext/core/Tests/Functional/Category/Collection/CategoryCollectionTest.php b/typo3/sysext/core/Tests/Functional/Category/Collection/CategoryCollectionTest.php index 766e50e5d913fd58c143229cc79fd529c080d1cd..6a4ba5fb8dda22d1b4d0b6fb42e7331078ababb2 100644 --- a/typo3/sysext/core/Tests/Functional/Category/Collection/CategoryCollectionTest.php +++ b/typo3/sysext/core/Tests/Functional/Category/Collection/CategoryCollectionTest.php @@ -14,8 +14,11 @@ namespace TYPO3\CMS\Core\Tests\Functional\Category\Collection; * The TYPO3 project - inspiring people to share! */ +use Doctrine\DBAL\Schema\Column; +use Doctrine\DBAL\Schema\TableDiff; use Doctrine\DBAL\Types\Type; use TYPO3\CMS\Core\Category\Collection\CategoryCollection; +use TYPO3\CMS\Core\Database\Connection; use TYPO3\CMS\Core\Database\ConnectionPool; use TYPO3\CMS\Core\Utility\GeneralUtility; @@ -336,7 +339,7 @@ class CategoryCollectionTest extends \TYPO3\TestingFramework\Core\Functional\Fun 'is_dummy_record' => 1 ]; - $connection->insert('sys_category', $values); + $connection->insert('sys_category', $values, [ 'l10n_diffsource' => Connection::PARAM_LOB ]); $this->categoryUid = $connection->lastInsertId('sys_category'); } @@ -351,16 +354,17 @@ class CategoryCollectionTest extends \TYPO3\TestingFramework\Core\Functional\Fun { $connection = $this->getConnectionPool() ->getConnectionByName(ConnectionPool::DEFAULT_CONNECTION_NAME); - $currentSchema = $connection->getSchemaManager()->createSchema(); - $targetSchema = clone $currentSchema; foreach ($this->tables as $table) { - $targetSchema->getTable($table)->dropColumn('is_dummy_record'); - } - - $queries = $currentSchema->getMigrateToSql($targetSchema, $connection->getDatabasePlatform()); - foreach ($queries as $query) { - $connection->query($query); + $diff = new TableDiff( + $table, + [], + [], + [ + 'is_dummy_record' => new Column('is_dummy_record', Type::getType(Type::SMALLINT)) + ] + ); + $connection->getSchemaManager()->alterTable($diff); } } } diff --git a/typo3/sysext/core/Tests/Functional/Collection/RecordCollectionRepositoryTest.php b/typo3/sysext/core/Tests/Functional/Collection/RecordCollectionRepositoryTest.php index 595fbe7953f6153b48f9bc76d7f5e365c688267c..b25eb7ae8707865218a3f6e5f62b3289cf9b8629 100644 --- a/typo3/sysext/core/Tests/Functional/Collection/RecordCollectionRepositoryTest.php +++ b/typo3/sysext/core/Tests/Functional/Collection/RecordCollectionRepositoryTest.php @@ -14,6 +14,7 @@ namespace TYPO3\CMS\Core\Tests\Functional\Collection; * The TYPO3 project - inspiring people to share! */ +use Doctrine\DBAL\Platforms\SQLServerPlatform; use TYPO3\CMS\Core\Collection\RecordCollectionRepository; use TYPO3\CMS\Core\Collection\StaticRecordCollection; use TYPO3\CMS\Core\Database\ConnectionPool; @@ -84,8 +85,8 @@ class RecordCollectionRepositoryTest extends \TYPO3\TestingFramework\Core\Functi { $type = RecordCollectionRepository::TYPE_Static; $this->insertTestData([ - ['type' => $type, 'table_name' => $this->testTableName], - ['type' => $type, 'table_name' => $this->testTableName] + ['uid' => 1, 'type' => $type, 'table_name' => $this->testTableName], + ['uid' => 2, 'type' => $type, 'table_name' => $this->testTableName] ]); $objects = $this->subject->findByType($type); @@ -110,8 +111,8 @@ class RecordCollectionRepositoryTest extends \TYPO3\TestingFramework\Core\Functi { $type = RecordCollectionRepository::TYPE_Static; $this->insertTestData([ - ['type' => $type, 'table_name' => $this->testTableName], - ['type' => $type, 'table_name' => $this->testTableName] + ['uid' => 1, 'type' => $type, 'table_name' => $this->testTableName], + ['uid' => 2, 'type' => $type, 'table_name' => $this->testTableName] ]); $objects = $this->subject->findByTableName($this->testTableName); @@ -138,8 +139,8 @@ class RecordCollectionRepositoryTest extends \TYPO3\TestingFramework\Core\Functi { $type = RecordCollectionRepository::TYPE_Static; $this->insertTestData([ - ['type' => $type, 'table_name' => $this->testTableName], - ['type' => $type, 'table_name' => $this->testTableName] + ['uid' => 1, 'type' => $type, 'table_name' => $this->testTableName], + ['uid' => 2, 'type' => $type, 'table_name' => $this->testTableName] ]); $objects = $this->subject->findByTypeAndTableName($type, $this->testTableName); @@ -305,9 +306,35 @@ class RecordCollectionRepositoryTest extends \TYPO3\TestingFramework\Core\Functi protected function insertTestData(array $rows) { $connection = GeneralUtility::makeInstance(ConnectionPool::class)->getConnectionForTable('sys_collection'); + $platform = $connection->getDatabasePlatform(); + $sqlServerIdentityDisabled = false; + if ($platform instanceof SQLServerPlatform) { + try { + $connection->exec('SET IDENTITY_INSERT sys_collection ON'); + $sqlServerIdentityDisabled = true; + } catch (\Doctrine\DBAL\DBALException $e) { + // Some tables like sys_refindex don't have an auto-increment uid field and thus no + // IDENTITY column. Instead of testing existance, we just try to set IDENTITY ON + // and catch the possible error that occurs. + } + } + + $types = []; + $tableDetails = $connection->getSchemaManager()->listTableDetails('sys_collection'); + foreach ($rows as $row) { + foreach ($row as $columnName => $columnValue) { + $types[] = $tableDetails->getColumn($columnName)->getType()->getBindingType(); + } + break; + } foreach ($rows as $row) { - $connection->insert('sys_collection', $row); + $connection->insert('sys_collection', $row, $types); + } + + if ($sqlServerIdentityDisabled) { + // Reset identity if it has been changed + $connection->exec('SET IDENTITY_INSERT sys_collection OFF'); } } } diff --git a/typo3/sysext/core/Tests/Functional/RegistryTest.php b/typo3/sysext/core/Tests/Functional/RegistryTest.php index acb65d16bf674dd59edf66f85ebf0ba0d427c451..84f70d18ab1725c695de0026d177c3be3dceb42e 100644 --- a/typo3/sysext/core/Tests/Functional/RegistryTest.php +++ b/typo3/sysext/core/Tests/Functional/RegistryTest.php @@ -14,6 +14,7 @@ namespace TYPO3\CMS\Core\Tests\Functional; * The TYPO3 project - inspiring people to share! */ +use TYPO3\CMS\Core\Database\Connection; use TYPO3\CMS\Core\Database\ConnectionPool; use TYPO3\CMS\Core\Registry; @@ -51,6 +52,9 @@ class RegistryTest extends \TYPO3\TestingFramework\Core\Functional\FunctionalTes 'entry_namespace' => 'myExtension', 'entry_key' => 'myKey', 'entry_value' => serialize('myValue'), + ], + [ + 'entry_value' => Connection::PARAM_LOB, ] ); $this->assertSame('myValue', (new Registry())->get('myExtension', 'myKey')); @@ -84,6 +88,9 @@ class RegistryTest extends \TYPO3\TestingFramework\Core\Functional\FunctionalTes 'entry_namespace' => 'myExtension', 'entry_key' => 'myKey', 'entry_value' => serialize('myValue'), + ], + [ + 'entry_value' => Connection::PARAM_LOB, ] ); (new Registry())->set('myExtension', 'myKey', 'myNewValue'); @@ -110,7 +117,10 @@ class RegistryTest extends \TYPO3\TestingFramework\Core\Functional\FunctionalTes ['ns1', 'k2', serialize('v2')], ['ns2', 'k1', serialize('v1')], ], - ['entry_namespace', 'entry_key', 'entry_value'] + ['entry_namespace', 'entry_key', 'entry_value'], + [ + 'entry_value' => Connection::PARAM_LOB, + ] ); (new Registry())->remove('ns1', 'k1'); @@ -133,7 +143,10 @@ class RegistryTest extends \TYPO3\TestingFramework\Core\Functional\FunctionalTes ['ns1', 'k2', serialize('v2')], ['ns2', 'k1', serialize('v1')], ], - ['entry_namespace', 'entry_key', 'entry_value'] + ['entry_namespace', 'entry_key', 'entry_value'], + [ + 'entry_value' => Connection::PARAM_LOB, + ] ); (new Registry())->removeAllByNamespace('ns1'); diff --git a/typo3/sysext/frontend/Tests/Functional/ContentObject/ContentObjectRendererTest.php b/typo3/sysext/frontend/Tests/Functional/ContentObject/ContentObjectRendererTest.php index 51a915d19d8a1ee5f6409781232b1f2f119b03da..a95dd27128ccaba4d9ad2c6e03aec6ddb83df085 100644 --- a/typo3/sysext/frontend/Tests/Functional/ContentObject/ContentObjectRendererTest.php +++ b/typo3/sysext/frontend/Tests/Functional/ContentObject/ContentObjectRendererTest.php @@ -31,11 +31,6 @@ class ContentObjectRendererTest extends \TYPO3\TestingFramework\Core\Functional\ */ protected $subject; - /** - * @var string - */ - protected $quoteChar; - protected function setUp() { parent::setUp(); @@ -51,10 +46,6 @@ class ContentObjectRendererTest extends \TYPO3\TestingFramework\Core\Functional\ $GLOBALS['TSFE'] = $typoScriptFrontendController; $this->subject = GeneralUtility::makeInstance(ContentObjectRenderer::class); - $this->quoteChar = GeneralUtility::makeInstance(ConnectionPool::class) - ->getConnectionForTable('tt_content') - ->getDatabasePlatform() - ->getIdentifierQuoteCharacter(); } /** @@ -79,7 +70,7 @@ class ContentObjectRendererTest extends \TYPO3\TestingFramework\Core\Functional\ 'selectFields' => 'header,bodytext' ], [ - 'SELECT' => 'header,bodytext, `tt_content`.`uid` AS `uid`, `tt_content`.`pid` AS `pid`, `tt_content`.`t3ver_state` AS `t3ver_state`' + 'SELECT' => 'header,bodytext, [tt_content].[uid] AS [uid], [tt_content].[pid] AS [pid], [tt_content].[t3ver_state] AS [t3ver_state]' ] ], 'testing #17284: no need to add' => [ @@ -107,7 +98,7 @@ class ContentObjectRendererTest extends \TYPO3\TestingFramework\Core\Functional\ 'join' => 'be_users ON tt_content.cruser_id = be_users.uid' ], [ - 'SELECT' => 'tt_content.header,be_users.username, `tt_content`.`uid` AS `uid`, `tt_content`.`pid` AS `pid`, `tt_content`.`t3ver_state` AS `t3ver_state`' + 'SELECT' => 'tt_content.header,be_users.username, [tt_content].[uid] AS [uid], [tt_content].[pid] AS [pid], [tt_content].[t3ver_state] AS [t3ver_state]' ] ], 'testing #34152: single count(*), add nothing' => [ @@ -190,10 +181,16 @@ class ContentObjectRendererTest extends \TYPO3\TestingFramework\Core\Functional\ ]; $result = $this->subject->getQuery($table, $conf, true); + + $databasePlatform = (new ConnectionPool())->getConnectionForTable('tt_content')->getDatabasePlatform(); foreach ($expected as $field => $value) { - // Replace the MySQL backtick quote character with the actual quote character for the DBMS - if ($field === 'SELECT') { - $value = str_replace('`', $this->quoteChar, $value); + if (!($databasePlatform instanceof \Doctrine\DBAL\Platforms\SQLServerPlatform)) { + // Replace the MySQL backtick quote character with the actual quote character for the DBMS, + if ($field === 'SELECT') { + $quoteChar = $databasePlatform->getIdentifierQuoteCharacter(); + $value = str_replace('[', $quoteChar, $value); + $value = str_replace(']', $quoteChar, $value); + } } $this->assertEquals($value, $result[$field]); } diff --git a/typo3/sysext/frontend/Tests/Functional/Controller/TypoScriptFrontendControllerTest.php b/typo3/sysext/frontend/Tests/Functional/Controller/TypoScriptFrontendControllerTest.php index d5fe1bd985852466f167d69ff64790136234a935..03ab52eb0864ee7531780c30d835169097041f9d 100644 --- a/typo3/sysext/frontend/Tests/Functional/Controller/TypoScriptFrontendControllerTest.php +++ b/typo3/sysext/frontend/Tests/Functional/Controller/TypoScriptFrontendControllerTest.php @@ -14,6 +14,7 @@ namespace TYPO3\CMS\Frontend\Tests\Functional\Controller; * The TYPO3 project - inspiring people to share! */ +use Doctrine\DBAL\Platforms\SQLServerPlatform; use TYPO3\CMS\Core\Cache\CacheManager; use TYPO3\CMS\Core\Database\ConnectionPool; use TYPO3\CMS\Core\Utility\GeneralUtility; @@ -115,13 +116,25 @@ class TypoScriptFrontendControllerTest extends \TYPO3\TestingFramework\Core\Func ], ]; + $connection = (new ConnectionPool())->getConnectionForTable('sys_domain'); + + $sqlServerIdentityDisabled = false; + if ($connection->getDatabasePlatform() instanceof SQLServerPlatform) { + $connection->exec('SET IDENTITY_INSERT sys_domain ON'); + $sqlServerIdentityDisabled = true; + } + foreach ($domainRecords as $domainRecord) { - (new ConnectionPool())->getConnectionForTable('sys_domain')->insert( + $connection->insert( 'sys_domain', $domainRecord ); } + if ($sqlServerIdentityDisabled) { + $connection->exec('SET IDENTITY_INSERT sys_domain OFF'); + } + GeneralUtility::makeInstance(CacheManager::class)->getCache('cache_runtime')->flush(); $expectedResult = [ $domainRecords[$currentDomain]['pid'] => $domainRecords[$currentDomain], @@ -162,13 +175,25 @@ class TypoScriptFrontendControllerTest extends \TYPO3\TestingFramework\Core\Func ], ]; + $connection = (new ConnectionPool())->getConnectionForTable('sys_domain'); + + $sqlServerIdentityDisabled = false; + if ($connection->getDatabasePlatform() instanceof SQLServerPlatform) { + $connection->exec('SET IDENTITY_INSERT sys_domain ON'); + $sqlServerIdentityDisabled = true; + } + foreach ($domainRecords as $domainRecord) { - (new ConnectionPool())->getConnectionForTable('sys_domain')->insert( + $connection->insert( 'sys_domain', $domainRecord ); } + if ($sqlServerIdentityDisabled) { + $connection->exec('SET IDENTITY_INSERT sys_domain OFF'); + } + GeneralUtility::makeInstance(CacheManager::class)->getCache('cache_runtime')->flush(); $expectedResult = [ $domainRecords[$currentDomain]['pid'] => $domainRecords['foo.bar'],