class DatabaseExceptionWrapperTest
Same name in this branch
- 9 core/modules/sqlite/tests/src/Kernel/sqlite/DatabaseExceptionWrapperTest.php \Drupal\Tests\sqlite\Kernel\sqlite\DatabaseExceptionWrapperTest
- 9 core/modules/pgsql/tests/src/Kernel/pgsql/DatabaseExceptionWrapperTest.php \Drupal\Tests\pgsql\Kernel\pgsql\DatabaseExceptionWrapperTest
- 9 core/tests/Drupal/KernelTests/Core/Database/DatabaseExceptionWrapperTest.php \Drupal\KernelTests\Core\Database\DatabaseExceptionWrapperTest
Same name and namespace in other branches
- 11.x core/modules/sqlite/tests/src/Kernel/sqlite/DatabaseExceptionWrapperTest.php \Drupal\Tests\sqlite\Kernel\sqlite\DatabaseExceptionWrapperTest
- 11.x core/modules/mysql/tests/src/Kernel/mysql/DatabaseExceptionWrapperTest.php \Drupal\Tests\mysql\Kernel\mysql\DatabaseExceptionWrapperTest
- 11.x core/modules/pgsql/tests/src/Kernel/pgsql/DatabaseExceptionWrapperTest.php \Drupal\Tests\pgsql\Kernel\pgsql\DatabaseExceptionWrapperTest
- 11.x core/modules/mysqli/tests/src/Kernel/mysqli/DatabaseExceptionWrapperTest.php \Drupal\Tests\mysqli\Kernel\mysqli\DatabaseExceptionWrapperTest
- 11.x core/tests/Drupal/KernelTests/Core/Database/DatabaseExceptionWrapperTest.php \Drupal\KernelTests\Core\Database\DatabaseExceptionWrapperTest
Tests exceptions thrown by queries.
@group Database
Hierarchy
- class \Drupal\KernelTests\KernelTestBase extends \Drupal\Core\DependencyInjection\ServiceProviderInterface uses \Drupal\KernelTests\AssertLegacyTrait, \Drupal\KernelTests\AssertContentTrait, \Drupal\Tests\RandomGeneratorTrait, \Drupal\Tests\ConfigTestTrait, \Drupal\Tests\ExtensionListTestTrait, \Drupal\Tests\TestRequirementsTrait, \Drupal\Tests\Traits\PhpUnitWarnings, \Drupal\Tests\PhpUnitCompatibilityTrait, \Symfony\Bridge\PhpUnit\ExpectDeprecationTrait implements \PHPUnit\Framework\TestCase
- class \Drupal\KernelTests\Core\Database\DriverSpecificKernelTestBase implements \Drupal\KernelTests\KernelTestBase
- class \Drupal\Tests\mysql\Kernel\mysql\DatabaseExceptionWrapperTest implements \Drupal\KernelTests\Core\Database\DriverSpecificKernelTestBase
- class \Drupal\KernelTests\Core\Database\DriverSpecificKernelTestBase implements \Drupal\KernelTests\KernelTestBase
Expanded class hierarchy of DatabaseExceptionWrapperTest
File
-
core/
modules/ mysql/ tests/ src/ Kernel/ mysql/ DatabaseExceptionWrapperTest.php, line 14
Namespace
Drupal\Tests\mysql\Kernel\mysqlView source
class DatabaseExceptionWrapperTest extends DriverSpecificKernelTestBase {
/**
* Tests Connection::prepareStatement exceptions on preparation.
*
* Core database drivers use PDO emulated statements or the StatementPrefetch
* class, which defer the statement check to the moment of the execution. In
* order to test a failure at preparation time, we have to force the
* connection not to emulate statement preparation. Still, this is only valid
* for the MySql driver.
*/
public function testPrepareStatementFailOnPreparation() {
$connection_info = Database::getConnectionInfo('default');
$connection_info['default']['pdo'][\PDO::ATTR_EMULATE_PREPARES] = FALSE;
Database::addConnectionInfo('default', 'foo', $connection_info['default']);
$foo_connection = Database::getConnection('foo', 'default');
$this->expectException(DatabaseExceptionWrapper::class);
$stmt = $foo_connection->prepareStatement('bananas', []);
}
/**
* Tests Connection::prepareStatement exception on execution.
*/
public function testPrepareStatementFailOnExecution() {
$this->expectException(\PDOException::class);
$stmt = $this->connection
->prepareStatement('bananas', []);
$stmt->execute();
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.