Reworked driver exception tests

1. Got rid of hard-coded exception mocks in favor of PHPUnit-generated ones where possible.
2. Reworked AbstractDriverTest::testConvertsException() to use a data provider to make testing all types of exceptions independent.
3. Updated PHPUnit since the reworked code relies on sebastianbergmann/phpunit#3604.
parent 4d0d2aff
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically" "This file is @generated automatically"
], ],
"content-hash": "ddba260b7dfb84d2591b0a71a885166a", "content-hash": "07e2f7f05586700d8d7bde1f2fd023e6",
"packages": [ "packages": [
{ {
"name": "doctrine/cache", "name": "doctrine/cache",
...@@ -329,27 +329,29 @@ ...@@ -329,27 +329,29 @@
}, },
{ {
"name": "doctrine/instantiator", "name": "doctrine/instantiator",
"version": "1.1.0", "version": "1.2.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/doctrine/instantiator.git", "url": "https://github.com/doctrine/instantiator.git",
"reference": "185b8868aa9bf7159f5f953ed5afb2d7fcdc3bda" "reference": "a2c590166b2133a4633738648b6b064edae0814a"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/doctrine/instantiator/zipball/185b8868aa9bf7159f5f953ed5afb2d7fcdc3bda", "url": "https://api.github.com/repos/doctrine/instantiator/zipball/a2c590166b2133a4633738648b6b064edae0814a",
"reference": "185b8868aa9bf7159f5f953ed5afb2d7fcdc3bda", "reference": "a2c590166b2133a4633738648b6b064edae0814a",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
"php": "^7.1" "php": "^7.1"
}, },
"require-dev": { "require-dev": {
"athletic/athletic": "~0.1.8", "doctrine/coding-standard": "^6.0",
"ext-pdo": "*", "ext-pdo": "*",
"ext-phar": "*", "ext-phar": "*",
"phpunit/phpunit": "^6.2.3", "phpbench/phpbench": "^0.13",
"squizlabs/php_codesniffer": "^3.0.2" "phpstan/phpstan-phpunit": "^0.11",
"phpstan/phpstan-shim": "^0.11",
"phpunit/phpunit": "^7.0"
}, },
"type": "library", "type": "library",
"extra": { "extra": {
...@@ -374,12 +376,12 @@ ...@@ -374,12 +376,12 @@
} }
], ],
"description": "A small, lightweight utility to instantiate objects in PHP without invoking their constructors", "description": "A small, lightweight utility to instantiate objects in PHP without invoking their constructors",
"homepage": "https://github.com/doctrine/instantiator", "homepage": "https://www.doctrine-project.org/projects/instantiator.html",
"keywords": [ "keywords": [
"constructor", "constructor",
"instantiate" "instantiate"
], ],
"time": "2017-07-22T11:58:36+00:00" "time": "2019-03-17T17:37:11+00:00"
}, },
{ {
"name": "jean85/pretty-package-versions", "name": "jean85/pretty-package-versions",
...@@ -472,16 +474,16 @@ ...@@ -472,16 +474,16 @@
}, },
{ {
"name": "myclabs/deep-copy", "name": "myclabs/deep-copy",
"version": "1.8.1", "version": "1.9.1",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/myclabs/DeepCopy.git", "url": "https://github.com/myclabs/DeepCopy.git",
"reference": "3e01bdad3e18354c3dce54466b7fbe33a9f9f7f8" "reference": "e6828efaba2c9b79f4499dae1d66ef8bfa7b2b72"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/3e01bdad3e18354c3dce54466b7fbe33a9f9f7f8", "url": "https://api.github.com/repos/myclabs/DeepCopy/zipball/e6828efaba2c9b79f4499dae1d66ef8bfa7b2b72",
"reference": "3e01bdad3e18354c3dce54466b7fbe33a9f9f7f8", "reference": "e6828efaba2c9b79f4499dae1d66ef8bfa7b2b72",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
...@@ -516,7 +518,7 @@ ...@@ -516,7 +518,7 @@
"object", "object",
"object graph" "object graph"
], ],
"time": "2018-06-11T23:09:50+00:00" "time": "2019-04-07T13:18:21+00:00"
}, },
{ {
"name": "nette/bootstrap", "name": "nette/bootstrap",
...@@ -1254,16 +1256,16 @@ ...@@ -1254,16 +1256,16 @@
}, },
{ {
"name": "phpdocumentor/reflection-docblock", "name": "phpdocumentor/reflection-docblock",
"version": "4.3.0", "version": "4.3.1",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/phpDocumentor/ReflectionDocBlock.git", "url": "https://github.com/phpDocumentor/ReflectionDocBlock.git",
"reference": "94fd0001232e47129dd3504189fa1c7225010d08" "reference": "bdd9f737ebc2a01c06ea7ff4308ec6697db9b53c"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/94fd0001232e47129dd3504189fa1c7225010d08", "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/bdd9f737ebc2a01c06ea7ff4308ec6697db9b53c",
"reference": "94fd0001232e47129dd3504189fa1c7225010d08", "reference": "bdd9f737ebc2a01c06ea7ff4308ec6697db9b53c",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
...@@ -1301,7 +1303,7 @@ ...@@ -1301,7 +1303,7 @@
} }
], ],
"description": "With this component, a library can provide support for annotations via DocBlocks or otherwise retrieve information that is embedded in a DocBlock.", "description": "With this component, a library can provide support for annotations via DocBlocks or otherwise retrieve information that is embedded in a DocBlock.",
"time": "2017-11-30T07:14:17+00:00" "time": "2019-04-30T17:48:53+00:00"
}, },
{ {
"name": "phpdocumentor/type-resolver", "name": "phpdocumentor/type-resolver",
...@@ -1534,16 +1536,16 @@ ...@@ -1534,16 +1536,16 @@
}, },
{ {
"name": "phpunit/php-code-coverage", "name": "phpunit/php-code-coverage",
"version": "7.0.1", "version": "7.0.3",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/sebastianbergmann/php-code-coverage.git", "url": "https://github.com/sebastianbergmann/php-code-coverage.git",
"reference": "4832739a02c418397e404da6c3e4fe680b7a4de7" "reference": "0317a769a81845c390e19684d9ba25d7f6aa4707"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/4832739a02c418397e404da6c3e4fe680b7a4de7", "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/0317a769a81845c390e19684d9ba25d7f6aa4707",
"reference": "4832739a02c418397e404da6c3e4fe680b7a4de7", "reference": "0317a769a81845c390e19684d9ba25d7f6aa4707",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
...@@ -1593,7 +1595,7 @@ ...@@ -1593,7 +1595,7 @@
"testing", "testing",
"xunit" "xunit"
], ],
"time": "2019-02-01T07:29:14+00:00" "time": "2019-02-26T07:38:26+00:00"
}, },
{ {
"name": "phpunit/php-file-iterator", "name": "phpunit/php-file-iterator",
...@@ -1688,16 +1690,16 @@ ...@@ -1688,16 +1690,16 @@
}, },
{ {
"name": "phpunit/php-timer", "name": "phpunit/php-timer",
"version": "2.0.0", "version": "2.1.1",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/sebastianbergmann/php-timer.git", "url": "https://github.com/sebastianbergmann/php-timer.git",
"reference": "8b8454ea6958c3dee38453d3bd571e023108c91f" "reference": "8b389aebe1b8b0578430bda0c7c95a829608e059"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/8b8454ea6958c3dee38453d3bd571e023108c91f", "url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/8b389aebe1b8b0578430bda0c7c95a829608e059",
"reference": "8b8454ea6958c3dee38453d3bd571e023108c91f", "reference": "8b389aebe1b8b0578430bda0c7c95a829608e059",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
...@@ -1709,7 +1711,7 @@ ...@@ -1709,7 +1711,7 @@
"type": "library", "type": "library",
"extra": { "extra": {
"branch-alias": { "branch-alias": {
"dev-master": "2.0-dev" "dev-master": "2.1-dev"
} }
}, },
"autoload": { "autoload": {
...@@ -1733,7 +1735,7 @@ ...@@ -1733,7 +1735,7 @@
"keywords": [ "keywords": [
"timer" "timer"
], ],
"time": "2018-02-01T13:07:23+00:00" "time": "2019-02-20T10:12:59+00:00"
}, },
{ {
"name": "phpunit/php-token-stream", "name": "phpunit/php-token-stream",
...@@ -1786,16 +1788,16 @@ ...@@ -1786,16 +1788,16 @@
}, },
{ {
"name": "phpunit/phpunit", "name": "phpunit/phpunit",
"version": "8.0.0", "version": "8.1.5",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/sebastianbergmann/phpunit.git", "url": "https://github.com/sebastianbergmann/phpunit.git",
"reference": "130104cf796a88dd1547dc5beb8bd555c2deb55e" "reference": "01392d4b5878aa617e8d9bc7a529e5febc8fe956"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/130104cf796a88dd1547dc5beb8bd555c2deb55e", "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/01392d4b5878aa617e8d9bc7a529e5febc8fe956",
"reference": "130104cf796a88dd1547dc5beb8bd555c2deb55e", "reference": "01392d4b5878aa617e8d9bc7a529e5febc8fe956",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
...@@ -1814,7 +1816,7 @@ ...@@ -1814,7 +1816,7 @@
"phpunit/php-code-coverage": "^7.0", "phpunit/php-code-coverage": "^7.0",
"phpunit/php-file-iterator": "^2.0.1", "phpunit/php-file-iterator": "^2.0.1",
"phpunit/php-text-template": "^1.2.1", "phpunit/php-text-template": "^1.2.1",
"phpunit/php-timer": "^2.0", "phpunit/php-timer": "^2.1",
"sebastian/comparator": "^3.0", "sebastian/comparator": "^3.0",
"sebastian/diff": "^3.0", "sebastian/diff": "^3.0",
"sebastian/environment": "^4.1", "sebastian/environment": "^4.1",
...@@ -1838,7 +1840,7 @@ ...@@ -1838,7 +1840,7 @@
"type": "library", "type": "library",
"extra": { "extra": {
"branch-alias": { "branch-alias": {
"dev-master": "8.0-dev" "dev-master": "8.1-dev"
} }
}, },
"autoload": { "autoload": {
...@@ -1864,7 +1866,7 @@ ...@@ -1864,7 +1866,7 @@
"testing", "testing",
"xunit" "xunit"
], ],
"time": "2019-02-01T05:41:59+00:00" "time": "2019-05-14T04:57:31+00:00"
}, },
{ {
"name": "psr/log", "name": "psr/log",
...@@ -2024,23 +2026,23 @@ ...@@ -2024,23 +2026,23 @@
}, },
{ {
"name": "sebastian/diff", "name": "sebastian/diff",
"version": "3.0.1", "version": "3.0.2",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/sebastianbergmann/diff.git", "url": "https://github.com/sebastianbergmann/diff.git",
"reference": "366541b989927187c4ca70490a35615d3fef2dce" "reference": "720fcc7e9b5cf384ea68d9d930d480907a0c1a29"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/366541b989927187c4ca70490a35615d3fef2dce", "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/720fcc7e9b5cf384ea68d9d930d480907a0c1a29",
"reference": "366541b989927187c4ca70490a35615d3fef2dce", "reference": "720fcc7e9b5cf384ea68d9d930d480907a0c1a29",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
"php": "^7.1" "php": "^7.1"
}, },
"require-dev": { "require-dev": {
"phpunit/phpunit": "^7.0", "phpunit/phpunit": "^7.5 || ^8.0",
"symfony/process": "^2 || ^3.3 || ^4" "symfony/process": "^2 || ^3.3 || ^4"
}, },
"type": "library", "type": "library",
...@@ -2076,20 +2078,20 @@ ...@@ -2076,20 +2078,20 @@
"unidiff", "unidiff",
"unified diff" "unified diff"
], ],
"time": "2018-06-10T07:54:39+00:00" "time": "2019-02-04T06:01:07+00:00"
}, },
{ {
"name": "sebastian/environment", "name": "sebastian/environment",
"version": "4.1.0", "version": "4.2.2",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/sebastianbergmann/environment.git", "url": "https://github.com/sebastianbergmann/environment.git",
"reference": "6fda8ce1974b62b14935adc02a9ed38252eca656" "reference": "f2a2c8e1c97c11ace607a7a667d73d47c19fe404"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/6fda8ce1974b62b14935adc02a9ed38252eca656", "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/f2a2c8e1c97c11ace607a7a667d73d47c19fe404",
"reference": "6fda8ce1974b62b14935adc02a9ed38252eca656", "reference": "f2a2c8e1c97c11ace607a7a667d73d47c19fe404",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
...@@ -2104,7 +2106,7 @@ ...@@ -2104,7 +2106,7 @@
"type": "library", "type": "library",
"extra": { "extra": {
"branch-alias": { "branch-alias": {
"dev-master": "4.1-dev" "dev-master": "4.2-dev"
} }
}, },
"autoload": { "autoload": {
...@@ -2129,7 +2131,7 @@ ...@@ -2129,7 +2131,7 @@
"environment", "environment",
"hhvm" "hhvm"
], ],
"time": "2019-02-01T05:27:49+00:00" "time": "2019-05-05T09:05:15+00:00"
}, },
{ {
"name": "sebastian/exporter", "name": "sebastian/exporter",
...@@ -2886,16 +2888,16 @@ ...@@ -2886,16 +2888,16 @@
}, },
{ {
"name": "symfony/polyfill-ctype", "name": "symfony/polyfill-ctype",
"version": "v1.10.0", "version": "v1.11.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symfony/polyfill-ctype.git", "url": "https://github.com/symfony/polyfill-ctype.git",
"reference": "e3d826245268269cd66f8326bd8bc066687b4a19" "reference": "82ebae02209c21113908c229e9883c419720738a"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/e3d826245268269cd66f8326bd8bc066687b4a19", "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/82ebae02209c21113908c229e9883c419720738a",
"reference": "e3d826245268269cd66f8326bd8bc066687b4a19", "reference": "82ebae02209c21113908c229e9883c419720738a",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
...@@ -2907,7 +2909,7 @@ ...@@ -2907,7 +2909,7 @@
"type": "library", "type": "library",
"extra": { "extra": {
"branch-alias": { "branch-alias": {
"dev-master": "1.9-dev" "dev-master": "1.11-dev"
} }
}, },
"autoload": { "autoload": {
...@@ -2940,7 +2942,7 @@ ...@@ -2940,7 +2942,7 @@
"polyfill", "polyfill",
"portable" "portable"
], ],
"time": "2018-08-06T14:22:27+00:00" "time": "2019-02-06T07:57:58+00:00"
}, },
{ {
"name": "symfony/polyfill-mbstring", "name": "symfony/polyfill-mbstring",
...@@ -3003,16 +3005,16 @@ ...@@ -3003,16 +3005,16 @@
}, },
{ {
"name": "theseer/tokenizer", "name": "theseer/tokenizer",
"version": "1.1.0", "version": "1.1.2",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/theseer/tokenizer.git", "url": "https://github.com/theseer/tokenizer.git",
"reference": "cb2f008f3f05af2893a87208fe6a6c4985483f8b" "reference": "1c42705be2b6c1de5904f8afacef5895cab44bf8"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/theseer/tokenizer/zipball/cb2f008f3f05af2893a87208fe6a6c4985483f8b", "url": "https://api.github.com/repos/theseer/tokenizer/zipball/1c42705be2b6c1de5904f8afacef5895cab44bf8",
"reference": "cb2f008f3f05af2893a87208fe6a6c4985483f8b", "reference": "1c42705be2b6c1de5904f8afacef5895cab44bf8",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
...@@ -3039,7 +3041,7 @@ ...@@ -3039,7 +3041,7 @@
} }
], ],
"description": "A small library for converting tokenized PHP source code into XML and potentially other formats", "description": "A small library for converting tokenized PHP source code into XML and potentially other formats",
"time": "2017-04-07T12:08:54+00:00" "time": "2019-04-04T09:56:43+00:00"
}, },
{ {
"name": "webmozart/assert", "name": "webmozart/assert",
......
...@@ -35,22 +35,10 @@ class DBALExceptionTest extends DbalTestCase ...@@ -35,22 +35,10 @@ class DBALExceptionTest extends DbalTestCase
{ {
/** @var Driver $driver */ /** @var Driver $driver */
$driver = $this->createMock(Driver::class); $driver = $this->createMock(Driver::class);
$inner = new class extends Exception implements InnerDriverException
{
/**
* {@inheritDoc}
*/
public function getErrorCode()
{
}
/** /** @var InnerDriverException $inner */
* {@inheritDoc} $inner = $this->createMock(InnerDriverException::class);
*/
public function getSQLState()
{
}
};
$ex = new DriverException('', $inner); $ex = new DriverException('', $inner);
$e = DBALException::driverExceptionDuringQuery($driver, $ex, ''); $e = DBALException::driverExceptionDuringQuery($driver, $ex, '');
self::assertSame($ex, $e); self::assertSame($ex, $e);
......
...@@ -30,6 +30,7 @@ use Doctrine\DBAL\VersionAwarePlatformDriver; ...@@ -30,6 +30,7 @@ use Doctrine\DBAL\VersionAwarePlatformDriver;
use Doctrine\Tests\DbalTestCase; use Doctrine\Tests\DbalTestCase;
use Exception; use Exception;
use ReflectionProperty; use ReflectionProperty;
use function array_merge;
use function get_class; use function get_class;
use function sprintf; use function sprintf;
...@@ -67,29 +68,31 @@ abstract class AbstractDriverTest extends DbalTestCase ...@@ -67,29 +68,31 @@ abstract class AbstractDriverTest extends DbalTestCase
$this->driver = $this->createDriver(); $this->driver = $this->createDriver();
} }
public function testConvertsException() /**
* @dataProvider exceptionConversionProvider
*/
public function testConvertsException($errorCode, $sqlState, $message, string $expectedClass) : void
{ {
if (! $this->driver instanceof ExceptionConverterDriver) { if (! $this->driver instanceof ExceptionConverterDriver) {
$this->markTestSkipped('This test is only intended for exception converter drivers.'); $this->markTestSkipped('This test is only intended for exception converter drivers.');
} }
$data = $this->getExceptionConversions(); $driverException = new class ($errorCode, $sqlState, $message)
extends Exception
implements DriverExceptionInterface
{
/** @var mixed */
private $errorCode;
if (empty($data)) { /** @var mixed */
$this->fail( private $sqlState;
sprintf(
'No test data found for test %s. You have to return test data from %s.',
static::class . '::' . __FUNCTION__,
static::class . '::getExceptionConversionData'
)
);
}
$driverException = new class extends Exception implements DriverExceptionInterface public function __construct($errorCode, $sqlState, $message)
{
public function __construct()
{ {
parent::__construct('baz'); parent::__construct($message);
$this->errorCode = $errorCode;
$this->sqlState = $sqlState;
} }
/** /**
...@@ -97,7 +100,7 @@ abstract class AbstractDriverTest extends DbalTestCase ...@@ -97,7 +100,7 @@ abstract class AbstractDriverTest extends DbalTestCase
*/ */
public function getErrorCode() public function getErrorCode()
{ {
return 'foo'; return $this->errorCode;
} }
/** /**
...@@ -105,26 +108,19 @@ abstract class AbstractDriverTest extends DbalTestCase ...@@ -105,26 +108,19 @@ abstract class AbstractDriverTest extends DbalTestCase
*/ */
public function getSQLState() public function getSQLState()
{ {
return 'bar'; return $this->sqlState;
} }
}; };
$data[] = [$driverException, self::EXCEPTION_DRIVER]; $dbalMessage = 'DBAL exception message';
$dbalException = $this->driver->convertException($dbalMessage, $driverException);
$message = 'DBAL exception message';
foreach ($data as $item) {
/** @var $driverException \Doctrine\DBAL\Driver\DriverException */
[$driverException, $convertedExceptionClassName] = $item;
$convertedException = $this->driver->convertException($message, $driverException);
self::assertSame($convertedExceptionClassName, get_class($convertedException)); self::assertInstanceOf($expectedClass, $dbalException);
self::assertSame($driverException->getErrorCode(), $convertedException->getErrorCode()); self::assertSame($driverException->getErrorCode(), $dbalException->getErrorCode());
self::assertSame($driverException->getSQLState(), $convertedException->getSQLState()); self::assertSame($driverException->getSQLState(), $dbalException->getSQLState());
self::assertSame($message, $convertedException->getMessage()); self::assertSame($driverException, $dbalException->getPrevious());
} self::assertSame($dbalMessage, $dbalException->getMessage());
} }
public function testCreatesDatabasePlatformForVersion() public function testCreatesDatabasePlatformForVersion()
...@@ -246,56 +242,25 @@ abstract class AbstractDriverTest extends DbalTestCase ...@@ -246,56 +242,25 @@ abstract class AbstractDriverTest extends DbalTestCase
return []; return [];
} }
protected function getExceptionConversionData() /**
* @return mixed[][]
*/
public static function exceptionConversionProvider() : iterable
{ {
return []; foreach (static::getExceptionConversionData() as $expectedClass => $items) {
foreach ($items as $item) {
yield array_merge($item, [$expectedClass]);
} }
private function getExceptionConversions()
{
$data = [];
foreach ($this->getExceptionConversionData() as $convertedExceptionClassName => $errors) {
foreach ($errors as $error) {
$driverException = new class ($error[0], $error[1], $error[2])
extends Exception
implements DriverExceptionInterface
{
/** @var mixed */
private $errorCode;
/** @var mixed */
private $sqlState;
public function __construct($errorCode, $sqlState, $message)
{
parent::__construct($message);
$this->errorCode = $errorCode;
$this->sqlState = $sqlState;
} }
/** yield ['foo', 'bar', 'baz', self::EXCEPTION_DRIVER];
* {@inheritDoc}
*/
public function getErrorCode()
{
return $this->errorCode;
} }
/** /**
* {@inheritDoc} * @return array<string,mixed[][]>
*/ */
public function getSQLState() protected static function getExceptionConversionData() : array
{ {
return $this->sqlState; return [];
}
};
$data[] = [$driverException, $convertedExceptionClassName];
}
}
return $data;
} }
} }
...@@ -83,7 +83,10 @@ class AbstractMySQLDriverTest extends AbstractDriverTest ...@@ -83,7 +83,10 @@ class AbstractMySQLDriverTest extends AbstractDriverTest
]; ];
} }
protected function getExceptionConversionData() /**
* {@inheritDoc}
*/
protected static function getExceptionConversionData() : array
{ {
return [ return [
self::EXCEPTION_CONNECTION => [ self::EXCEPTION_CONNECTION => [
......
...@@ -60,7 +60,10 @@ class AbstractOracleDriverTest extends AbstractDriverTest ...@@ -60,7 +60,10 @@ class AbstractOracleDriverTest extends AbstractDriverTest
return new OracleSchemaManager($connection); return new OracleSchemaManager($connection);
} }
protected function getExceptionConversionData() /**
* {@inheritDoc}
*/
protected static function getExceptionConversionData() : array
{ {
return [ return [
self::EXCEPTION_CONNECTION => [ self::EXCEPTION_CONNECTION => [
......
...@@ -77,7 +77,10 @@ class AbstractPostgreSQLDriverTest extends AbstractDriverTest ...@@ -77,7 +77,10 @@ class AbstractPostgreSQLDriverTest extends AbstractDriverTest
]; ];
} }
protected function getExceptionConversionData() /**
* {@inheritDoc}
*/
protected static function getExceptionConversionData() : array
{ {
return [ return [
self::EXCEPTION_CONNECTION => [ self::EXCEPTION_CONNECTION => [
......
...@@ -62,7 +62,10 @@ class AbstractSQLAnywhereDriverTest extends AbstractDriverTest ...@@ -62,7 +62,10 @@ class AbstractSQLAnywhereDriverTest extends AbstractDriverTest
]; ];
} }
protected function getExceptionConversionData() /**
* {@inheritDoc}
*/
protected static function getExceptionConversionData() : array
{ {
return [ return [
self::EXCEPTION_CONNECTION => [ self::EXCEPTION_CONNECTION => [
......
...@@ -42,7 +42,10 @@ class AbstractSQLiteDriverTest extends AbstractDriverTest ...@@ -42,7 +42,10 @@ class AbstractSQLiteDriverTest extends AbstractDriverTest
return new SqliteSchemaManager($connection); return new SqliteSchemaManager($connection);
} }
protected function getExceptionConversionData() /**
* {@inheritDoc}
*/
protected static function getExceptionConversionData() : array
{ {
return [ return [
self::EXCEPTION_CONNECTION => [ self::EXCEPTION_CONNECTION => [
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment