class SqlModeTest
Tests compatibility of the MySQL driver with various sql_mode options.
Attributes
#[Group('Database')]
Hierarchy
- class \Drupal\Tests\mysqli\Kernel\mysqli\SqlModeTest
Expanded class hierarchy of SqlModeTest
File
-
core/
modules/ mysqli/ tests/ src/ Kernel/ mysqli/ SqlModeTest.php, line 13
Namespace
Drupal\Tests\mysqli\Kernel\mysqliView source
class SqlModeTest extends DriverSpecificDatabaseTestBase {
/**
* Tests quoting identifiers in queries.
*/
public function testQuotingIdentifiers() : void {
// Use SQL-reserved words for both the table and column names.
$query = $this->connection
->query('SELECT [update] FROM {select}');
$this->assertEquals('Update value 1', $query->fetchObject()->update);
$this->assertStringContainsString('SELECT `update` FROM `', $query->getQueryString());
}
/**
* {@inheritdoc}
*/
protected function getDatabaseConnectionInfo() {
$info = parent::getDatabaseConnectionInfo();
// This runs during setUp(), so is not yet skipped for non MySQL databases.
// We defer skipping the test to later in setUp(), so that that can be
// based on databaseType() rather than 'driver', but here all we have to go
// on is 'driver'.
if ($info['default']['driver'] === 'mysqli') {
$info['default']['init_commands']['sql_mode'] = "SET sql_mode = ''";
}
return $info;
}
}
Members
Title Sort descending | Modifiers | Object type | Summary |
---|---|---|---|
ExpectDeprecationTrait::expectDeprecation | public | function | Adds an expected deprecation. |
ExpectDeprecationTrait::setUpErrorHandler | public | function | Sets up the test error handler. |
ExpectDeprecationTrait::tearDownErrorHandler | public | function | Tears down the test error handler. |
SqlModeTest::getDatabaseConnectionInfo | protected | function | Returns the Database connection info to be used for this test. |
SqlModeTest::testQuotingIdentifiers | public | function | Tests quoting identifiers in queries. |
StorageCopyTrait::replaceStorageContents | protected static | function | Copy the configuration from one storage to another and remove stale items. |
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.