PHPCBF

parent f18ced56
...@@ -12,36 +12,26 @@ class QueryCacheProfileTest extends DbalTestCase ...@@ -12,36 +12,26 @@ class QueryCacheProfileTest extends DbalTestCase
private const LIFETIME = 3600; private const LIFETIME = 3600;
private const CACHE_KEY = 'user_specified_cache_key'; private const CACHE_KEY = 'user_specified_cache_key';
/** /** @var QueryCacheProfile */
* @var QueryCacheProfile
*/
private $queryCacheProfile; private $queryCacheProfile;
/** /** @var string */
* @var string
*/
private $query = 'SELECT * FROM foo WHERE bar = ?'; private $query = 'SELECT * FROM foo WHERE bar = ?';
/** /** @var int[] */
* @var int[]
*/
private $params = [666]; private $params = [666];
/** /** @var string[] */
* @var string[]
*/
private $types = [ParameterType::INTEGER]; private $types = [ParameterType::INTEGER];
/** /** @var string[] */
* @var string[]
*/
private $connectionParams = [ private $connectionParams = [
'dbname' => 'database_name', 'dbname' => 'database_name',
'user' => 'database_user', 'user' => 'database_user',
'password' => 'database_password', 'password' => 'database_password',
'host' => 'database_host', 'host' => 'database_host',
'driver' => 'database_driver', 'driver' => 'database_driver',
]; ];
protected function setUp() protected function setUp()
{ {
...@@ -50,7 +40,7 @@ class QueryCacheProfileTest extends DbalTestCase ...@@ -50,7 +40,7 @@ class QueryCacheProfileTest extends DbalTestCase
public function testShouldUseTheGivenCacheKeyIfPresent() public function testShouldUseTheGivenCacheKeyIfPresent()
{ {
list($cacheKey) = $this->queryCacheProfile->generateCacheKeys( [$cacheKey] = $this->queryCacheProfile->generateCacheKeys(
$this->query, $this->query,
$this->params, $this->params,
$this->types, $this->types,
...@@ -64,7 +54,7 @@ class QueryCacheProfileTest extends DbalTestCase ...@@ -64,7 +54,7 @@ class QueryCacheProfileTest extends DbalTestCase
{ {
$this->queryCacheProfile = $this->queryCacheProfile->setCacheKey(null); $this->queryCacheProfile = $this->queryCacheProfile->setCacheKey(null);
list($cacheKey) = $this->queryCacheProfile->generateCacheKeys( [$cacheKey] = $this->queryCacheProfile->generateCacheKeys(
$this->query, $this->query,
$this->params, $this->params,
$this->types, $this->types,
...@@ -84,7 +74,7 @@ class QueryCacheProfileTest extends DbalTestCase ...@@ -84,7 +74,7 @@ class QueryCacheProfileTest extends DbalTestCase
{ {
$this->queryCacheProfile = $this->queryCacheProfile->setCacheKey(null); $this->queryCacheProfile = $this->queryCacheProfile->setCacheKey(null);
list($firstCacheKey) = $this->queryCacheProfile->generateCacheKeys( [$firstCacheKey] = $this->queryCacheProfile->generateCacheKeys(
$this->query, $this->query,
$this->params, $this->params,
$this->types, $this->types,
...@@ -93,7 +83,7 @@ class QueryCacheProfileTest extends DbalTestCase ...@@ -93,7 +83,7 @@ class QueryCacheProfileTest extends DbalTestCase
$this->connectionParams['host'] = 'a_different_host'; $this->connectionParams['host'] = 'a_different_host';
list($secondCacheKey) = $this->queryCacheProfile->generateCacheKeys( [$secondCacheKey] = $this->queryCacheProfile->generateCacheKeys(
$this->query, $this->query,
$this->params, $this->params,
$this->types, $this->types,
...@@ -107,7 +97,7 @@ class QueryCacheProfileTest extends DbalTestCase ...@@ -107,7 +97,7 @@ class QueryCacheProfileTest extends DbalTestCase
{ {
$this->queryCacheProfile = $this->queryCacheProfile->setCacheKey(null); $this->queryCacheProfile = $this->queryCacheProfile->setCacheKey(null);
list($cacheKey, $queryString) = $this->queryCacheProfile->generateCacheKeys( [$cacheKey, $queryString] = $this->queryCacheProfile->generateCacheKeys(
$this->query, $this->query,
$this->params, $this->params,
$this->types, $this->types,
...@@ -128,14 +118,14 @@ class QueryCacheProfileTest extends DbalTestCase ...@@ -128,14 +118,14 @@ class QueryCacheProfileTest extends DbalTestCase
{ {
$this->queryCacheProfile = $this->queryCacheProfile->setCacheKey(null); $this->queryCacheProfile = $this->queryCacheProfile->setCacheKey(null);
list($firstCacheKey) = $this->queryCacheProfile->generateCacheKeys( [$firstCacheKey] = $this->queryCacheProfile->generateCacheKeys(
$this->query, $this->query,
$this->params, $this->params,
$this->types, $this->types,
$this->connectionParams $this->connectionParams
); );
list($secondCacheKey) = $this->queryCacheProfile->generateCacheKeys( [$secondCacheKey] = $this->queryCacheProfile->generateCacheKeys(
$this->query, $this->query,
$this->params, $this->params,
$this->types, $this->types,
......
...@@ -24,15 +24,13 @@ use Doctrine\Tests\DbalTestCase; ...@@ -24,15 +24,13 @@ use Doctrine\Tests\DbalTestCase;
/** /**
* Unit tests for the configuration container. * Unit tests for the configuration container.
*
* @author Steve Müller <st.mueller@dzh-online.de>
*/ */
class ConfigurationTest extends DbalTestCase class ConfigurationTest extends DbalTestCase
{ {
/** /**
* The configuration container instance under test. * The configuration container instance under test.
* *
* @var \Doctrine\DBAL\Configuration * @var Configuration
*/ */
protected $config; protected $config;
......
...@@ -3,10 +3,12 @@ ...@@ -3,10 +3,12 @@
namespace Doctrine\Tests\DBAL; namespace Doctrine\Tests\DBAL;
use Doctrine\DBAL\DBALException; use Doctrine\DBAL\DBALException;
use Doctrine\DBAL\Exception\DriverException; use Doctrine\DBAL\Driver;
use Doctrine\DBAL\Driver\DriverException as InnerDriverException; use Doctrine\DBAL\Driver\DriverException as InnerDriverException;
use Doctrine\DBAL\Exception\DriverException;
use Doctrine\Tests\DbalTestCase; use Doctrine\Tests\DbalTestCase;
use Doctrine\DBAL\Driver; use Exception;
use stdClass;
use function chr; use function chr;
use function fopen; use function fopen;
use function sprintf; use function sprintf;
...@@ -15,25 +17,25 @@ class DBALExceptionTest extends DbalTestCase ...@@ -15,25 +17,25 @@ class DBALExceptionTest extends DbalTestCase
{ {
public function testDriverExceptionDuringQueryAcceptsBinaryData() public function testDriverExceptionDuringQueryAcceptsBinaryData()
{ {
/* @var $driver Driver */ /** @var Driver $driver */
$driver = $this->createMock(Driver::class); $driver = $this->createMock(Driver::class);
$e = DBALException::driverExceptionDuringQuery($driver, new \Exception, '', array('ABC', chr(128))); $e = DBALException::driverExceptionDuringQuery($driver, new Exception(), '', ['ABC', chr(128)]);
self::assertContains('with params ["ABC", "\x80"]', $e->getMessage()); self::assertContains('with params ["ABC", "\x80"]', $e->getMessage());
} }
public function testDriverExceptionDuringQueryAcceptsResource() public function testDriverExceptionDuringQueryAcceptsResource()
{ {
/* @var $driver Driver */ /** @var Driver $driver */
$driver = $this->createMock(Driver::class); $driver = $this->createMock(Driver::class);
$e = \Doctrine\DBAL\DBALException::driverExceptionDuringQuery($driver, new \Exception, "INSERT INTO file (`content`) VALUES (?)", [1 => fopen(__FILE__, 'r')]); $e = DBALException::driverExceptionDuringQuery($driver, new Exception(), 'INSERT INTO file (`content`) VALUES (?)', [1 => fopen(__FILE__, 'r')]);
self::assertContains('Resource', $e->getMessage()); self::assertContains('Resource', $e->getMessage());
} }
public function testAvoidOverWrappingOnDriverException() public function testAvoidOverWrappingOnDriverException()
{ {
/* @var $driver Driver */ /** @var Driver $driver */
$driver = $this->createMock(Driver::class); $driver = $this->createMock(Driver::class);
$inner = new class extends \Exception implements InnerDriverException $inner = new class extends Exception implements InnerDriverException
{ {
/** /**
* {@inheritDoc} * {@inheritDoc}
...@@ -49,14 +51,14 @@ class DBALExceptionTest extends DbalTestCase ...@@ -49,14 +51,14 @@ class DBALExceptionTest extends DbalTestCase
{ {
} }
}; };
$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);
} }
public function testDriverRequiredWithUrl() public function testDriverRequiredWithUrl()
{ {
$url = 'mysql://localhost'; $url = 'mysql://localhost';
$exception = DBALException::driverRequired($url); $exception = DBALException::driverRequired($url);
self::assertInstanceOf(DBALException::class, $exception); self::assertInstanceOf(DBALException::class, $exception);
...@@ -73,9 +75,9 @@ class DBALExceptionTest extends DbalTestCase ...@@ -73,9 +75,9 @@ class DBALExceptionTest extends DbalTestCase
/** /**
* @group #2821 * @group #2821
*/ */
public function testInvalidPlatformTypeObject(): void public function testInvalidPlatformTypeObject() : void
{ {
$exception = DBALException::invalidPlatformType(new \stdClass()); $exception = DBALException::invalidPlatformType(new stdClass());
self::assertSame( self::assertSame(
"Option 'platform' must be a subtype of 'Doctrine\DBAL\Platforms\AbstractPlatform', instance of 'stdClass' given", "Option 'platform' must be a subtype of 'Doctrine\DBAL\Platforms\AbstractPlatform', instance of 'stdClass' given",
...@@ -86,7 +88,7 @@ class DBALExceptionTest extends DbalTestCase ...@@ -86,7 +88,7 @@ class DBALExceptionTest extends DbalTestCase
/** /**
* @group #2821 * @group #2821
*/ */
public function testInvalidPlatformTypeScalar(): void public function testInvalidPlatformTypeScalar() : void
{ {
$exception = DBALException::invalidPlatformType('some string'); $exception = DBALException::invalidPlatformType('some string');
......
...@@ -3,37 +3,41 @@ ...@@ -3,37 +3,41 @@
namespace Doctrine\Tests\DBAL\Driver; namespace Doctrine\Tests\DBAL\Driver;
use Doctrine\DBAL\Connection; use Doctrine\DBAL\Connection;
use Doctrine\DBAL\Driver;
use Doctrine\DBAL\Driver\DriverException; use Doctrine\DBAL\Driver\DriverException;
use Doctrine\DBAL\Driver\ExceptionConverterDriver; use Doctrine\DBAL\Driver\ExceptionConverterDriver;
use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Schema\AbstractSchemaManager;
use Doctrine\DBAL\VersionAwarePlatformDriver; use Doctrine\DBAL\VersionAwarePlatformDriver;
use Doctrine\Tests\DbalTestCase; use Doctrine\Tests\DbalTestCase;
use Exception;
use function get_class; use function get_class;
use function sprintf; use function sprintf;
abstract class AbstractDriverTest extends DbalTestCase abstract class AbstractDriverTest extends DbalTestCase
{ {
const EXCEPTION_CONNECTION = 'Doctrine\DBAL\Exception\ConnectionException'; public const EXCEPTION_CONNECTION = 'Doctrine\DBAL\Exception\ConnectionException';
const EXCEPTION_CONSTRAINT_VIOLATION = 'Doctrine\DBAL\Exception\ConstraintViolationException'; public const EXCEPTION_CONSTRAINT_VIOLATION = 'Doctrine\DBAL\Exception\ConstraintViolationException';
const EXCEPTION_DATABASE_OBJECT_EXISTS = 'Doctrine\DBAL\Exception\DatabaseObjectExistsException'; public const EXCEPTION_DATABASE_OBJECT_EXISTS = 'Doctrine\DBAL\Exception\DatabaseObjectExistsException';
const EXCEPTION_DATABASE_OBJECT_NOT_FOUND = 'Doctrine\DBAL\Exception\DatabaseObjectNotFoundException'; public const EXCEPTION_DATABASE_OBJECT_NOT_FOUND = 'Doctrine\DBAL\Exception\DatabaseObjectNotFoundException';
const EXCEPTION_DRIVER = 'Doctrine\DBAL\Exception\DriverException'; public const EXCEPTION_DRIVER = 'Doctrine\DBAL\Exception\DriverException';
const EXCEPTION_FOREIGN_KEY_CONSTRAINT_VIOLATION = 'Doctrine\DBAL\Exception\ForeignKeyConstraintViolationException'; public const EXCEPTION_FOREIGN_KEY_CONSTRAINT_VIOLATION = 'Doctrine\DBAL\Exception\ForeignKeyConstraintViolationException';
const EXCEPTION_INVALID_FIELD_NAME = 'Doctrine\DBAL\Exception\InvalidFieldNameException'; public const EXCEPTION_INVALID_FIELD_NAME = 'Doctrine\DBAL\Exception\InvalidFieldNameException';
const EXCEPTION_NON_UNIQUE_FIELD_NAME = 'Doctrine\DBAL\Exception\NonUniqueFieldNameException'; public const EXCEPTION_NON_UNIQUE_FIELD_NAME = 'Doctrine\DBAL\Exception\NonUniqueFieldNameException';
const EXCEPTION_NOT_NULL_CONSTRAINT_VIOLATION = 'Doctrine\DBAL\Exception\NotNullConstraintViolationException'; public const EXCEPTION_NOT_NULL_CONSTRAINT_VIOLATION = 'Doctrine\DBAL\Exception\NotNullConstraintViolationException';
const EXCEPTION_READ_ONLY = 'Doctrine\DBAL\Exception\ReadOnlyException'; public const EXCEPTION_READ_ONLY = 'Doctrine\DBAL\Exception\ReadOnlyException';
const EXCEPTION_SERVER = 'Doctrine\DBAL\Exception\ServerException'; public const EXCEPTION_SERVER = 'Doctrine\DBAL\Exception\ServerException';
const EXCEPTION_SYNTAX_ERROR = 'Doctrine\DBAL\Exception\SyntaxErrorException'; public const EXCEPTION_SYNTAX_ERROR = 'Doctrine\DBAL\Exception\SyntaxErrorException';
const EXCEPTION_TABLE_EXISTS = 'Doctrine\DBAL\Exception\TableExistsException'; public const EXCEPTION_TABLE_EXISTS = 'Doctrine\DBAL\Exception\TableExistsException';
const EXCEPTION_TABLE_NOT_FOUND = 'Doctrine\DBAL\Exception\TableNotFoundException'; public const EXCEPTION_TABLE_NOT_FOUND = 'Doctrine\DBAL\Exception\TableNotFoundException';
const EXCEPTION_UNIQUE_CONSTRAINT_VIOLATION = 'Doctrine\DBAL\Exception\UniqueConstraintViolationException'; public const EXCEPTION_UNIQUE_CONSTRAINT_VIOLATION = 'Doctrine\DBAL\Exception\UniqueConstraintViolationException';
const EXCEPTION_DEADLOCK = 'Doctrine\DBAL\Exception\DeadlockException'; public const EXCEPTION_DEADLOCK = 'Doctrine\DBAL\Exception\DeadlockException';
const EXCEPTION_LOCK_WAIT_TIMEOUT = 'Doctrine\DBAL\Exception\LockWaitTimeoutException'; public const EXCEPTION_LOCK_WAIT_TIMEOUT = 'Doctrine\DBAL\Exception\LockWaitTimeoutException';
/** /**
* The driver mock under test. * The driver mock under test.
* *
* @var \Doctrine\DBAL\Driver * @var Driver
*/ */
protected $driver; protected $driver;
...@@ -46,7 +50,7 @@ abstract class AbstractDriverTest extends DbalTestCase ...@@ -46,7 +50,7 @@ abstract class AbstractDriverTest extends DbalTestCase
public function testConvertsException() public function testConvertsException()
{ {
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.');
} }
...@@ -56,13 +60,13 @@ abstract class AbstractDriverTest extends DbalTestCase ...@@ -56,13 +60,13 @@ abstract class AbstractDriverTest extends DbalTestCase
$this->fail( $this->fail(
sprintf( sprintf(
'No test data found for test %s. You have to return test data from %s.', 'No test data found for test %s. You have to return test data from %s.',
get_class($this) . '::' . __FUNCTION__, static::class . '::' . __FUNCTION__,
get_class($this) . '::getExceptionConversionData' static::class . '::getExceptionConversionData'
) )
); );
} }
$driverException = new class extends \Exception implements DriverException $driverException = new class extends Exception implements DriverException
{ {
public function __construct() public function __construct()
{ {
...@@ -86,13 +90,13 @@ abstract class AbstractDriverTest extends DbalTestCase ...@@ -86,13 +90,13 @@ abstract class AbstractDriverTest extends DbalTestCase
} }
}; };
$data[] = array($driverException, self::EXCEPTION_DRIVER); $data[] = [$driverException, self::EXCEPTION_DRIVER];
$message = 'DBAL exception message'; $message = 'DBAL exception message';
foreach ($data as $item) { foreach ($data as $item) {
/** @var $driverException \Doctrine\DBAL\Driver\DriverException */ /** @var $driverException \Doctrine\DBAL\Driver\DriverException */
list($driverException, $convertedExceptionClassName) = $item; [$driverException, $convertedExceptionClassName] = $item;
$convertedException = $this->driver->convertException($message, $driverException); $convertedException = $this->driver->convertException($message, $driverException);
...@@ -106,7 +110,7 @@ abstract class AbstractDriverTest extends DbalTestCase ...@@ -106,7 +110,7 @@ abstract class AbstractDriverTest extends DbalTestCase
public function testCreatesDatabasePlatformForVersion() public function testCreatesDatabasePlatformForVersion()
{ {
if ( ! $this->driver instanceof VersionAwarePlatformDriver) { if (! $this->driver instanceof VersionAwarePlatformDriver) {
$this->markTestSkipped('This test is only intended for version aware platform drivers.'); $this->markTestSkipped('This test is only intended for version aware platform drivers.');
} }
...@@ -116,8 +120,8 @@ abstract class AbstractDriverTest extends DbalTestCase ...@@ -116,8 +120,8 @@ abstract class AbstractDriverTest extends DbalTestCase
$data, $data,
sprintf( sprintf(
'No test data found for test %s. You have to return test data from %s.', 'No test data found for test %s. You have to return test data from %s.',
get_class($this) . '::' . __FUNCTION__, static::class . '::' . __FUNCTION__,
get_class($this) . '::getDatabasePlatformsForVersions' static::class . '::getDatabasePlatformsForVersions'
) )
); );
...@@ -142,7 +146,7 @@ abstract class AbstractDriverTest extends DbalTestCase ...@@ -142,7 +146,7 @@ abstract class AbstractDriverTest extends DbalTestCase
*/ */
public function testThrowsExceptionOnCreatingDatabasePlatformsForInvalidVersion() public function testThrowsExceptionOnCreatingDatabasePlatformsForInvalidVersion()
{ {
if ( ! $this->driver instanceof VersionAwarePlatformDriver) { if (! $this->driver instanceof VersionAwarePlatformDriver) {
$this->markTestSkipped('This test is only intended for version aware platform drivers.'); $this->markTestSkipped('This test is only intended for version aware platform drivers.');
} }
...@@ -151,11 +155,11 @@ abstract class AbstractDriverTest extends DbalTestCase ...@@ -151,11 +155,11 @@ abstract class AbstractDriverTest extends DbalTestCase
public function testReturnsDatabaseName() public function testReturnsDatabaseName()
{ {
$params = array( $params = [
'user' => 'foo', 'user' => 'foo',
'password' => 'bar', 'password' => 'bar',
'dbname' => 'baz', 'dbname' => 'baz',
); ];
$connection = $this->getConnectionMock(); $connection = $this->getConnectionMock();
...@@ -183,7 +187,7 @@ abstract class AbstractDriverTest extends DbalTestCase ...@@ -183,7 +187,7 @@ abstract class AbstractDriverTest extends DbalTestCase
/** /**
* Factory method for creating the driver instance under test. * Factory method for creating the driver instance under test.
* *
* @return \Doctrine\DBAL\Driver * @return Driver
*/ */
abstract protected function createDriver(); abstract protected function createDriver();
...@@ -193,7 +197,7 @@ abstract class AbstractDriverTest extends DbalTestCase ...@@ -193,7 +197,7 @@ abstract class AbstractDriverTest extends DbalTestCase
* The platform instance returned by this method must be the same as returned by * The platform instance returned by this method must be the same as returned by
* the driver's getDatabasePlatform() method. * the driver's getDatabasePlatform() method.
* *
* @return \Doctrine\DBAL\Platforms\AbstractPlatform * @return AbstractPlatform
*/ */
abstract protected function createPlatform(); abstract protected function createPlatform();
...@@ -205,7 +209,7 @@ abstract class AbstractDriverTest extends DbalTestCase ...@@ -205,7 +209,7 @@ abstract class AbstractDriverTest extends DbalTestCase
* *
* @param Connection $connection The underlying connection to use. * @param Connection $connection The underlying connection to use.
* *
* @return \Doctrine\DBAL\Schema\AbstractSchemaManager * @return AbstractSchemaManager
*/ */
abstract protected function createSchemaManager(Connection $connection); abstract protected function createSchemaManager(Connection $connection);
...@@ -218,32 +222,28 @@ abstract class AbstractDriverTest extends DbalTestCase ...@@ -218,32 +222,28 @@ abstract class AbstractDriverTest extends DbalTestCase
protected function getDatabasePlatformsForVersions() protected function getDatabasePlatformsForVersions()
{ {
return array(); return [];
} }
protected function getExceptionConversionData() protected function getExceptionConversionData()
{ {
return array(); return [];
} }
private function getExceptionConversions() private function getExceptionConversions()
{ {
$data = array(); $data = [];
foreach ($this->getExceptionConversionData() as $convertedExceptionClassName => $errors) { foreach ($this->getExceptionConversionData() as $convertedExceptionClassName => $errors) {
foreach ($errors as $error) { foreach ($errors as $error) {
$driverException = new class ($error[0], $error[1], $error[2]) $driverException = new class ($error[0], $error[1], $error[2])
extends \Exception extends Exception
implements DriverException implements DriverException
{ {
/** /** @var mixed */
* @var mixed
*/
private $errorCode; private $errorCode;
/** /** @var mixed */
* @var mixed
*/
private $sqlState; private $sqlState;
public function __construct($errorCode, $sqlState, $message) public function __construct($errorCode, $sqlState, $message)
...@@ -271,7 +271,7 @@ abstract class AbstractDriverTest extends DbalTestCase ...@@ -271,7 +271,7 @@ abstract class AbstractDriverTest extends DbalTestCase
} }
}; };
$data[] = array($driverException, $convertedExceptionClassName); $data[] = [$driverException, $convertedExceptionClassName];
} }
} }
......
...@@ -16,10 +16,10 @@ class AbstractMySQLDriverTest extends AbstractDriverTest ...@@ -16,10 +16,10 @@ class AbstractMySQLDriverTest extends AbstractDriverTest
parent::testReturnsDatabaseName(); parent::testReturnsDatabaseName();
$database = 'bloo'; $database = 'bloo';
$params = array( $params = [
'user' => 'foo', 'user' => 'foo',
'password' => 'bar', 'password' => 'bar',
); ];
$statement = $this->createMock('Doctrine\Tests\Mocks\DriverResultStatementMock'); $statement = $this->createMock('Doctrine\Tests\Mocks\DriverResultStatementMock');
...@@ -74,85 +74,85 @@ class AbstractMySQLDriverTest extends AbstractDriverTest ...@@ -74,85 +74,85 @@ class AbstractMySQLDriverTest extends AbstractDriverTest
['5.5.40-MariaDB-1~wheezy', MySqlPlatform::class], ['5.5.40-MariaDB-1~wheezy', MySqlPlatform::class],
['5.5.5-MariaDB-10.2.8+maria~xenial-log', MariaDb1027Platform::class], ['5.5.5-MariaDB-10.2.8+maria~xenial-log', MariaDb1027Platform::class],
['10.2.8-MariaDB-10.2.8+maria~xenial-log', MariaDb1027Platform::class], ['10.2.8-MariaDB-10.2.8+maria~xenial-log', MariaDb1027Platform::class],
['10.2.8-MariaDB-1~lenny-log', MariaDb1027Platform::class] ['10.2.8-MariaDB-1~lenny-log', MariaDb1027Platform::class],
]; ];
} }
protected function getExceptionConversionData() protected function getExceptionConversionData()
{ {
return array( return [
self::EXCEPTION_CONNECTION => array( self::EXCEPTION_CONNECTION => [
array('1044', null, null), ['1044', null, null],
array('1045', null, null), ['1045', null, null],
array('1046', null, null), ['1046', null, null],
array('1049', null, null), ['1049', null, null],
array('1095', null, null), ['1095', null, null],
array('1142', null, null), ['1142', null, null],
array('1143', null, null), ['1143', null, null],
array('1227', null, null), ['1227', null, null],
array('1370', null, null), ['1370', null, null],
array('2002', null, null), ['2002', null, null],
array('2005', null, null), ['2005', null, null],
), ],
self::EXCEPTION_FOREIGN_KEY_CONSTRAINT_VIOLATION => array( self::EXCEPTION_FOREIGN_KEY_CONSTRAINT_VIOLATION => [
array('1216', null, null), ['1216', null, null],
array('1217', null, null), ['1217', null, null],
array('1451', null, null), ['1451', null, null],
array('1452', null, null), ['1452', null, null],
), ],
self::EXCEPTION_INVALID_FIELD_NAME => array( self::EXCEPTION_INVALID_FIELD_NAME => [
array('1054', null, null), ['1054', null, null],
array('1166', null, null), ['1166', null, null],
array('1611', null, null), ['1611', null, null],
), ],
self::EXCEPTION_NON_UNIQUE_FIELD_NAME => array( self::EXCEPTION_NON_UNIQUE_FIELD_NAME => [
array('1052', null, null), ['1052', null, null],
array('1060', null, null), ['1060', null, null],
array('1110', null, null), ['1110', null, null],
), ],
self::EXCEPTION_NOT_NULL_CONSTRAINT_VIOLATION => array( self::EXCEPTION_NOT_NULL_CONSTRAINT_VIOLATION => [
array('1048', null, null), ['1048', null, null],
array('1121', null, null), ['1121', null, null],
array('1138', null, null), ['1138', null, null],
array('1171', null, null), ['1171', null, null],
array('1252', null, null), ['1252', null, null],
array('1263', null, null), ['1263', null, null],
array('1364', null, null), ['1364', null, null],
array('1566', null, null), ['1566', null, null],
), ],
self::EXCEPTION_SYNTAX_ERROR => array( self::EXCEPTION_SYNTAX_ERROR => [
array('1064', null, null), ['1064', null, null],
array('1149', null, null), ['1149', null, null],
array('1287', null, null), ['1287', null, null],
array('1341', null, null), ['1341', null, null],
array('1342', null, null), ['1342', null, null],
array('1343', null, null), ['1343', null, null],
array('1344', null, null), ['1344', null, null],
array('1382', null, null), ['1382', null, null],
array('1479', null, null), ['1479', null, null],
array('1541', null, null), ['1541', null, null],
array('1554', null, null), ['1554', null, null],
array('1626', null, null), ['1626', null, null],
), ],
self::EXCEPTION_TABLE_EXISTS => array( self::EXCEPTION_TABLE_EXISTS => [
array('1050', null, null), ['1050', null, null],
), ],
self::EXCEPTION_TABLE_NOT_FOUND => array( self::EXCEPTION_TABLE_NOT_FOUND => [
array('1051', null, null), ['1051', null, null],
array('1146', null, null), ['1146', null, null],
), ],
self::EXCEPTION_UNIQUE_CONSTRAINT_VIOLATION => array( self::EXCEPTION_UNIQUE_CONSTRAINT_VIOLATION => [
array('1062', null, null), ['1062', null, null],
array('1557', null, null), ['1557', null, null],
array('1569', null, null), ['1569', null, null],
array('1586', null, null), ['1586', null, null],
), ],
self::EXCEPTION_DEADLOCK => array( self::EXCEPTION_DEADLOCK => [
array('1213', null, null), ['1213', null, null],
), ],
self::EXCEPTION_LOCK_WAIT_TIMEOUT => array( self::EXCEPTION_LOCK_WAIT_TIMEOUT => [
array('1205', null, null), ['1205', null, null],
), ],
); ];
} }
} }
...@@ -9,6 +9,7 @@ class EasyConnectStringTest extends TestCase ...@@ -9,6 +9,7 @@ class EasyConnectStringTest extends TestCase
{ {
/** /**
* @param mixed[] $params * @param mixed[] $params
*
* @dataProvider connectionParametersProvider * @dataProvider connectionParametersProvider
*/ */
public function testFromConnectionParameters(array $params, string $expected) : void public function testFromConnectionParameters(array $params, string $expected) : void
......
...@@ -10,11 +10,11 @@ class AbstractOracleDriverTest extends AbstractDriverTest ...@@ -10,11 +10,11 @@ class AbstractOracleDriverTest extends AbstractDriverTest
{ {
public function testReturnsDatabaseName() public function testReturnsDatabaseName()
{ {
$params = array( $params = [
'user' => 'foo', 'user' => 'foo',
'password' => 'bar', 'password' => 'bar',
'dbname' => 'baz', 'dbname' => 'baz',
); ];
$connection = $this->getConnectionMock(); $connection = $this->getConnectionMock();
...@@ -27,13 +27,13 @@ class AbstractOracleDriverTest extends AbstractDriverTest ...@@ -27,13 +27,13 @@ class AbstractOracleDriverTest extends AbstractDriverTest
public function testReturnsDatabaseNameWithConnectDescriptor() public function testReturnsDatabaseNameWithConnectDescriptor()
{ {
$params = array( $params = [
'user' => 'foo', 'user' => 'foo',
'password' => 'bar', 'password' => 'bar',
'connectionstring' => '(DESCRIPTION=' . 'connectionstring' => '(DESCRIPTION=' .
'(ADDRESS=(PROTOCOL=TCP)(HOST=localhost)(PORT=1521))' . '(ADDRESS=(PROTOCOL=TCP)(HOST=localhost)(PORT=1521))' .
'(CONNECT_DATA=(SERVICE_NAME=baz)))' '(CONNECT_DATA=(SERVICE_NAME=baz)))',
); ];
$connection = $this->getConnectionMock(); $connection = $this->getConnectionMock();
...@@ -61,38 +61,38 @@ class AbstractOracleDriverTest extends AbstractDriverTest ...@@ -61,38 +61,38 @@ class AbstractOracleDriverTest extends AbstractDriverTest
protected function getExceptionConversionData() protected function getExceptionConversionData()
{ {
return array( return [
self::EXCEPTION_CONNECTION => array( self::EXCEPTION_CONNECTION => [
array('1017', null, null), ['1017', null, null],
array('12545', null, null), ['12545', null, null],
), ],
self::EXCEPTION_FOREIGN_KEY_CONSTRAINT_VIOLATION => array( self::EXCEPTION_FOREIGN_KEY_CONSTRAINT_VIOLATION => [
array('2292', null, null), ['2292', null, null],
), ],
self::EXCEPTION_INVALID_FIELD_NAME => array( self::EXCEPTION_INVALID_FIELD_NAME => [
array('904', null, null), ['904', null, null],
), ],
self::EXCEPTION_NON_UNIQUE_FIELD_NAME => array( self::EXCEPTION_NON_UNIQUE_FIELD_NAME => [
array('918', null, null), ['918', null, null],
array('960', null, null), ['960', null, null],
), ],
self::EXCEPTION_NOT_NULL_CONSTRAINT_VIOLATION => array( self::EXCEPTION_NOT_NULL_CONSTRAINT_VIOLATION => [
array('1400', null, null), ['1400', null, null],
), ],
self::EXCEPTION_SYNTAX_ERROR => array( self::EXCEPTION_SYNTAX_ERROR => [
array('923', null, null), ['923', null, null],
), ],
self::EXCEPTION_TABLE_EXISTS => array( self::EXCEPTION_TABLE_EXISTS => [
array('955', null, null), ['955', null, null],
), ],
self::EXCEPTION_TABLE_NOT_FOUND => array( self::EXCEPTION_TABLE_NOT_FOUND => [
array('942', null, null), ['942', null, null],
), ],
self::EXCEPTION_UNIQUE_CONSTRAINT_VIOLATION => array( self::EXCEPTION_UNIQUE_CONSTRAINT_VIOLATION => [
array('1', null, null), ['1', null, null],
array('2299', null, null), ['2299', null, null],
array('38911', null, null), ['38911', null, null],
), ],
); ];
} }
} }
...@@ -14,10 +14,10 @@ class AbstractPostgreSQLDriverTest extends AbstractDriverTest ...@@ -14,10 +14,10 @@ class AbstractPostgreSQLDriverTest extends AbstractDriverTest
parent::testReturnsDatabaseName(); parent::testReturnsDatabaseName();
$database = 'bloo'; $database = 'bloo';
$params = array( $params = [
'user' => 'foo', 'user' => 'foo',
'password' => 'bar', 'password' => 'bar',
); ];
$statement = $this->createMock('Doctrine\Tests\Mocks\DriverResultStatementMock'); $statement = $this->createMock('Doctrine\Tests\Mocks\DriverResultStatementMock');
...@@ -55,57 +55,57 @@ class AbstractPostgreSQLDriverTest extends AbstractDriverTest ...@@ -55,57 +55,57 @@ class AbstractPostgreSQLDriverTest extends AbstractDriverTest
protected function getDatabasePlatformsForVersions() protected function getDatabasePlatformsForVersions()
{ {
return array( return [
array('9.0.9', 'Doctrine\DBAL\Platforms\PostgreSqlPlatform'), ['9.0.9', 'Doctrine\DBAL\Platforms\PostgreSqlPlatform'],
array('9.1', 'Doctrine\DBAL\Platforms\PostgreSQL91Platform'), ['9.1', 'Doctrine\DBAL\Platforms\PostgreSQL91Platform'],
array('9.1.0', 'Doctrine\DBAL\Platforms\PostgreSQL91Platform'), ['9.1.0', 'Doctrine\DBAL\Platforms\PostgreSQL91Platform'],
array('9.1.1', 'Doctrine\DBAL\Platforms\PostgreSQL91Platform'), ['9.1.1', 'Doctrine\DBAL\Platforms\PostgreSQL91Platform'],
array('9.1.9', 'Doctrine\DBAL\Platforms\PostgreSQL91Platform'), ['9.1.9', 'Doctrine\DBAL\Platforms\PostgreSQL91Platform'],
array('9.2', 'Doctrine\DBAL\Platforms\PostgreSQL92Platform'), ['9.2', 'Doctrine\DBAL\Platforms\PostgreSQL92Platform'],
array('9.2.0', 'Doctrine\DBAL\Platforms\PostgreSQL92Platform'), ['9.2.0', 'Doctrine\DBAL\Platforms\PostgreSQL92Platform'],
array('9.2.1', 'Doctrine\DBAL\Platforms\PostgreSQL92Platform'), ['9.2.1', 'Doctrine\DBAL\Platforms\PostgreSQL92Platform'],
array('9.3.6', 'Doctrine\DBAL\Platforms\PostgreSQL92Platform'), ['9.3.6', 'Doctrine\DBAL\Platforms\PostgreSQL92Platform'],
array('9.4', 'Doctrine\DBAL\Platforms\PostgreSQL94Platform'), ['9.4', 'Doctrine\DBAL\Platforms\PostgreSQL94Platform'],
array('9.4.0', 'Doctrine\DBAL\Platforms\PostgreSQL94Platform'), ['9.4.0', 'Doctrine\DBAL\Platforms\PostgreSQL94Platform'],
array('9.4.1', 'Doctrine\DBAL\Platforms\PostgreSQL94Platform'), ['9.4.1', 'Doctrine\DBAL\Platforms\PostgreSQL94Platform'],
array('10', PostgreSQL100Platform::class), ['10', PostgreSQL100Platform::class],
); ];
} }
protected function getExceptionConversionData() protected function getExceptionConversionData()
{ {
return array( return [
self::EXCEPTION_CONNECTION => array( self::EXCEPTION_CONNECTION => [
array(null, '7', 'SQLSTATE[08006]'), [null, '7', 'SQLSTATE[08006]'],
), ],
self::EXCEPTION_FOREIGN_KEY_CONSTRAINT_VIOLATION => array( self::EXCEPTION_FOREIGN_KEY_CONSTRAINT_VIOLATION => [
array(null, '23503', null), [null, '23503', null],
), ],
self::EXCEPTION_INVALID_FIELD_NAME => array( self::EXCEPTION_INVALID_FIELD_NAME => [
array(null, '42703', null), [null, '42703', null],
), ],
self::EXCEPTION_NON_UNIQUE_FIELD_NAME => array( self::EXCEPTION_NON_UNIQUE_FIELD_NAME => [
array(null, '42702', null), [null, '42702', null],
), ],
self::EXCEPTION_NOT_NULL_CONSTRAINT_VIOLATION => array( self::EXCEPTION_NOT_NULL_CONSTRAINT_VIOLATION => [
array(null, '23502', null), [null, '23502', null],
), ],
self::EXCEPTION_SYNTAX_ERROR => array( self::EXCEPTION_SYNTAX_ERROR => [
array(null, '42601', null), [null, '42601', null],
), ],
self::EXCEPTION_TABLE_EXISTS => array( self::EXCEPTION_TABLE_EXISTS => [
array(null, '42P07', null), [null, '42P07', null],
), ],
self::EXCEPTION_TABLE_NOT_FOUND => array( self::EXCEPTION_TABLE_NOT_FOUND => [
array(null, '42P01', null), [null, '42P01', null],
), ],
self::EXCEPTION_UNIQUE_CONSTRAINT_VIOLATION => array( self::EXCEPTION_UNIQUE_CONSTRAINT_VIOLATION => [
array(null, '23505', null), [null, '23505', null],
), ],
self::EXCEPTION_DEADLOCK => array( self::EXCEPTION_DEADLOCK => [
array(null, '40001', null), [null, '40001', null],
array(null, '40P01', null), [null, '40P01', null],
), ],
); ];
} }
} }
...@@ -25,84 +25,84 @@ class AbstractSQLAnywhereDriverTest extends AbstractDriverTest ...@@ -25,84 +25,84 @@ class AbstractSQLAnywhereDriverTest extends AbstractDriverTest
protected function getDatabasePlatformsForVersions() protected function getDatabasePlatformsForVersions()
{ {
return array( return [
array('10', 'Doctrine\DBAL\Platforms\SQLAnywherePlatform'), ['10', 'Doctrine\DBAL\Platforms\SQLAnywherePlatform'],
array('10.0', 'Doctrine\DBAL\Platforms\SQLAnywherePlatform'), ['10.0', 'Doctrine\DBAL\Platforms\SQLAnywherePlatform'],
array('10.0.0', 'Doctrine\DBAL\Platforms\SQLAnywherePlatform'), ['10.0.0', 'Doctrine\DBAL\Platforms\SQLAnywherePlatform'],
array('10.0.0.0', 'Doctrine\DBAL\Platforms\SQLAnywherePlatform'), ['10.0.0.0', 'Doctrine\DBAL\Platforms\SQLAnywherePlatform'],
array('10.1.2.3', 'Doctrine\DBAL\Platforms\SQLAnywherePlatform'), ['10.1.2.3', 'Doctrine\DBAL\Platforms\SQLAnywherePlatform'],
array('10.9.9.9', 'Doctrine\DBAL\Platforms\SQLAnywherePlatform'), ['10.9.9.9', 'Doctrine\DBAL\Platforms\SQLAnywherePlatform'],
array('11', 'Doctrine\DBAL\Platforms\SQLAnywhere11Platform'), ['11', 'Doctrine\DBAL\Platforms\SQLAnywhere11Platform'],
array('11.0', 'Doctrine\DBAL\Platforms\SQLAnywhere11Platform'), ['11.0', 'Doctrine\DBAL\Platforms\SQLAnywhere11Platform'],
array('11.0.0', 'Doctrine\DBAL\Platforms\SQLAnywhere11Platform'), ['11.0.0', 'Doctrine\DBAL\Platforms\SQLAnywhere11Platform'],
array('11.0.0.0', 'Doctrine\DBAL\Platforms\SQLAnywhere11Platform'), ['11.0.0.0', 'Doctrine\DBAL\Platforms\SQLAnywhere11Platform'],
array('11.1.2.3', 'Doctrine\DBAL\Platforms\SQLAnywhere11Platform'), ['11.1.2.3', 'Doctrine\DBAL\Platforms\SQLAnywhere11Platform'],
array('11.9.9.9', 'Doctrine\DBAL\Platforms\SQLAnywhere11Platform'), ['11.9.9.9', 'Doctrine\DBAL\Platforms\SQLAnywhere11Platform'],
array('12', 'Doctrine\DBAL\Platforms\SQLAnywhere12Platform'), ['12', 'Doctrine\DBAL\Platforms\SQLAnywhere12Platform'],
array('12.0', 'Doctrine\DBAL\Platforms\SQLAnywhere12Platform'), ['12.0', 'Doctrine\DBAL\Platforms\SQLAnywhere12Platform'],
array('12.0.0', 'Doctrine\DBAL\Platforms\SQLAnywhere12Platform'), ['12.0.0', 'Doctrine\DBAL\Platforms\SQLAnywhere12Platform'],
array('12.0.0.0', 'Doctrine\DBAL\Platforms\SQLAnywhere12Platform'), ['12.0.0.0', 'Doctrine\DBAL\Platforms\SQLAnywhere12Platform'],
array('12.1.2.3', 'Doctrine\DBAL\Platforms\SQLAnywhere12Platform'), ['12.1.2.3', 'Doctrine\DBAL\Platforms\SQLAnywhere12Platform'],
array('12.9.9.9', 'Doctrine\DBAL\Platforms\SQLAnywhere12Platform'), ['12.9.9.9', 'Doctrine\DBAL\Platforms\SQLAnywhere12Platform'],
array('13', 'Doctrine\DBAL\Platforms\SQLAnywhere12Platform'), ['13', 'Doctrine\DBAL\Platforms\SQLAnywhere12Platform'],
array('14', 'Doctrine\DBAL\Platforms\SQLAnywhere12Platform'), ['14', 'Doctrine\DBAL\Platforms\SQLAnywhere12Platform'],
array('15', 'Doctrine\DBAL\Platforms\SQLAnywhere12Platform'), ['15', 'Doctrine\DBAL\Platforms\SQLAnywhere12Platform'],
array('15.9.9.9', 'Doctrine\DBAL\Platforms\SQLAnywhere12Platform'), ['15.9.9.9', 'Doctrine\DBAL\Platforms\SQLAnywhere12Platform'],
array('16', 'Doctrine\DBAL\Platforms\SQLAnywhere16Platform'), ['16', 'Doctrine\DBAL\Platforms\SQLAnywhere16Platform'],
array('16.0', 'Doctrine\DBAL\Platforms\SQLAnywhere16Platform'), ['16.0', 'Doctrine\DBAL\Platforms\SQLAnywhere16Platform'],
array('16.0.0', 'Doctrine\DBAL\Platforms\SQLAnywhere16Platform'), ['16.0.0', 'Doctrine\DBAL\Platforms\SQLAnywhere16Platform'],
array('16.0.0.0', 'Doctrine\DBAL\Platforms\SQLAnywhere16Platform'), ['16.0.0.0', 'Doctrine\DBAL\Platforms\SQLAnywhere16Platform'],
array('16.1.2.3', 'Doctrine\DBAL\Platforms\SQLAnywhere16Platform'), ['16.1.2.3', 'Doctrine\DBAL\Platforms\SQLAnywhere16Platform'],
array('16.9.9.9', 'Doctrine\DBAL\Platforms\SQLAnywhere16Platform'), ['16.9.9.9', 'Doctrine\DBAL\Platforms\SQLAnywhere16Platform'],
array('17', 'Doctrine\DBAL\Platforms\SQLAnywhere16Platform'), ['17', 'Doctrine\DBAL\Platforms\SQLAnywhere16Platform'],
); ];
} }
protected function getExceptionConversionData() protected function getExceptionConversionData()
{ {
return array( return [
self::EXCEPTION_CONNECTION => array( self::EXCEPTION_CONNECTION => [
array('-100', null, null), ['-100', null, null],
array('-103', null, null), ['-103', null, null],
array('-832', null, null), ['-832', null, null],
), ],
self::EXCEPTION_FOREIGN_KEY_CONSTRAINT_VIOLATION => array( self::EXCEPTION_FOREIGN_KEY_CONSTRAINT_VIOLATION => [
array('-198', null, null), ['-198', null, null],
), ],
self::EXCEPTION_INVALID_FIELD_NAME => array( self::EXCEPTION_INVALID_FIELD_NAME => [
array('-143', null, null), ['-143', null, null],
), ],
self::EXCEPTION_NON_UNIQUE_FIELD_NAME => array( self::EXCEPTION_NON_UNIQUE_FIELD_NAME => [
array('-144', null, null), ['-144', null, null],
), ],
self::EXCEPTION_NOT_NULL_CONSTRAINT_VIOLATION => array( self::EXCEPTION_NOT_NULL_CONSTRAINT_VIOLATION => [
array('-184', null, null), ['-184', null, null],
array('-195', null, null), ['-195', null, null],
), ],
self::EXCEPTION_SYNTAX_ERROR => array( self::EXCEPTION_SYNTAX_ERROR => [
array('-131', null, null), ['-131', null, null],
), ],
self::EXCEPTION_TABLE_EXISTS => array( self::EXCEPTION_TABLE_EXISTS => [
array('-110', null, null), ['-110', null, null],
), ],
self::EXCEPTION_TABLE_NOT_FOUND => array( self::EXCEPTION_TABLE_NOT_FOUND => [
array('-141', null, null), ['-141', null, null],
array('-1041', null, null), ['-1041', null, null],
), ],
self::EXCEPTION_UNIQUE_CONSTRAINT_VIOLATION => array( self::EXCEPTION_UNIQUE_CONSTRAINT_VIOLATION => [
array('-193', null, null), ['-193', null, null],
array('-196', null, null), ['-196', null, null],
), ],
self::EXCEPTION_DEADLOCK => array( self::EXCEPTION_DEADLOCK => [
array('-306', null, null), ['-306', null, null],
array('-307', null, null), ['-307', null, null],
array('-684', null, null), ['-684', null, null],
), ],
self::EXCEPTION_LOCK_WAIT_TIMEOUT => array( self::EXCEPTION_LOCK_WAIT_TIMEOUT => [
array('-210', null, null), ['-210', null, null],
array('-1175', null, null), ['-1175', null, null],
array('-1281', null, null), ['-1281', null, null],
), ],
); ];
} }
} }
...@@ -25,33 +25,33 @@ class AbstractSQLServerDriverTest extends AbstractDriverTest ...@@ -25,33 +25,33 @@ class AbstractSQLServerDriverTest extends AbstractDriverTest
protected function getDatabasePlatformsForVersions() protected function getDatabasePlatformsForVersions()
{ {
return array( return [
array('9', 'Doctrine\DBAL\Platforms\SQLServerPlatform'), ['9', 'Doctrine\DBAL\Platforms\SQLServerPlatform'],
array('9.00', 'Doctrine\DBAL\Platforms\SQLServerPlatform'), ['9.00', 'Doctrine\DBAL\Platforms\SQLServerPlatform'],
array('9.00.0', 'Doctrine\DBAL\Platforms\SQLServerPlatform'), ['9.00.0', 'Doctrine\DBAL\Platforms\SQLServerPlatform'],
array('9.00.1398', 'Doctrine\DBAL\Platforms\SQLServerPlatform'), ['9.00.1398', 'Doctrine\DBAL\Platforms\SQLServerPlatform'],
array('9.00.1398.99', 'Doctrine\DBAL\Platforms\SQLServerPlatform'), ['9.00.1398.99', 'Doctrine\DBAL\Platforms\SQLServerPlatform'],
array('9.00.1399', 'Doctrine\DBAL\Platforms\SQLServer2005Platform'), ['9.00.1399', 'Doctrine\DBAL\Platforms\SQLServer2005Platform'],
array('9.00.1399.0', 'Doctrine\DBAL\Platforms\SQLServer2005Platform'), ['9.00.1399.0', 'Doctrine\DBAL\Platforms\SQLServer2005Platform'],
array('9.00.1399.99', 'Doctrine\DBAL\Platforms\SQLServer2005Platform'), ['9.00.1399.99', 'Doctrine\DBAL\Platforms\SQLServer2005Platform'],
array('9.00.1400', 'Doctrine\DBAL\Platforms\SQLServer2005Platform'), ['9.00.1400', 'Doctrine\DBAL\Platforms\SQLServer2005Platform'],
array('9.10', 'Doctrine\DBAL\Platforms\SQLServer2005Platform'), ['9.10', 'Doctrine\DBAL\Platforms\SQLServer2005Platform'],
array('9.10.9999', 'Doctrine\DBAL\Platforms\SQLServer2005Platform'), ['9.10.9999', 'Doctrine\DBAL\Platforms\SQLServer2005Platform'],
array('10.00.1599', 'Doctrine\DBAL\Platforms\SQLServer2005Platform'), ['10.00.1599', 'Doctrine\DBAL\Platforms\SQLServer2005Platform'],
array('10.00.1599.99', 'Doctrine\DBAL\Platforms\SQLServer2005Platform'), ['10.00.1599.99', 'Doctrine\DBAL\Platforms\SQLServer2005Platform'],
array('10.00.1600', 'Doctrine\DBAL\Platforms\SQLServer2008Platform'), ['10.00.1600', 'Doctrine\DBAL\Platforms\SQLServer2008Platform'],
array('10.00.1600.0', 'Doctrine\DBAL\Platforms\SQLServer2008Platform'), ['10.00.1600.0', 'Doctrine\DBAL\Platforms\SQLServer2008Platform'],
array('10.00.1600.99', 'Doctrine\DBAL\Platforms\SQLServer2008Platform'), ['10.00.1600.99', 'Doctrine\DBAL\Platforms\SQLServer2008Platform'],
array('10.00.1601', 'Doctrine\DBAL\Platforms\SQLServer2008Platform'), ['10.00.1601', 'Doctrine\DBAL\Platforms\SQLServer2008Platform'],
array('10.10', 'Doctrine\DBAL\Platforms\SQLServer2008Platform'), ['10.10', 'Doctrine\DBAL\Platforms\SQLServer2008Platform'],
array('10.10.9999', 'Doctrine\DBAL\Platforms\SQLServer2008Platform'), ['10.10.9999', 'Doctrine\DBAL\Platforms\SQLServer2008Platform'],
array('11.00.2099', 'Doctrine\DBAL\Platforms\SQLServer2008Platform'), ['11.00.2099', 'Doctrine\DBAL\Platforms\SQLServer2008Platform'],
array('11.00.2099.99', 'Doctrine\DBAL\Platforms\SQLServer2008Platform'), ['11.00.2099.99', 'Doctrine\DBAL\Platforms\SQLServer2008Platform'],
array('11.00.2100', 'Doctrine\DBAL\Platforms\SQLServer2012Platform'), ['11.00.2100', 'Doctrine\DBAL\Platforms\SQLServer2012Platform'],
array('11.00.2100.0', 'Doctrine\DBAL\Platforms\SQLServer2012Platform'), ['11.00.2100.0', 'Doctrine\DBAL\Platforms\SQLServer2012Platform'],
array('11.00.2100.99', 'Doctrine\DBAL\Platforms\SQLServer2012Platform'), ['11.00.2100.99', 'Doctrine\DBAL\Platforms\SQLServer2012Platform'],
array('11.00.2101', 'Doctrine\DBAL\Platforms\SQLServer2012Platform'), ['11.00.2101', 'Doctrine\DBAL\Platforms\SQLServer2012Platform'],
array('12', 'Doctrine\DBAL\Platforms\SQLServer2012Platform'), ['12', 'Doctrine\DBAL\Platforms\SQLServer2012Platform'],
); ];
} }
} }
...@@ -10,12 +10,12 @@ class AbstractSQLiteDriverTest extends AbstractDriverTest ...@@ -10,12 +10,12 @@ class AbstractSQLiteDriverTest extends AbstractDriverTest
{ {
public function testReturnsDatabaseName() public function testReturnsDatabaseName()
{ {
$params = array( $params = [
'user' => 'foo', 'user' => 'foo',
'password' => 'bar', 'password' => 'bar',
'dbname' => 'baz', 'dbname' => 'baz',
'path' => 'bloo', 'path' => 'bloo',
); ];
$connection = $this->getConnectionMock(); $connection = $this->getConnectionMock();
...@@ -43,39 +43,39 @@ class AbstractSQLiteDriverTest extends AbstractDriverTest ...@@ -43,39 +43,39 @@ class AbstractSQLiteDriverTest extends AbstractDriverTest
protected function getExceptionConversionData() protected function getExceptionConversionData()
{ {
return array( return [
self::EXCEPTION_CONNECTION => array( self::EXCEPTION_CONNECTION => [
array(null, null, 'unable to open database file'), [null, null, 'unable to open database file'],
), ],
self::EXCEPTION_INVALID_FIELD_NAME => array( self::EXCEPTION_INVALID_FIELD_NAME => [
array(null, null, 'has no column named'), [null, null, 'has no column named'],
), ],
self::EXCEPTION_NON_UNIQUE_FIELD_NAME => array( self::EXCEPTION_NON_UNIQUE_FIELD_NAME => [
array(null, null, 'ambiguous column name'), [null, null, 'ambiguous column name'],
), ],
self::EXCEPTION_NOT_NULL_CONSTRAINT_VIOLATION => array( self::EXCEPTION_NOT_NULL_CONSTRAINT_VIOLATION => [
array(null, null, 'may not be NULL'), [null, null, 'may not be NULL'],
), ],
self::EXCEPTION_READ_ONLY => array( self::EXCEPTION_READ_ONLY => [
array(null, null, 'attempt to write a readonly database'), [null, null, 'attempt to write a readonly database'],
), ],
self::EXCEPTION_SYNTAX_ERROR => array( self::EXCEPTION_SYNTAX_ERROR => [
array(null, null, 'syntax error'), [null, null, 'syntax error'],
), ],
self::EXCEPTION_TABLE_EXISTS => array( self::EXCEPTION_TABLE_EXISTS => [
array(null, null, 'already exists'), [null, null, 'already exists'],
), ],
self::EXCEPTION_TABLE_NOT_FOUND => array( self::EXCEPTION_TABLE_NOT_FOUND => [
array(null, null, 'no such table:'), [null, null, 'no such table:'],
), ],
self::EXCEPTION_UNIQUE_CONSTRAINT_VIOLATION => array( self::EXCEPTION_UNIQUE_CONSTRAINT_VIOLATION => [
array(null, null, 'must be unique'), [null, null, 'must be unique'],
array(null, null, 'is not unique'), [null, null, 'is not unique'],
array(null, null, 'are not unique'), [null, null, 'are not unique'],
), ],
self::EXCEPTION_LOCK_WAIT_TIMEOUT => array( self::EXCEPTION_LOCK_WAIT_TIMEOUT => [
array(null, null, 'database is locked'), [null, null, 'database is locked'],
), ],
); ];
} }
} }
...@@ -2,7 +2,9 @@ ...@@ -2,7 +2,9 @@
namespace Doctrine\Tests\DBAL\Driver\IBMDB2; namespace Doctrine\Tests\DBAL\Driver\IBMDB2;
use Doctrine\DBAL\Driver\IBMDB2\DB2Connection;
use Doctrine\Tests\DbalTestCase; use Doctrine\Tests\DbalTestCase;
use PHPUnit_Framework_MockObject_MockObject;
use function extension_loaded; use function extension_loaded;
class DB2ConnectionTest extends DbalTestCase class DB2ConnectionTest extends DbalTestCase
...@@ -10,13 +12,13 @@ class DB2ConnectionTest extends DbalTestCase ...@@ -10,13 +12,13 @@ class DB2ConnectionTest extends DbalTestCase
/** /**
* The ibm_db2 driver connection mock under test. * The ibm_db2 driver connection mock under test.
* *
* @var \Doctrine\DBAL\Driver\IBMDB2\DB2Connection|\PHPUnit_Framework_MockObject_MockObject * @var DB2Connection|PHPUnit_Framework_MockObject_MockObject
*/ */
private $connectionMock; private $connectionMock;
protected function setUp() protected function setUp()
{ {
if ( ! extension_loaded('ibm_db2')) { if (! extension_loaded('ibm_db2')) {
$this->markTestSkipped('ibm_db2 is not installed.'); $this->markTestSkipped('ibm_db2 is not installed.');
} }
......
...@@ -6,6 +6,7 @@ use Doctrine\DBAL\Driver\Mysqli\MysqliConnection; ...@@ -6,6 +6,7 @@ use Doctrine\DBAL\Driver\Mysqli\MysqliConnection;
use Doctrine\DBAL\Driver\Mysqli\MysqliException; use Doctrine\DBAL\Driver\Mysqli\MysqliException;
use Doctrine\DBAL\Platforms\MySqlPlatform; use Doctrine\DBAL\Platforms\MySqlPlatform;
use Doctrine\Tests\DbalFunctionalTestCase; use Doctrine\Tests\DbalFunctionalTestCase;
use PHPUnit_Framework_MockObject_MockObject;
use function extension_loaded; use function extension_loaded;
use function restore_error_handler; use function restore_error_handler;
use function set_error_handler; use function set_error_handler;
...@@ -15,13 +16,13 @@ class MysqliConnectionTest extends DbalFunctionalTestCase ...@@ -15,13 +16,13 @@ class MysqliConnectionTest extends DbalFunctionalTestCase
/** /**
* The mysqli driver connection mock under test. * The mysqli driver connection mock under test.
* *
* @var \Doctrine\DBAL\Driver\Mysqli\MysqliConnection|\PHPUnit_Framework_MockObject_MockObject * @var MysqliConnection|PHPUnit_Framework_MockObject_MockObject
*/ */
private $connectionMock; private $connectionMock;
protected function setUp() protected function setUp()
{ {
if ( ! extension_loaded('mysqli')) { if (! extension_loaded('mysqli')) {
$this->markTestSkipped('mysqli is not installed.'); $this->markTestSkipped('mysqli is not installed.');
} }
...@@ -43,7 +44,9 @@ class MysqliConnectionTest extends DbalFunctionalTestCase ...@@ -43,7 +44,9 @@ class MysqliConnectionTest extends DbalFunctionalTestCase
public function testRestoresErrorHandlerOnException() public function testRestoresErrorHandlerOnException()
{ {
$handler = function () { self::fail('Never expected this to be called'); }; $handler = static function () {
self::fail('Never expected this to be called');
};
$default_handler = set_error_handler($handler); $default_handler = set_error_handler($handler);
try { try {
......
...@@ -2,7 +2,9 @@ ...@@ -2,7 +2,9 @@
namespace Doctrine\Tests\DBAL\Driver\OCI8; namespace Doctrine\Tests\DBAL\Driver\OCI8;
use Doctrine\DBAL\Driver\OCI8\OCI8Connection;
use Doctrine\Tests\DbalTestCase; use Doctrine\Tests\DbalTestCase;
use PHPUnit_Framework_MockObject_MockObject;
use function extension_loaded; use function extension_loaded;
class OCI8ConnectionTest extends DbalTestCase class OCI8ConnectionTest extends DbalTestCase
...@@ -10,13 +12,13 @@ class OCI8ConnectionTest extends DbalTestCase ...@@ -10,13 +12,13 @@ class OCI8ConnectionTest extends DbalTestCase
/** /**
* The oci8 driver connection mock under test. * The oci8 driver connection mock under test.
* *
* @var \Doctrine\DBAL\Driver\OCI8\OCI8Connection|\PHPUnit_Framework_MockObject_MockObject * @var OCI8Connection|PHPUnit_Framework_MockObject_MockObject
*/ */
private $connectionMock; private $connectionMock;
protected function setUp() protected function setUp()
{ {
if ( ! extension_loaded('oci8')) { if (! extension_loaded('oci8')) {
$this->markTestSkipped('oci8 is not installed.'); $this->markTestSkipped('oci8 is not installed.');
} }
......
...@@ -5,13 +5,14 @@ namespace Doctrine\Tests\DBAL\Driver\OCI8; ...@@ -5,13 +5,14 @@ namespace Doctrine\Tests\DBAL\Driver\OCI8;
use Doctrine\DBAL\Driver\OCI8\OCI8Exception; use Doctrine\DBAL\Driver\OCI8\OCI8Exception;
use Doctrine\DBAL\Driver\OCI8\OCI8Statement; use Doctrine\DBAL\Driver\OCI8\OCI8Statement;
use Doctrine\Tests\DbalTestCase; use Doctrine\Tests\DbalTestCase;
use ReflectionProperty;
use function extension_loaded; use function extension_loaded;
class OCI8StatementTest extends DbalTestCase class OCI8StatementTest extends DbalTestCase
{ {
protected function setUp() protected function setUp()
{ {
if (!extension_loaded('oci8')) { if (! extension_loaded('oci8')) {
$this->markTestSkipped('oci8 is not installed.'); $this->markTestSkipped('oci8 is not installed.');
} }
...@@ -33,7 +34,7 @@ class OCI8StatementTest extends DbalTestCase ...@@ -33,7 +34,7 @@ class OCI8StatementTest extends DbalTestCase
public function testExecute(array $params) public function testExecute(array $params)
{ {
$statement = $this->getMockBuilder('\Doctrine\DBAL\Driver\OCI8\OCI8Statement') $statement = $this->getMockBuilder('\Doctrine\DBAL\Driver\OCI8\OCI8Statement')
->setMethods(array('bindValue', 'errorInfo')) ->setMethods(['bindValue', 'errorInfo'])
->disableOriginalConstructor() ->disableOriginalConstructor()
->getMock(); ->getMock();
...@@ -54,18 +55,18 @@ class OCI8StatementTest extends DbalTestCase ...@@ -54,18 +55,18 @@ class OCI8StatementTest extends DbalTestCase
->with( ->with(
$this->equalTo(3), $this->equalTo(3),
$this->equalTo($params[2]) $this->equalTo($params[2])
); );
// can't pass to constructor since we don't have a real database handle, // can't pass to constructor since we don't have a real database handle,
// but execute must check the connection for the executeMode // but execute must check the connection for the executeMode
$conn = $this->getMockBuilder('\Doctrine\DBAL\Driver\OCI8\OCI8Connection') $conn = $this->getMockBuilder('\Doctrine\DBAL\Driver\OCI8\OCI8Connection')
->setMethods(array('getExecuteMode')) ->setMethods(['getExecuteMode'])
->disableOriginalConstructor() ->disableOriginalConstructor()
->getMock(); ->getMock();
$conn->expects($this->once()) $conn->expects($this->once())
->method('getExecuteMode'); ->method('getExecuteMode');
$reflProperty = new \ReflectionProperty($statement, '_conn'); $reflProperty = new ReflectionProperty($statement, '_conn');
$reflProperty->setAccessible(true); $reflProperty->setAccessible(true);
$reflProperty->setValue($statement, $conn); $reflProperty->setValue($statement, $conn);
...@@ -74,16 +75,16 @@ class OCI8StatementTest extends DbalTestCase ...@@ -74,16 +75,16 @@ class OCI8StatementTest extends DbalTestCase
public static function executeDataProvider() public static function executeDataProvider()
{ {
return array( return [
// $hasZeroIndex = isset($params[0]); == true // $hasZeroIndex = isset($params[0]); == true
array( [
array(0 => 'test', 1 => null, 2 => 'value') [0 => 'test', 1 => null, 2 => 'value'],
), ],
// $hasZeroIndex = isset($params[0]); == false // $hasZeroIndex = isset($params[0]); == false
array( [
array(0 => null, 1 => 'test', 2 => 'value') [0 => null, 1 => 'test', 2 => 'value'],
) ],
); ];
} }
/** /**
...@@ -98,19 +99,19 @@ class OCI8StatementTest extends DbalTestCase ...@@ -98,19 +99,19 @@ class OCI8StatementTest extends DbalTestCase
public static function nonTerminatedLiteralProvider() public static function nonTerminatedLiteralProvider()
{ {
return array( return [
'no-matching-quote' => array( 'no-matching-quote' => [
"SELECT 'literal FROM DUAL", "SELECT 'literal FROM DUAL",
'/offset 7/', '/offset 7/',
), ],
'no-matching-double-quote' => array( 'no-matching-double-quote' => [
'SELECT 1 "COL1 FROM DUAL', 'SELECT 1 "COL1 FROM DUAL',
'/offset 9/', '/offset 9/',
), ],
'incorrect-escaping-syntax' => array( 'incorrect-escaping-syntax' => [
"SELECT 'quoted \\'string' FROM DUAL", "SELECT 'quoted \\'string' FROM DUAL",
'/offset 23/', '/offset 23/',
), ],
); ];
} }
} }
...@@ -4,33 +4,34 @@ namespace Doctrine\Tests\DBAL\Driver; ...@@ -4,33 +4,34 @@ namespace Doctrine\Tests\DBAL\Driver;
use Doctrine\DBAL\Driver\PDOException; use Doctrine\DBAL\Driver\PDOException;
use Doctrine\Tests\DbalTestCase; use Doctrine\Tests\DbalTestCase;
use PHPUnit_Framework_MockObject_MockObject;
use function extension_loaded; use function extension_loaded;
class PDOExceptionTest extends DbalTestCase class PDOExceptionTest extends DbalTestCase
{ {
const ERROR_CODE = 666; public const ERROR_CODE = 666;
const MESSAGE = 'PDO Exception'; public const MESSAGE = 'PDO Exception';
const SQLSTATE = 28000; public const SQLSTATE = 28000;
/** /**
* The PDO exception wrapper under test. * The PDO exception wrapper under test.
* *
* @var \Doctrine\DBAL\Driver\PDOException * @var PDOException
*/ */
private $exception; private $exception;
/** /**
* The wrapped PDO exception mock. * The wrapped PDO exception mock.
* *
* @var \PDOException|\PHPUnit_Framework_MockObject_MockObject * @var \PDOException|PHPUnit_Framework_MockObject_MockObject
*/ */
private $wrappedException; private $wrappedException;
protected function setUp() protected function setUp()
{ {
if ( ! extension_loaded('PDO')) { if (! extension_loaded('PDO')) {
$this->markTestSkipped('PDO is not installed.'); $this->markTestSkipped('PDO is not installed.');
} }
...@@ -38,7 +39,7 @@ class PDOExceptionTest extends DbalTestCase ...@@ -38,7 +39,7 @@ class PDOExceptionTest extends DbalTestCase
$this->wrappedException = new \PDOException(self::MESSAGE, self::SQLSTATE); $this->wrappedException = new \PDOException(self::MESSAGE, self::SQLSTATE);
$this->wrappedException->errorInfo = array(self::SQLSTATE, self::ERROR_CODE); $this->wrappedException->errorInfo = [self::SQLSTATE, self::ERROR_CODE];
$this->exception = new PDOException($this->wrappedException); $this->exception = new PDOException($this->wrappedException);
} }
......
...@@ -6,6 +6,7 @@ use Doctrine\DBAL\Driver\PDOPgSql\Driver; ...@@ -6,6 +6,7 @@ use Doctrine\DBAL\Driver\PDOPgSql\Driver;
use Doctrine\Tests\DBAL\Driver\AbstractPostgreSQLDriverTest; use Doctrine\Tests\DBAL\Driver\AbstractPostgreSQLDriverTest;
use PDO; use PDO;
use PDOException; use PDOException;
use PHPUnit_Framework_SkippedTestError;
use function defined; use function defined;
class DriverTest extends AbstractPostgreSQLDriverTest class DriverTest extends AbstractPostgreSQLDriverTest
...@@ -23,10 +24,10 @@ class DriverTest extends AbstractPostgreSQLDriverTest ...@@ -23,10 +24,10 @@ class DriverTest extends AbstractPostgreSQLDriverTest
$this->skipWhenNotUsingPhp56AndPdoPgsql(); $this->skipWhenNotUsingPhp56AndPdoPgsql();
$connection = $this->createDriver()->connect( $connection = $this->createDriver()->connect(
array( [
'host' => $GLOBALS['db_host'], 'host' => $GLOBALS['db_host'],
'port' => $GLOBALS['db_port'] 'port' => $GLOBALS['db_port'],
), ],
$GLOBALS['db_username'], $GLOBALS['db_username'],
$GLOBALS['db_password'] $GLOBALS['db_password']
); );
...@@ -49,13 +50,13 @@ class DriverTest extends AbstractPostgreSQLDriverTest ...@@ -49,13 +50,13 @@ class DriverTest extends AbstractPostgreSQLDriverTest
$this->skipWhenNotUsingPhp56AndPdoPgsql(); $this->skipWhenNotUsingPhp56AndPdoPgsql();
$connection = $this->createDriver()->connect( $connection = $this->createDriver()->connect(
array( [
'host' => $GLOBALS['db_host'], 'host' => $GLOBALS['db_host'],
'port' => $GLOBALS['db_port'] 'port' => $GLOBALS['db_port'],
), ],
$GLOBALS['db_username'], $GLOBALS['db_username'],
$GLOBALS['db_password'], $GLOBALS['db_password'],
array(PDO::PGSQL_ATTR_DISABLE_PREPARES => false) [PDO::PGSQL_ATTR_DISABLE_PREPARES => false]
); );
self::assertInstanceOf('Doctrine\DBAL\Driver\PDOConnection', $connection); self::assertInstanceOf('Doctrine\DBAL\Driver\PDOConnection', $connection);
...@@ -76,13 +77,13 @@ class DriverTest extends AbstractPostgreSQLDriverTest ...@@ -76,13 +77,13 @@ class DriverTest extends AbstractPostgreSQLDriverTest
$this->skipWhenNotUsingPhp56AndPdoPgsql(); $this->skipWhenNotUsingPhp56AndPdoPgsql();
$connection = $this->createDriver()->connect( $connection = $this->createDriver()->connect(
array( [
'host' => $GLOBALS['db_host'], 'host' => $GLOBALS['db_host'],
'port' => $GLOBALS['db_port'] 'port' => $GLOBALS['db_port'],
), ],
$GLOBALS['db_username'], $GLOBALS['db_username'],
$GLOBALS['db_password'], $GLOBALS['db_password'],
array(PDO::PGSQL_ATTR_DISABLE_PREPARES => true) [PDO::PGSQL_ATTR_DISABLE_PREPARES => true]
); );
self::assertInstanceOf('Doctrine\DBAL\Driver\PDOConnection', $connection); self::assertInstanceOf('Doctrine\DBAL\Driver\PDOConnection', $connection);
...@@ -104,7 +105,7 @@ class DriverTest extends AbstractPostgreSQLDriverTest ...@@ -104,7 +105,7 @@ class DriverTest extends AbstractPostgreSQLDriverTest
} }
/** /**
* @throws \PHPUnit_Framework_SkippedTestError * @throws PHPUnit_Framework_SkippedTestError
*/ */
private function skipWhenNotUsingPhp56AndPdoPgsql() private function skipWhenNotUsingPhp56AndPdoPgsql()
{ {
...@@ -112,8 +113,10 @@ class DriverTest extends AbstractPostgreSQLDriverTest ...@@ -112,8 +113,10 @@ class DriverTest extends AbstractPostgreSQLDriverTest
$this->markTestSkipped('Test requires PHP 5.6+'); $this->markTestSkipped('Test requires PHP 5.6+');
} }
if (! (isset($GLOBALS['db_type']) && $GLOBALS['db_type'] === 'pdo_pgsql')) { if (isset($GLOBALS['db_type']) && $GLOBALS['db_type'] === 'pdo_pgsql') {
$this->markTestSkipped('Test enabled only when using pdo_pgsql specific phpunit.xml'); return;
} }
$this->markTestSkipped('Test enabled only when using pdo_pgsql specific phpunit.xml');
} }
} }
...@@ -2,7 +2,9 @@ ...@@ -2,7 +2,9 @@
namespace Doctrine\Tests\DBAL\Driver\SQLAnywhere; namespace Doctrine\Tests\DBAL\Driver\SQLAnywhere;
use Doctrine\DBAL\Driver\SQLAnywhere\SQLAnywhereConnection;
use Doctrine\Tests\DbalTestCase; use Doctrine\Tests\DbalTestCase;
use PHPUnit_Framework_MockObject_MockObject;
use function extension_loaded; use function extension_loaded;
class SQLAnywhereConnectionTest extends DbalTestCase class SQLAnywhereConnectionTest extends DbalTestCase
...@@ -10,13 +12,13 @@ class SQLAnywhereConnectionTest extends DbalTestCase ...@@ -10,13 +12,13 @@ class SQLAnywhereConnectionTest extends DbalTestCase
/** /**
* The sqlanywhere driver connection mock under test. * The sqlanywhere driver connection mock under test.
* *
* @var \Doctrine\DBAL\Driver\SQLAnywhere\SQLAnywhereConnection|\PHPUnit_Framework_MockObject_MockObject * @var SQLAnywhereConnection|PHPUnit_Framework_MockObject_MockObject
*/ */
private $connectionMock; private $connectionMock;
protected function setUp() protected function setUp()
{ {
if ( ! extension_loaded('sqlanywhere')) { if (! extension_loaded('sqlanywhere')) {
$this->markTestSkipped('sqlanywhere is not installed.'); $this->markTestSkipped('sqlanywhere is not installed.');
} }
......
...@@ -2,7 +2,9 @@ ...@@ -2,7 +2,9 @@
namespace Doctrine\Tests\DBAL\Driver\SQLSrv; namespace Doctrine\Tests\DBAL\Driver\SQLSrv;
use Doctrine\DBAL\Driver\SQLSrv\SQLSrvConnection;
use Doctrine\Tests\DbalTestCase; use Doctrine\Tests\DbalTestCase;
use PHPUnit_Framework_MockObject_MockObject;
use function extension_loaded; use function extension_loaded;
class SQLSrvConnectionTest extends DbalTestCase class SQLSrvConnectionTest extends DbalTestCase
...@@ -10,13 +12,13 @@ class SQLSrvConnectionTest extends DbalTestCase ...@@ -10,13 +12,13 @@ class SQLSrvConnectionTest extends DbalTestCase
/** /**
* The sqlsrv driver connection mock under test. * The sqlsrv driver connection mock under test.
* *
* @var \Doctrine\DBAL\Driver\SQLSrv\SQLSrvConnection|\PHPUnit_Framework_MockObject_MockObject * @var SQLSrvConnection|PHPUnit_Framework_MockObject_MockObject
*/ */
private $connectionMock; private $connectionMock;
protected function setUp() protected function setUp()
{ {
if ( ! extension_loaded('sqlsrv')) { if (! extension_loaded('sqlsrv')) {
$this->markTestSkipped('sqlsrv is not installed.'); $this->markTestSkipped('sqlsrv is not installed.');
} }
......
...@@ -10,12 +10,13 @@ use Doctrine\DBAL\Driver\SQLSrv\SQLSrvStatement; ...@@ -10,12 +10,13 @@ use Doctrine\DBAL\Driver\SQLSrv\SQLSrvStatement;
use Doctrine\DBAL\Driver\Statement; use Doctrine\DBAL\Driver\Statement;
use Doctrine\DBAL\Driver\StatementIterator; use Doctrine\DBAL\Driver\StatementIterator;
use Doctrine\DBAL\Portability\Statement as PortabilityStatement; use Doctrine\DBAL\Portability\Statement as PortabilityStatement;
use Doctrine\Tests\DbalTestCase;
use IteratorAggregate; use IteratorAggregate;
use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\MockObject\MockObject;
use Traversable; use Traversable;
use function extension_loaded; use function extension_loaded;
class StatementIteratorTest extends \Doctrine\Tests\DbalTestCase class StatementIteratorTest extends DbalTestCase
{ {
/** /**
* @dataProvider statementProvider() * @dataProvider statementProvider()
...@@ -58,11 +59,11 @@ class StatementIteratorTest extends \Doctrine\Tests\DbalTestCase ...@@ -58,11 +59,11 @@ class StatementIteratorTest extends \Doctrine\Tests\DbalTestCase
private function configureStatement(MockObject $stmt, int &$calls) : void private function configureStatement(MockObject $stmt, int &$calls) : void
{ {
$values = ['foo', '', 'bar', '0', 'baz', 0, 'qux', null, 'quz', false, 'impossible']; $values = ['foo', '', 'bar', '0', 'baz', 0, 'qux', null, 'quz', false, 'impossible'];
$calls = 0; $calls = 0;
$stmt->expects($this->exactly(10)) $stmt->expects($this->exactly(10))
->method('fetch') ->method('fetch')
->willReturnCallback(function() use ($values, &$calls) { ->willReturnCallback(static function () use ($values, &$calls) {
$value = $values[$calls]; $value = $values[$calls];
$calls++; $calls++;
......
...@@ -15,6 +15,7 @@ use Doctrine\Tests\DBAL\Mocks\MockPlatform; ...@@ -15,6 +15,7 @@ use Doctrine\Tests\DBAL\Mocks\MockPlatform;
use Doctrine\Tests\DbalTestCase; use Doctrine\Tests\DbalTestCase;
use Doctrine\Tests\Mocks\ConnectionMock; use Doctrine\Tests\Mocks\ConnectionMock;
use Doctrine\Tests\Mocks\DriverMock; use Doctrine\Tests\Mocks\DriverMock;
use PDO;
use stdClass; use stdClass;
use function extension_loaded; use function extension_loaded;
use function in_array; use function in_array;
...@@ -37,7 +38,7 @@ class DriverManagerTest extends DbalTestCase ...@@ -37,7 +38,7 @@ class DriverManagerTest extends DbalTestCase
public function testValidPdoInstance() public function testValidPdoInstance()
{ {
$conn = DriverManager::getConnection([ $conn = DriverManager::getConnection([
'pdo' => new \PDO('sqlite::memory:'), 'pdo' => new PDO('sqlite::memory:'),
]); ]);
self::assertEquals('sqlite', $conn->getDatabasePlatform()->getName()); self::assertEquals('sqlite', $conn->getDatabasePlatform()->getName());
...@@ -49,12 +50,12 @@ class DriverManagerTest extends DbalTestCase ...@@ -49,12 +50,12 @@ class DriverManagerTest extends DbalTestCase
*/ */
public function testPdoInstanceSetErrorMode() public function testPdoInstanceSetErrorMode()
{ {
$pdo = new \PDO('sqlite::memory:'); $pdo = new PDO('sqlite::memory:');
$pdo->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_SILENT); $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_SILENT);
$options = ['pdo' => $pdo]; $options = ['pdo' => $pdo];
DriverManager::getConnection($options); DriverManager::getConnection($options);
self::assertEquals(\PDO::ERRMODE_EXCEPTION, $pdo->getAttribute(\PDO::ATTR_ERRMODE)); self::assertEquals(PDO::ERRMODE_EXCEPTION, $pdo->getAttribute(PDO::ATTR_ERRMODE));
} }
/** /**
...@@ -80,7 +81,7 @@ class DriverManagerTest extends DbalTestCase ...@@ -80,7 +81,7 @@ class DriverManagerTest extends DbalTestCase
{ {
$mockPlatform = new MockPlatform(); $mockPlatform = new MockPlatform();
$options = [ $options = [
'pdo' => new \PDO('sqlite::memory:'), 'pdo' => new PDO('sqlite::memory:'),
'platform' => $mockPlatform, 'platform' => $mockPlatform,
]; ];
...@@ -96,7 +97,7 @@ class DriverManagerTest extends DbalTestCase ...@@ -96,7 +97,7 @@ class DriverManagerTest extends DbalTestCase
$wrapperClass = ConnectionMock::class; $wrapperClass = ConnectionMock::class;
$options = [ $options = [
'pdo' => new \PDO('sqlite::memory:'), 'pdo' => new PDO('sqlite::memory:'),
'wrapperClass' => $wrapperClass, 'wrapperClass' => $wrapperClass,
]; ];
...@@ -112,7 +113,7 @@ class DriverManagerTest extends DbalTestCase ...@@ -112,7 +113,7 @@ class DriverManagerTest extends DbalTestCase
$this->expectException(DBALException::class); $this->expectException(DBALException::class);
$options = [ $options = [
'pdo' => new \PDO('sqlite::memory:'), 'pdo' => new PDO('sqlite::memory:'),
'wrapperClass' => stdClass::class, 'wrapperClass' => stdClass::class,
]; ];
...@@ -216,7 +217,7 @@ class DriverManagerTest extends DbalTestCase ...@@ -216,7 +217,7 @@ class DriverManagerTest extends DbalTestCase
$this->markTestSkipped('PDO is not installed'); $this->markTestSkipped('PDO is not installed');
} }
$options['pdo'] = $this->createMock(\PDO::class); $options['pdo'] = $this->createMock(PDO::class);
} }
$options = is_array($url) ? $url : ['url' => $url]; $options = is_array($url) ? $url : ['url' => $url];
......
...@@ -14,11 +14,10 @@ class MysqlSessionInitTest extends DbalTestCase ...@@ -14,11 +14,10 @@ class MysqlSessionInitTest extends DbalTestCase
$connectionMock = $this->createMock('Doctrine\DBAL\Connection'); $connectionMock = $this->createMock('Doctrine\DBAL\Connection');
$connectionMock->expects($this->once()) $connectionMock->expects($this->once())
->method('executeUpdate') ->method('executeUpdate')
->with($this->equalTo("SET NAMES foo COLLATE bar")); ->with($this->equalTo('SET NAMES foo COLLATE bar'));
$eventArgs = new ConnectionEventArgs($connectionMock); $eventArgs = new ConnectionEventArgs($connectionMock);
$listener = new MysqlSessionInit('foo', 'bar'); $listener = new MysqlSessionInit('foo', 'bar');
$listener->postConnect($eventArgs); $listener->postConnect($eventArgs);
} }
...@@ -26,6 +25,6 @@ class MysqlSessionInitTest extends DbalTestCase ...@@ -26,6 +25,6 @@ class MysqlSessionInitTest extends DbalTestCase
public function testGetSubscribedEvents() public function testGetSubscribedEvents()
{ {
$listener = new MysqlSessionInit(); $listener = new MysqlSessionInit();
self::assertEquals(array(Events::postConnect), $listener->getSubscribedEvents()); self::assertEquals([Events::postConnect], $listener->getSubscribedEvents());
} }
} }
...@@ -19,14 +19,12 @@ class OracleSessionInitTest extends DbalTestCase ...@@ -19,14 +19,12 @@ class OracleSessionInitTest extends DbalTestCase
$eventArgs = new ConnectionEventArgs($connectionMock); $eventArgs = new ConnectionEventArgs($connectionMock);
$listener = new OracleSessionInit(); $listener = new OracleSessionInit();
$listener->postConnect($eventArgs); $listener->postConnect($eventArgs);
} }
/** /**
* @group DBAL-1824 * @group DBAL-1824
*
* @dataProvider getPostConnectWithSessionParameterValuesData * @dataProvider getPostConnectWithSessionParameterValuesData
*/ */
public function testPostConnectQuotesSessionParameterValues($name, $value) public function testPostConnectQuotesSessionParameterValues($name, $value)
...@@ -40,21 +38,20 @@ class OracleSessionInitTest extends DbalTestCase ...@@ -40,21 +38,20 @@ class OracleSessionInitTest extends DbalTestCase
$eventArgs = new ConnectionEventArgs($connectionMock); $eventArgs = new ConnectionEventArgs($connectionMock);
$listener = new OracleSessionInit([$name => $value]);
$listener = new OracleSessionInit(array($name => $value));
$listener->postConnect($eventArgs); $listener->postConnect($eventArgs);
} }
public function getPostConnectWithSessionParameterValuesData() public function getPostConnectWithSessionParameterValuesData()
{ {
return array( return [
array('CURRENT_SCHEMA', 'foo'), ['CURRENT_SCHEMA', 'foo'],
); ];
} }
public function testGetSubscribedEvents() public function testGetSubscribedEvents()
{ {
$listener = new OracleSessionInit(); $listener = new OracleSessionInit();
self::assertEquals(array(Events::postConnect), $listener->getSubscribedEvents()); self::assertEquals([Events::postConnect], $listener->getSubscribedEvents());
} }
} }
...@@ -28,6 +28,6 @@ class SQLSessionInitTest extends DbalTestCase ...@@ -28,6 +28,6 @@ class SQLSessionInitTest extends DbalTestCase
public function testGetSubscribedEvents() public function testGetSubscribedEvents()
{ {
$listener = new SQLSessionInit("SET SEARCH_PATH TO foo, public, TIMEZONE TO 'Europe/Berlin'"); $listener = new SQLSessionInit("SET SEARCH_PATH TO foo, public, TIMEZONE TO 'Europe/Berlin'");
self::assertEquals(array(Events::postConnect), $listener->getSubscribedEvents()); self::assertEquals([Events::postConnect], $listener->getSubscribedEvents());
} }
} }
...@@ -20,15 +20,14 @@ ...@@ -20,15 +20,14 @@
namespace Doctrine\Tests\DBAL\Exception; namespace Doctrine\Tests\DBAL\Exception;
use Doctrine\DBAL\Exception\InvalidArgumentException; use Doctrine\DBAL\Exception\InvalidArgumentException;
use PHPUnit\Framework\TestCase;
/** /**
* Tests for {@see \Doctrine\DBAL\Exception\InvalidArgumentException} * Tests for {@see \Doctrine\DBAL\Exception\InvalidArgumentException}
* *
* @covers \Doctrine\DBAL\Exception\InvalidArgumentException * @covers \Doctrine\DBAL\Exception\InvalidArgumentException
*
* @author Marco Pivetta <ocramius@gmail.com>
*/ */
class InvalidArgumentExceptionTest extends \PHPUnit\Framework\TestCase class InvalidArgumentExceptionTest extends TestCase
{ {
public function testFromEmptyCriteria() public function testFromEmptyCriteria()
{ {
......
...@@ -5,8 +5,10 @@ namespace Doctrine\Tests\DBAL\Functional; ...@@ -5,8 +5,10 @@ namespace Doctrine\Tests\DBAL\Functional;
use Doctrine\DBAL\Driver\PDOSqlsrv\Driver as PDOSQLSrvDriver; use Doctrine\DBAL\Driver\PDOSqlsrv\Driver as PDOSQLSrvDriver;
use Doctrine\DBAL\FetchMode; use Doctrine\DBAL\FetchMode;
use Doctrine\DBAL\ParameterType; use Doctrine\DBAL\ParameterType;
use Doctrine\DBAL\Schema\AbstractSchemaManager;
use Doctrine\DBAL\Schema\Table; use Doctrine\DBAL\Schema\Table;
use Doctrine\DBAL\Types\Type; use Doctrine\DBAL\Types\Type;
use Doctrine\Tests\DbalFunctionalTestCase;
use function fopen; use function fopen;
use function in_array; use function in_array;
use function str_repeat; use function str_repeat;
...@@ -15,7 +17,7 @@ use function stream_get_contents; ...@@ -15,7 +17,7 @@ use function stream_get_contents;
/** /**
* @group DBAL-6 * @group DBAL-6
*/ */
class BlobTest extends \Doctrine\Tests\DbalFunctionalTestCase class BlobTest extends DbalFunctionalTestCase
{ {
protected function setUp() protected function setUp()
{ {
...@@ -25,7 +27,7 @@ class BlobTest extends \Doctrine\Tests\DbalFunctionalTestCase ...@@ -25,7 +27,7 @@ class BlobTest extends \Doctrine\Tests\DbalFunctionalTestCase
$this->markTestSkipped('This test does not work on pdo_sqlsrv driver due to a bug. See: http://social.msdn.microsoft.com/Forums/sqlserver/en-US/5a755bdd-41e9-45cb-9166-c9da4475bb94/how-to-set-null-for-varbinarymax-using-bindvalue-using-pdosqlsrv?forum=sqldriverforphp'); $this->markTestSkipped('This test does not work on pdo_sqlsrv driver due to a bug. See: http://social.msdn.microsoft.com/Forums/sqlserver/en-US/5a755bdd-41e9-45cb-9166-c9da4475bb94/how-to-set-null-for-varbinarymax-using-bindvalue-using-pdosqlsrv?forum=sqldriverforphp');
} }
/* @var $sm \Doctrine\DBAL\Schema\AbstractSchemaManager */ /** @var AbstractSchemaManager $sm */
$table = new Table('blob_table'); $table = new Table('blob_table');
$table->addColumn('id', 'integer'); $table->addColumn('id', 'integer');
$table->addColumn('clobfield', 'text'); $table->addColumn('clobfield', 'text');
...@@ -100,9 +102,7 @@ class BlobTest extends \Doctrine\Tests\DbalFunctionalTestCase ...@@ -100,9 +102,7 @@ class BlobTest extends \Doctrine\Tests\DbalFunctionalTestCase
ParameterType::LARGE_OBJECT, ParameterType::LARGE_OBJECT,
]); ]);
$this->_conn->update('blob_table', [ $this->_conn->update('blob_table', ['blobfield' => 'test2'], ['id' => 1], [
'blobfield' => 'test2',
], ['id' => 1], [
ParameterType::LARGE_OBJECT, ParameterType::LARGE_OBJECT,
ParameterType::INTEGER, ParameterType::INTEGER,
]); ]);
......
...@@ -2,14 +2,20 @@ ...@@ -2,14 +2,20 @@
namespace Doctrine\Tests\DBAL\Functional; namespace Doctrine\Tests\DBAL\Functional;
use Doctrine\DBAL\Connection;
use Doctrine\DBAL\ConnectionException; use Doctrine\DBAL\ConnectionException;
use Doctrine\DBAL\DriverManager; use Doctrine\DBAL\DriverManager;
use Doctrine\DBAL\ParameterType; use Doctrine\DBAL\ParameterType;
use Doctrine\DBAL\Platforms\AbstractPlatform; use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Types\Type; use Doctrine\DBAL\Types\Type;
use Doctrine\Tests\DbalFunctionalTestCase;
use Error;
use Exception;
use RuntimeException;
use Throwable;
use function in_array; use function in_array;
class ConnectionTest extends \Doctrine\Tests\DbalFunctionalTestCase class ConnectionTest extends DbalFunctionalTestCase
{ {
protected function setUp() protected function setUp()
{ {
...@@ -46,9 +52,9 @@ class ConnectionTest extends \Doctrine\Tests\DbalFunctionalTestCase ...@@ -46,9 +52,9 @@ class ConnectionTest extends \Doctrine\Tests\DbalFunctionalTestCase
try { try {
$this->_conn->beginTransaction(); $this->_conn->beginTransaction();
self::assertEquals(2, $this->_conn->getTransactionNestingLevel()); self::assertEquals(2, $this->_conn->getTransactionNestingLevel());
throw new \Exception; throw new Exception();
$this->_conn->commit(); // never reached $this->_conn->commit(); // never reached
} catch (\Exception $e) { } catch (Throwable $e) {
$this->_conn->rollBack(); $this->_conn->rollBack();
self::assertEquals(1, $this->_conn->getTransactionNestingLevel()); self::assertEquals(1, $this->_conn->getTransactionNestingLevel());
//no rethrow //no rethrow
...@@ -82,9 +88,9 @@ class ConnectionTest extends \Doctrine\Tests\DbalFunctionalTestCase ...@@ -82,9 +88,9 @@ class ConnectionTest extends \Doctrine\Tests\DbalFunctionalTestCase
self::assertEquals(3, $this->_conn->getTransactionNestingLevel()); self::assertEquals(3, $this->_conn->getTransactionNestingLevel());
$this->_conn->commit(); $this->_conn->commit();
self::assertEquals(2, $this->_conn->getTransactionNestingLevel()); self::assertEquals(2, $this->_conn->getTransactionNestingLevel());
throw new \Exception; throw new Exception();
$this->_conn->commit(); // never reached $this->_conn->commit(); // never reached
} catch (\Exception $e) { } catch (Throwable $e) {
$this->_conn->rollBack(); $this->_conn->rollBack();
self::assertEquals(1, $this->_conn->getTransactionNestingLevel()); self::assertEquals(1, $this->_conn->getTransactionNestingLevel());
//no rethrow //no rethrow
...@@ -121,7 +127,7 @@ class ConnectionTest extends \Doctrine\Tests\DbalFunctionalTestCase ...@@ -121,7 +127,7 @@ class ConnectionTest extends \Doctrine\Tests\DbalFunctionalTestCase
} }
$this->expectException(ConnectionException::class); $this->expectException(ConnectionException::class);
$this->expectExceptionMessage("Savepoints are not supported by this driver."); $this->expectExceptionMessage('Savepoints are not supported by this driver.');
$this->_conn->setNestTransactionsWithSavepoints(true); $this->_conn->setNestTransactionsWithSavepoints(true);
} }
...@@ -133,7 +139,7 @@ class ConnectionTest extends \Doctrine\Tests\DbalFunctionalTestCase ...@@ -133,7 +139,7 @@ class ConnectionTest extends \Doctrine\Tests\DbalFunctionalTestCase
} }
$this->expectException(ConnectionException::class); $this->expectException(ConnectionException::class);
$this->expectExceptionMessage("Savepoints are not supported by this driver."); $this->expectExceptionMessage('Savepoints are not supported by this driver.');
$this->_conn->createSavepoint('foo'); $this->_conn->createSavepoint('foo');
} }
...@@ -145,7 +151,7 @@ class ConnectionTest extends \Doctrine\Tests\DbalFunctionalTestCase ...@@ -145,7 +151,7 @@ class ConnectionTest extends \Doctrine\Tests\DbalFunctionalTestCase
} }
$this->expectException(ConnectionException::class); $this->expectException(ConnectionException::class);
$this->expectExceptionMessage("Savepoints are not supported by this driver."); $this->expectExceptionMessage('Savepoints are not supported by this driver.');
$this->_conn->releaseSavepoint('foo'); $this->_conn->releaseSavepoint('foo');
} }
...@@ -157,7 +163,7 @@ class ConnectionTest extends \Doctrine\Tests\DbalFunctionalTestCase ...@@ -157,7 +163,7 @@ class ConnectionTest extends \Doctrine\Tests\DbalFunctionalTestCase
} }
$this->expectException(ConnectionException::class); $this->expectException(ConnectionException::class);
$this->expectExceptionMessage("Savepoints are not supported by this driver."); $this->expectExceptionMessage('Savepoints are not supported by this driver.');
$this->_conn->rollbackSavepoint('foo'); $this->_conn->rollbackSavepoint('foo');
} }
...@@ -168,10 +174,10 @@ class ConnectionTest extends \Doctrine\Tests\DbalFunctionalTestCase ...@@ -168,10 +174,10 @@ class ConnectionTest extends \Doctrine\Tests\DbalFunctionalTestCase
$this->_conn->beginTransaction(); $this->_conn->beginTransaction();
self::assertEquals(1, $this->_conn->getTransactionNestingLevel()); self::assertEquals(1, $this->_conn->getTransactionNestingLevel());
throw new \Exception; throw new Exception();
$this->_conn->commit(); // never reached $this->_conn->commit(); // never reached
} catch (\Exception $e) { } catch (Throwable $e) {
self::assertEquals(1, $this->_conn->getTransactionNestingLevel()); self::assertEquals(1, $this->_conn->getTransactionNestingLevel());
$this->_conn->rollBack(); $this->_conn->rollBack();
self::assertEquals(0, $this->_conn->getTransactionNestingLevel()); self::assertEquals(0, $this->_conn->getTransactionNestingLevel());
...@@ -184,7 +190,7 @@ class ConnectionTest extends \Doctrine\Tests\DbalFunctionalTestCase ...@@ -184,7 +190,7 @@ class ConnectionTest extends \Doctrine\Tests\DbalFunctionalTestCase
$this->_conn->beginTransaction(); $this->_conn->beginTransaction();
self::assertEquals(1, $this->_conn->getTransactionNestingLevel()); self::assertEquals(1, $this->_conn->getTransactionNestingLevel());
$this->_conn->commit(); $this->_conn->commit();
} catch (\Exception $e) { } catch (Throwable $e) {
$this->_conn->rollBack(); $this->_conn->rollBack();
self::assertEquals(0, $this->_conn->getTransactionNestingLevel()); self::assertEquals(0, $this->_conn->getTransactionNestingLevel());
} }
...@@ -195,13 +201,13 @@ class ConnectionTest extends \Doctrine\Tests\DbalFunctionalTestCase ...@@ -195,13 +201,13 @@ class ConnectionTest extends \Doctrine\Tests\DbalFunctionalTestCase
public function testTransactionalWithException() public function testTransactionalWithException()
{ {
try { try {
$this->_conn->transactional(function($conn) { $this->_conn->transactional(static function($conn) {
/* @var $conn \Doctrine\DBAL\Connection */ /** @var Connection $conn */
$conn->executeQuery($conn->getDatabasePlatform()->getDummySelectSQL()); $conn->executeQuery($conn->getDatabasePlatform()->getDummySelectSQL());
throw new \RuntimeException("Ooops!"); throw new RuntimeException('Ooops!');
}); });
$this->fail('Expected exception'); $this->fail('Expected exception');
} catch (\RuntimeException $expected) { } catch (RuntimeException $expected) {
self::assertEquals(0, $this->_conn->getTransactionNestingLevel()); self::assertEquals(0, $this->_conn->getTransactionNestingLevel());
} }
} }
...@@ -209,21 +215,21 @@ class ConnectionTest extends \Doctrine\Tests\DbalFunctionalTestCase ...@@ -209,21 +215,21 @@ class ConnectionTest extends \Doctrine\Tests\DbalFunctionalTestCase
public function testTransactionalWithThrowable() public function testTransactionalWithThrowable()
{ {
try { try {
$this->_conn->transactional(function($conn) { $this->_conn->transactional(static function($conn) {
/* @var $conn \Doctrine\DBAL\Connection */ /** @var Connection $conn */
$conn->executeQuery($conn->getDatabasePlatform()->getDummySelectSQL()); $conn->executeQuery($conn->getDatabasePlatform()->getDummySelectSQL());
throw new \Error("Ooops!"); throw new Error('Ooops!');
}); });
$this->fail('Expected exception'); $this->fail('Expected exception');
} catch (\Error $expected) { } catch (Error $expected) {
self::assertEquals(0, $this->_conn->getTransactionNestingLevel()); self::assertEquals(0, $this->_conn->getTransactionNestingLevel());
} }
} }
public function testTransactional() public function testTransactional()
{ {
$res = $this->_conn->transactional(function($conn) { $res = $this->_conn->transactional(static function($conn) {
/* @var $conn \Doctrine\DBAL\Connection */ /** @var Connection $conn */
$conn->executeQuery($conn->getDatabasePlatform()->getDummySelectSQL()); $conn->executeQuery($conn->getDatabasePlatform()->getDummySelectSQL());
}); });
...@@ -232,7 +238,7 @@ class ConnectionTest extends \Doctrine\Tests\DbalFunctionalTestCase ...@@ -232,7 +238,7 @@ class ConnectionTest extends \Doctrine\Tests\DbalFunctionalTestCase
public function testTransactionalReturnValue() public function testTransactionalReturnValue()
{ {
$res = $this->_conn->transactional(function() { $res = $this->_conn->transactional(static function() {
return 42; return 42;
}); });
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
namespace Doctrine\Tests\DBAL\Functional\Driver; namespace Doctrine\Tests\DBAL\Functional\Driver;
use Doctrine\DBAL\Connection; use Doctrine\DBAL\Connection;
use Doctrine\DBAL\Driver;
use Doctrine\Tests\DbalFunctionalTestCase; use Doctrine\Tests\DbalFunctionalTestCase;
abstract class AbstractDriverTest extends DbalFunctionalTestCase abstract class AbstractDriverTest extends DbalFunctionalTestCase
...@@ -10,7 +11,7 @@ abstract class AbstractDriverTest extends DbalFunctionalTestCase ...@@ -10,7 +11,7 @@ abstract class AbstractDriverTest extends DbalFunctionalTestCase
/** /**
* The driver instance under test. * The driver instance under test.
* *
* @var \Doctrine\DBAL\Driver * @var Driver
*/ */
protected $driver; protected $driver;
...@@ -29,7 +30,7 @@ abstract class AbstractDriverTest extends DbalFunctionalTestCase ...@@ -29,7 +30,7 @@ abstract class AbstractDriverTest extends DbalFunctionalTestCase
$params = $this->_conn->getParams(); $params = $this->_conn->getParams();
unset($params['dbname']); unset($params['dbname']);
$user = $params['user'] ?? null; $user = $params['user'] ?? null;
$password = $params['password'] ?? null; $password = $params['password'] ?? null;
$connection = $this->driver->connect($params, $user, $password); $connection = $this->driver->connect($params, $user, $password);
...@@ -59,7 +60,7 @@ abstract class AbstractDriverTest extends DbalFunctionalTestCase ...@@ -59,7 +60,7 @@ abstract class AbstractDriverTest extends DbalFunctionalTestCase
} }
/** /**
* @return \Doctrine\DBAL\Driver * @return Driver
*/ */
abstract protected function createDriver(); abstract protected function createDriver();
......
...@@ -16,9 +16,11 @@ class DB2DriverTest extends AbstractDriverTest ...@@ -16,9 +16,11 @@ class DB2DriverTest extends AbstractDriverTest
parent::setUp(); parent::setUp();
if (! $this->_conn->getDriver() instanceof DB2Driver) { if ($this->_conn->getDriver() instanceof DB2Driver) {
$this->markTestSkipped('ibm_db2 only test.'); return;
} }
$this->markTestSkipped('ibm_db2 only test.');
} }
/** /**
......
...@@ -13,15 +13,17 @@ class DB2StatementTest extends DbalFunctionalTestCase ...@@ -13,15 +13,17 @@ class DB2StatementTest extends DbalFunctionalTestCase
{ {
protected function setUp() protected function setUp()
{ {
if ( ! extension_loaded('ibm_db2')) { if (! extension_loaded('ibm_db2')) {
$this->markTestSkipped('ibm_db2 is not installed.'); $this->markTestSkipped('ibm_db2 is not installed.');
} }
parent::setUp(); parent::setUp();
if ( ! $this->_conn->getDriver() instanceof DB2Driver) { if ($this->_conn->getDriver() instanceof DB2Driver) {
$this->markTestSkipped('ibm_db2 only test.'); return;
} }
$this->markTestSkipped('ibm_db2 only test.');
} }
public function testExecutionErrorsAreNotSuppressed() public function testExecutionErrorsAreNotSuppressed()
......
<?php <?php
namespace Doctrine\Tests\DBAL\Functional\Driver\Mysqli; namespace Doctrine\Tests\DBAL\Functional\Driver\Mysqli;
use Doctrine\DBAL\Driver\Mysqli\Driver;
use Doctrine\DBAL\Driver\Mysqli\MysqliConnection;
use Doctrine\Tests\DbalFunctionalTestCase;
use const MYSQLI_OPT_CONNECT_TIMEOUT;
use function extension_loaded; use function extension_loaded;
class ConnectionTest extends \Doctrine\Tests\DbalFunctionalTestCase class ConnectionTest extends DbalFunctionalTestCase
{ {
protected function setUp() protected function setUp()
{ {
if (!extension_loaded('mysqli')) { if (! extension_loaded('mysqli')) {
$this->markTestSkipped('mysqli is not installed.'); $this->markTestSkipped('mysqli is not installed.');
} }
parent::setUp(); parent::setUp();
if ( !($this->_conn->getDriver() instanceof \Doctrine\DBAL\Driver\Mysqli\Driver)) { if ($this->_conn->getDriver() instanceof Driver) {
$this->markTestSkipped('MySQLi only test.'); return;
} }
$this->markTestSkipped('MySQLi only test.');
} }
protected function tearDown() protected function tearDown()
...@@ -24,12 +32,10 @@ class ConnectionTest extends \Doctrine\Tests\DbalFunctionalTestCase ...@@ -24,12 +32,10 @@ class ConnectionTest extends \Doctrine\Tests\DbalFunctionalTestCase
public function testDriverOptions() public function testDriverOptions()
{ {
$driverOptions = array( $driverOptions = [MYSQLI_OPT_CONNECT_TIMEOUT => 1];
\MYSQLI_OPT_CONNECT_TIMEOUT => 1,
);
$connection = $this->getConnection($driverOptions); $connection = $this->getConnection($driverOptions);
self::assertInstanceOf("\Doctrine\DBAL\Driver\Mysqli\MysqliConnection", $connection); self::assertInstanceOf('\Doctrine\DBAL\Driver\Mysqli\MysqliConnection', $connection);
} }
/** /**
...@@ -37,22 +43,22 @@ class ConnectionTest extends \Doctrine\Tests\DbalFunctionalTestCase ...@@ -37,22 +43,22 @@ class ConnectionTest extends \Doctrine\Tests\DbalFunctionalTestCase
*/ */
public function testUnsupportedDriverOption() public function testUnsupportedDriverOption()
{ {
$this->getConnection(array('hello' => 'world')); // use local infile $this->getConnection(['hello' => 'world']); // use local infile
} }
public function testPing() public function testPing()
{ {
$conn = $this->getConnection(array()); $conn = $this->getConnection([]);
self::assertTrue($conn->ping()); self::assertTrue($conn->ping());
} }
private function getConnection(array $driverOptions) private function getConnection(array $driverOptions)
{ {
return new \Doctrine\DBAL\Driver\Mysqli\MysqliConnection( return new MysqliConnection(
array( [
'host' => $GLOBALS['db_host'], 'host' => $GLOBALS['db_host'],
'dbname' => $GLOBALS['db_name'], 'dbname' => $GLOBALS['db_name'],
), ],
$GLOBALS['db_username'], $GLOBALS['db_username'],
$GLOBALS['db_password'], $GLOBALS['db_password'],
$driverOptions $driverOptions
......
...@@ -16,9 +16,11 @@ class DriverTest extends AbstractDriverTest ...@@ -16,9 +16,11 @@ class DriverTest extends AbstractDriverTest
parent::setUp(); parent::setUp();
if (! $this->_conn->getDriver() instanceof Driver) { if ($this->_conn->getDriver() instanceof Driver) {
$this->markTestSkipped('MySQLi only test.'); return;
} }
$this->markTestSkipped('MySQLi only test.');
} }
/** /**
......
...@@ -16,9 +16,11 @@ class DriverTest extends AbstractDriverTest ...@@ -16,9 +16,11 @@ class DriverTest extends AbstractDriverTest
parent::setUp(); parent::setUp();
if (! $this->_conn->getDriver() instanceof Driver) { if ($this->_conn->getDriver() instanceof Driver) {
$this->markTestSkipped('oci8 only test.'); return;
} }
$this->markTestSkipped('oci8 only test.');
} }
/** /**
......
...@@ -3,15 +3,14 @@ ...@@ -3,15 +3,14 @@
namespace Doctrine\Tests\DBAL\Functional\Driver\OCI8; namespace Doctrine\Tests\DBAL\Functional\Driver\OCI8;
use Doctrine\DBAL\Driver\OCI8\Driver; use Doctrine\DBAL\Driver\OCI8\Driver;
use Doctrine\DBAL\Driver\OCI8\OCI8Connection;
use Doctrine\DBAL\Schema\Table; use Doctrine\DBAL\Schema\Table;
use Doctrine\Tests\DbalFunctionalTestCase; use Doctrine\Tests\DbalFunctionalTestCase;
use function extension_loaded; use function extension_loaded;
class OCI8ConnectionTest extends DbalFunctionalTestCase class OCI8ConnectionTest extends DbalFunctionalTestCase
{ {
/** /** @var OCI8Connection */
* @var \Doctrine\DBAL\Driver\OCI8\OCI8Connection
*/
protected $driverConnection; protected $driverConnection;
protected function setUp() protected function setUp()
...@@ -34,18 +33,18 @@ class OCI8ConnectionTest extends DbalFunctionalTestCase ...@@ -34,18 +33,18 @@ class OCI8ConnectionTest extends DbalFunctionalTestCase
*/ */
public function testLastInsertIdAcceptsFqn() public function testLastInsertIdAcceptsFqn()
{ {
$platform = $this->_conn->getDatabasePlatform(); $platform = $this->_conn->getDatabasePlatform();
$schemaManager = $this->_conn->getSchemaManager(); $schemaManager = $this->_conn->getSchemaManager();
$table = new Table('DBAL2595'); $table = new Table('DBAL2595');
$table->addColumn('id', 'integer', array('autoincrement' => true)); $table->addColumn('id', 'integer', ['autoincrement' => true]);
$table->addColumn('foo', 'integer'); $table->addColumn('foo', 'integer');
$schemaManager->dropAndCreateTable($table); $schemaManager->dropAndCreateTable($table);
$this->_conn->executeUpdate('INSERT INTO DBAL2595 (foo) VALUES (1)'); $this->_conn->executeUpdate('INSERT INTO DBAL2595 (foo) VALUES (1)');
$schema = $this->_conn->getDatabase(); $schema = $this->_conn->getDatabase();
$sequence = $platform->getIdentitySequenceName($schema . '.DBAL2595', 'id'); $sequence = $platform->getIdentitySequenceName($schema . '.DBAL2595', 'id');
self::assertSame(1, $this->driverConnection->lastInsertId($sequence)); self::assertSame(1, $this->driverConnection->lastInsertId($sequence));
......
...@@ -16,9 +16,11 @@ class StatementTest extends DbalFunctionalTestCase ...@@ -16,9 +16,11 @@ class StatementTest extends DbalFunctionalTestCase
parent::setUp(); parent::setUp();
if (! $this->_conn->getDriver() instanceof Driver) { if ($this->_conn->getDriver() instanceof Driver) {
$this->markTestSkipped('oci8 only test.'); return;
} }
$this->markTestSkipped('oci8 only test.');
} }
/** /**
...@@ -34,53 +36,47 @@ class StatementTest extends DbalFunctionalTestCase ...@@ -34,53 +36,47 @@ class StatementTest extends DbalFunctionalTestCase
public static function queryConversionProvider() public static function queryConversionProvider()
{ {
return array( return [
'simple' => array( 'simple' => [
'SELECT ? COL1 FROM DUAL', 'SELECT ? COL1 FROM DUAL',
array(1), [1],
array( ['COL1' => 1],
'COL1' => 1, ],
), 'literal-with-placeholder' => [
),
'literal-with-placeholder' => array(
"SELECT '?' COL1, ? COL2 FROM DUAL", "SELECT '?' COL1, ? COL2 FROM DUAL",
array(2), [2],
array( [
'COL1' => '?', 'COL1' => '?',
'COL2' => 2, 'COL2' => 2,
), ],
), ],
'literal-with-quotes' => array( 'literal-with-quotes' => [
"SELECT ? COL1, '?\"?''?' \"COL?\" FROM DUAL", "SELECT ? COL1, '?\"?''?' \"COL?\" FROM DUAL",
array(3), [3],
array( [
'COL1' => 3, 'COL1' => 3,
'COL?' => '?"?\'?', 'COL?' => '?"?\'?',
), ],
), ],
'placeholder-at-the-end' => array( 'placeholder-at-the-end' => [
'SELECT ? COL1 FROM DUAL WHERE 1 = ?', 'SELECT ? COL1 FROM DUAL WHERE 1 = ?',
array(4, 1), [4, 1],
array( ['COL1' => 4],
'COL1' => 4, ],
), 'multi-line-literal' => [
),
'multi-line-literal' => array(
"SELECT 'Hello, "SELECT 'Hello,
World?!' COL1 FROM DUAL WHERE 1 = ?", World?!' COL1 FROM DUAL WHERE 1 = ?",
array(1), [1],
array( [
'COL1' => 'Hello, 'COL1' => 'Hello,
World?!', World?!',
), ],
), ],
'empty-literal' => array( 'empty-literal' => [
"SELECT '' COL1 FROM DUAL", "SELECT '' COL1 FROM DUAL",
array(), [],
array( ['COL1' => ''],
'COL1' => '', ],
), ];
),
);
} }
} }
...@@ -4,6 +4,7 @@ namespace Doctrine\Tests\DBAL\Functional\Driver; ...@@ -4,6 +4,7 @@ namespace Doctrine\Tests\DBAL\Functional\Driver;
use Doctrine\DBAL\Driver\PDOConnection; use Doctrine\DBAL\Driver\PDOConnection;
use Doctrine\Tests\DbalFunctionalTestCase; use Doctrine\Tests\DbalFunctionalTestCase;
use PDO;
use function extension_loaded; use function extension_loaded;
use function sprintf; use function sprintf;
...@@ -12,13 +13,13 @@ class PDOConnectionTest extends DbalFunctionalTestCase ...@@ -12,13 +13,13 @@ class PDOConnectionTest extends DbalFunctionalTestCase
/** /**
* The PDO driver connection under test. * The PDO driver connection under test.
* *
* @var \Doctrine\DBAL\Driver\PDOConnection * @var PDOConnection
*/ */
protected $driverConnection; protected $driverConnection;
protected function setUp() protected function setUp()
{ {
if ( ! extension_loaded('PDO')) { if (! extension_loaded('PDO')) {
$this->markTestSkipped('PDO is not installed.'); $this->markTestSkipped('PDO is not installed.');
} }
...@@ -26,9 +27,11 @@ class PDOConnectionTest extends DbalFunctionalTestCase ...@@ -26,9 +27,11 @@ class PDOConnectionTest extends DbalFunctionalTestCase
$this->driverConnection = $this->_conn->getWrappedConnection(); $this->driverConnection = $this->_conn->getWrappedConnection();
if ( ! $this->driverConnection instanceof PDOConnection) { if ($this->driverConnection instanceof PDOConnection) {
$this->markTestSkipped('PDO connection only test.'); return;
} }
$this->markTestSkipped('PDO connection only test.');
} }
protected function tearDown() protected function tearDown()
...@@ -53,7 +56,6 @@ class PDOConnectionTest extends DbalFunctionalTestCase ...@@ -53,7 +56,6 @@ class PDOConnectionTest extends DbalFunctionalTestCase
/** /**
* @group DBAL-1022 * @group DBAL-1022
*
* @expectedException \Doctrine\DBAL\Driver\PDOException * @expectedException \Doctrine\DBAL\Driver\PDOException
*/ */
public function testThrowsWrappedExceptionOnExec() public function testThrowsWrappedExceptionOnExec()
...@@ -72,7 +74,7 @@ class PDOConnectionTest extends DbalFunctionalTestCase ...@@ -72,7 +74,7 @@ class PDOConnectionTest extends DbalFunctionalTestCase
// Emulated prepared statements have to be disabled for this test // Emulated prepared statements have to be disabled for this test
// so that PDO actually communicates with the database server to check the query. // so that PDO actually communicates with the database server to check the query.
$this->driverConnection->setAttribute(\PDO::ATTR_EMULATE_PREPARES, false); $this->driverConnection->setAttribute(PDO::ATTR_EMULATE_PREPARES, false);
$this->driverConnection->prepare('foo'); $this->driverConnection->prepare('foo');
......
...@@ -16,9 +16,11 @@ class DriverTest extends AbstractDriverTest ...@@ -16,9 +16,11 @@ class DriverTest extends AbstractDriverTest
parent::setUp(); parent::setUp();
if (! $this->_conn->getDriver() instanceof Driver) { if ($this->_conn->getDriver() instanceof Driver) {
$this->markTestSkipped('pdo_mysql only test.'); return;
} }
$this->markTestSkipped('pdo_mysql only test.');
} }
/** /**
......
...@@ -16,9 +16,11 @@ class DriverTest extends AbstractDriverTest ...@@ -16,9 +16,11 @@ class DriverTest extends AbstractDriverTest
parent::setUp(); parent::setUp();
if (! $this->_conn->getDriver() instanceof Driver) { if ($this->_conn->getDriver() instanceof Driver) {
$this->markTestSkipped('PDO_OCI only test.'); return;
} }
$this->markTestSkipped('PDO_OCI only test.');
} }
/** /**
......
...@@ -21,9 +21,11 @@ class DriverTest extends AbstractDriverTest ...@@ -21,9 +21,11 @@ class DriverTest extends AbstractDriverTest
parent::setUp(); parent::setUp();
if (! $this->_conn->getDriver() instanceof Driver) { if ($this->_conn->getDriver() instanceof Driver) {
$this->markTestSkipped('pdo_pgsql only test.'); return;
} }
$this->markTestSkipped('pdo_pgsql only test.');
} }
/** /**
...@@ -31,8 +33,8 @@ class DriverTest extends AbstractDriverTest ...@@ -31,8 +33,8 @@ class DriverTest extends AbstractDriverTest
*/ */
public function testDatabaseParameters($databaseName, $defaultDatabaseName, $expectedDatabaseName) public function testDatabaseParameters($databaseName, $defaultDatabaseName, $expectedDatabaseName)
{ {
$params = $this->_conn->getParams(); $params = $this->_conn->getParams();
$params['dbname'] = $databaseName; $params['dbname'] = $databaseName;
$params['default_dbname'] = $defaultDatabaseName; $params['default_dbname'] = $defaultDatabaseName;
$connection = new Connection( $connection = new Connection(
...@@ -50,17 +52,17 @@ class DriverTest extends AbstractDriverTest ...@@ -50,17 +52,17 @@ class DriverTest extends AbstractDriverTest
public function getDatabaseParameter() public function getDatabaseParameter()
{ {
$params = TestUtil::getConnection()->getParams(); $params = TestUtil::getConnection()->getParams();
$realDatabaseName = $params['dbname'] ?? ''; $realDatabaseName = $params['dbname'] ?? '';
$dummyDatabaseName = $realDatabaseName . 'a'; $dummyDatabaseName = $realDatabaseName . 'a';
return array( return [
// dbname, default_dbname, expected // dbname, default_dbname, expected
array($realDatabaseName, null, $realDatabaseName), [$realDatabaseName, null, $realDatabaseName],
array($realDatabaseName, $dummyDatabaseName, $realDatabaseName), [$realDatabaseName, $dummyDatabaseName, $realDatabaseName],
array(null, $realDatabaseName, $realDatabaseName), [null, $realDatabaseName, $realDatabaseName],
array(null, null, $this->getDatabaseNameForConnectionWithoutDatabaseNameParameter()), [null, null, $this->getDatabaseNameForConnectionWithoutDatabaseNameParameter()],
); ];
} }
/** /**
...@@ -68,18 +70,18 @@ class DriverTest extends AbstractDriverTest ...@@ -68,18 +70,18 @@ class DriverTest extends AbstractDriverTest
*/ */
public function testConnectsWithApplicationNameParameter() public function testConnectsWithApplicationNameParameter()
{ {
$parameters = $this->_conn->getParams(); $parameters = $this->_conn->getParams();
$parameters['application_name'] = 'doctrine'; $parameters['application_name'] = 'doctrine';
$user = $parameters['user'] ?? null; $user = $parameters['user'] ?? null;
$password = $parameters['password'] ?? null; $password = $parameters['password'] ?? null;
$connection = $this->driver->connect($parameters, $user, $password); $connection = $this->driver->connect($parameters, $user, $password);
$hash = microtime(true); // required to identify the record in the results uniquely $hash = microtime(true); // required to identify the record in the results uniquely
$sql = sprintf('SELECT * FROM pg_stat_activity WHERE %d = %d', $hash, $hash); $sql = sprintf('SELECT * FROM pg_stat_activity WHERE %d = %d', $hash, $hash);
$statement = $connection->query($sql); $statement = $connection->query($sql);
$records = $statement->fetchAll(); $records = $statement->fetchAll();
foreach ($records as $record) { foreach ($records as $record) {
// The query column is named "current_query" on PostgreSQL < 9.2 // The query column is named "current_query" on PostgreSQL < 9.2
......
...@@ -12,28 +12,29 @@ class PDOPgsqlConnectionTest extends DbalFunctionalTestCase ...@@ -12,28 +12,29 @@ class PDOPgsqlConnectionTest extends DbalFunctionalTestCase
{ {
protected function setUp() protected function setUp()
{ {
if ( ! extension_loaded('pdo_pgsql')) { if (! extension_loaded('pdo_pgsql')) {
$this->markTestSkipped('pdo_pgsql is not loaded.'); $this->markTestSkipped('pdo_pgsql is not loaded.');
} }
parent::setUp(); parent::setUp();
if ( ! $this->_conn->getDatabasePlatform() instanceof PostgreSqlPlatform) { if ($this->_conn->getDatabasePlatform() instanceof PostgreSqlPlatform) {
$this->markTestSkipped('PDOPgsql only test.'); return;
} }
$this->markTestSkipped('PDOPgsql only test.');
} }
/** /**
* @param string $charset
*
* @group DBAL-1183 * @group DBAL-1183
* @group DBAL-1189 * @group DBAL-1189
*
* @dataProvider getValidCharsets * @dataProvider getValidCharsets
*
* @param string $charset
*/ */
public function testConnectsWithValidCharsetOption($charset) public function testConnectsWithValidCharsetOption($charset)
{ {
$params = $this->_conn->getParams(); $params = $this->_conn->getParams();
$params['charset'] = $charset; $params['charset'] = $charset;
$connection = DriverManager::getConnection( $connection = DriverManager::getConnection(
...@@ -54,9 +55,9 @@ class PDOPgsqlConnectionTest extends DbalFunctionalTestCase ...@@ -54,9 +55,9 @@ class PDOPgsqlConnectionTest extends DbalFunctionalTestCase
*/ */
public function getValidCharsets() public function getValidCharsets()
{ {
return array( return [
array("UTF8"), ['UTF8'],
array("LATIN1") ['LATIN1'],
); ];
} }
} }
...@@ -16,9 +16,11 @@ class DriverTest extends AbstractDriverTest ...@@ -16,9 +16,11 @@ class DriverTest extends AbstractDriverTest
parent::setUp(); parent::setUp();
if (! $this->_conn->getDriver() instanceof Driver) { if ($this->_conn->getDriver() instanceof Driver) {
$this->markTestSkipped('pdo_sqlite only test.'); return;
} }
$this->markTestSkipped('pdo_sqlite only test.');
} }
/** /**
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
namespace Doctrine\Tests\DBAL\Functional\Driver\PDOSqlsrv; namespace Doctrine\Tests\DBAL\Functional\Driver\PDOSqlsrv;
use Doctrine\DBAL\Driver\Connection as Connection; use Doctrine\DBAL\Driver\Connection;
use Doctrine\DBAL\Driver\PDOSqlsrv\Driver; use Doctrine\DBAL\Driver\PDOSqlsrv\Driver;
use Doctrine\Tests\DBAL\Functional\Driver\AbstractDriverTest; use Doctrine\Tests\DBAL\Functional\Driver\AbstractDriverTest;
use PDO; use PDO;
......
...@@ -4,9 +4,10 @@ namespace Doctrine\Tests\DBAL\Functional\Driver\SQLAnywhere; ...@@ -4,9 +4,10 @@ namespace Doctrine\Tests\DBAL\Functional\Driver\SQLAnywhere;
use Doctrine\DBAL\Driver\SQLAnywhere\Driver; use Doctrine\DBAL\Driver\SQLAnywhere\Driver;
use Doctrine\DBAL\DriverManager; use Doctrine\DBAL\DriverManager;
use Doctrine\Tests\DbalFunctionalTestCase;
use function extension_loaded; use function extension_loaded;
class ConnectionTest extends \Doctrine\Tests\DbalFunctionalTestCase class ConnectionTest extends DbalFunctionalTestCase
{ {
protected function setUp() protected function setUp()
{ {
...@@ -16,14 +17,16 @@ class ConnectionTest extends \Doctrine\Tests\DbalFunctionalTestCase ...@@ -16,14 +17,16 @@ class ConnectionTest extends \Doctrine\Tests\DbalFunctionalTestCase
parent::setUp(); parent::setUp();
if (! $this->_conn->getDriver() instanceof Driver) { if ($this->_conn->getDriver() instanceof Driver) {
$this->markTestSkipped('sqlanywhere only test.'); return;
} }
$this->markTestSkipped('sqlanywhere only test.');
} }
public function testNonPersistentConnection() public function testNonPersistentConnection()
{ {
$params = $this->_conn->getParams(); $params = $this->_conn->getParams();
$params['persistent'] = false; $params['persistent'] = false;
$conn = DriverManager::getConnection($params); $conn = DriverManager::getConnection($params);
...@@ -35,7 +38,7 @@ class ConnectionTest extends \Doctrine\Tests\DbalFunctionalTestCase ...@@ -35,7 +38,7 @@ class ConnectionTest extends \Doctrine\Tests\DbalFunctionalTestCase
public function testPersistentConnection() public function testPersistentConnection()
{ {
$params = $this->_conn->getParams(); $params = $this->_conn->getParams();
$params['persistent'] = true; $params['persistent'] = true;
$conn = DriverManager::getConnection($params); $conn = DriverManager::getConnection($params);
......
...@@ -17,9 +17,11 @@ class DriverTest extends AbstractDriverTest ...@@ -17,9 +17,11 @@ class DriverTest extends AbstractDriverTest
parent::setUp(); parent::setUp();
if (! $this->_conn->getDriver() instanceof Driver) { if ($this->_conn->getDriver() instanceof Driver) {
$this->markTestSkipped('sqlanywhere only test.'); return;
} }
$this->markTestSkipped('sqlanywhere only test.');
} }
public function testReturnsDatabaseNameWithoutDatabaseNameParameter() public function testReturnsDatabaseNameWithoutDatabaseNameParameter()
......
...@@ -4,9 +4,10 @@ namespace Doctrine\Tests\DBAL\Functional\Driver\SQLAnywhere; ...@@ -4,9 +4,10 @@ namespace Doctrine\Tests\DBAL\Functional\Driver\SQLAnywhere;
use Doctrine\DBAL\Driver\SQLAnywhere\Driver; use Doctrine\DBAL\Driver\SQLAnywhere\Driver;
use Doctrine\DBAL\DriverManager; use Doctrine\DBAL\DriverManager;
use Doctrine\Tests\DbalFunctionalTestCase;
use function extension_loaded; use function extension_loaded;
class StatementTest extends \Doctrine\Tests\DbalFunctionalTestCase class StatementTest extends DbalFunctionalTestCase
{ {
protected function setUp() protected function setUp()
{ {
...@@ -16,39 +17,40 @@ class StatementTest extends \Doctrine\Tests\DbalFunctionalTestCase ...@@ -16,39 +17,40 @@ class StatementTest extends \Doctrine\Tests\DbalFunctionalTestCase
parent::setUp(); parent::setUp();
if (! $this->_conn->getDriver() instanceof Driver) { if ($this->_conn->getDriver() instanceof Driver) {
$this->markTestSkipped('sqlanywhere only test.'); return;
} }
$this->markTestSkipped('sqlanywhere only test.');
} }
public function testNonPersistentStatement() public function testNonPersistentStatement()
{ {
$params = $this->_conn->getParams(); $params = $this->_conn->getParams();
$params['persistent'] = false; $params['persistent'] = false;
$conn = DriverManager::getConnection($params); $conn = DriverManager::getConnection($params);
$conn->connect(); $conn->connect();
self::assertTrue($conn->isConnected(),'No SQLAnywhere-Connection established'); self::assertTrue($conn->isConnected(), 'No SQLAnywhere-Connection established');
$prepStmt = $conn->prepare('SELECT 1'); $prepStmt = $conn->prepare('SELECT 1');
self::assertTrue($prepStmt->execute(),' Statement non-persistent failed'); self::assertTrue($prepStmt->execute(), ' Statement non-persistent failed');
} }
public function testPersistentStatement() public function testPersistentStatement()
{ {
$params = $this->_conn->getParams(); $params = $this->_conn->getParams();
$params['persistent'] = true; $params['persistent'] = true;
$conn = DriverManager::getConnection($params); $conn = DriverManager::getConnection($params);
$conn->connect(); $conn->connect();
self::assertTrue($conn->isConnected(),'No SQLAnywhere-Connection established'); self::assertTrue($conn->isConnected(), 'No SQLAnywhere-Connection established');
$prepStmt = $conn->prepare('SELECT 1'); $prepStmt = $conn->prepare('SELECT 1');
self::assertTrue($prepStmt->execute(),' Statement persistent failed'); self::assertTrue($prepStmt->execute(), ' Statement persistent failed');
} }
} }
...@@ -16,9 +16,11 @@ class DriverTest extends AbstractDriverTest ...@@ -16,9 +16,11 @@ class DriverTest extends AbstractDriverTest
parent::setUp(); parent::setUp();
if (! $this->_conn->getDriver() instanceof Driver) { if ($this->_conn->getDriver() instanceof Driver) {
$this->markTestSkipped('sqlsrv only test.'); return;
} }
$this->markTestSkipped('sqlsrv only test.');
} }
/** /**
......
...@@ -11,15 +11,17 @@ class StatementTest extends DbalFunctionalTestCase ...@@ -11,15 +11,17 @@ class StatementTest extends DbalFunctionalTestCase
{ {
protected function setUp() protected function setUp()
{ {
if (!extension_loaded('sqlsrv')) { if (! extension_loaded('sqlsrv')) {
self::markTestSkipped('sqlsrv is not installed.'); self::markTestSkipped('sqlsrv is not installed.');
} }
parent::setUp(); parent::setUp();
if (!$this->_conn->getDriver() instanceof Driver) { if ($this->_conn->getDriver() instanceof Driver) {
self::markTestSkipped('sqlsrv only test'); return;
} }
self::markTestSkipped('sqlsrv only test');
} }
public function testFailureToPrepareResultsInException() public function testFailureToPrepareResultsInException()
......
...@@ -4,7 +4,6 @@ namespace Doctrine\Tests\DBAL\Functional; ...@@ -4,7 +4,6 @@ namespace Doctrine\Tests\DBAL\Functional;
use Doctrine\Tests\DbalFunctionalTestCase; use Doctrine\Tests\DbalFunctionalTestCase;
use function sprintf; use function sprintf;
use function str_replace;
final class LikeWildcardsEscapingTest extends DbalFunctionalTestCase final class LikeWildcardsEscapingTest extends DbalFunctionalTestCase
{ {
......
...@@ -2,7 +2,9 @@ ...@@ -2,7 +2,9 @@
namespace Doctrine\Tests\DBAL\Functional; namespace Doctrine\Tests\DBAL\Functional;
class LoggingTest extends \Doctrine\Tests\DbalFunctionalTestCase use Doctrine\Tests\DbalFunctionalTestCase;
class LoggingTest extends DbalFunctionalTestCase
{ {
public function testLogExecuteQuery() public function testLogExecuteQuery()
{ {
...@@ -11,11 +13,11 @@ class LoggingTest extends \Doctrine\Tests\DbalFunctionalTestCase ...@@ -11,11 +13,11 @@ class LoggingTest extends \Doctrine\Tests\DbalFunctionalTestCase
$logMock = $this->createMock('Doctrine\DBAL\Logging\SQLLogger'); $logMock = $this->createMock('Doctrine\DBAL\Logging\SQLLogger');
$logMock->expects($this->at(0)) $logMock->expects($this->at(0))
->method('startQuery') ->method('startQuery')
->with($this->equalTo($sql), $this->equalTo(array()), $this->equalTo(array())); ->with($this->equalTo($sql), $this->equalTo([]), $this->equalTo([]));
$logMock->expects($this->at(1)) $logMock->expects($this->at(1))
->method('stopQuery'); ->method('stopQuery');
$this->_conn->getConfiguration()->setSQLLogger($logMock); $this->_conn->getConfiguration()->setSQLLogger($logMock);
$this->_conn->executeQuery($sql, array()); $this->_conn->executeQuery($sql, []);
} }
public function testLogExecuteUpdate() public function testLogExecuteUpdate()
...@@ -27,11 +29,11 @@ class LoggingTest extends \Doctrine\Tests\DbalFunctionalTestCase ...@@ -27,11 +29,11 @@ class LoggingTest extends \Doctrine\Tests\DbalFunctionalTestCase
$logMock = $this->createMock('Doctrine\DBAL\Logging\SQLLogger'); $logMock = $this->createMock('Doctrine\DBAL\Logging\SQLLogger');
$logMock->expects($this->at(0)) $logMock->expects($this->at(0))
->method('startQuery') ->method('startQuery')
->with($this->equalTo($sql), $this->equalTo(array()), $this->equalTo(array())); ->with($this->equalTo($sql), $this->equalTo([]), $this->equalTo([]));
$logMock->expects($this->at(1)) $logMock->expects($this->at(1))
->method('stopQuery'); ->method('stopQuery');
$this->_conn->getConfiguration()->setSQLLogger($logMock); $this->_conn->getConfiguration()->setSQLLogger($logMock);
$this->_conn->executeUpdate($sql, array()); $this->_conn->executeUpdate($sql, []);
} }
public function testLogPrepareExecute() public function testLogPrepareExecute()
...@@ -41,7 +43,7 @@ class LoggingTest extends \Doctrine\Tests\DbalFunctionalTestCase ...@@ -41,7 +43,7 @@ class LoggingTest extends \Doctrine\Tests\DbalFunctionalTestCase
$logMock = $this->createMock('Doctrine\DBAL\Logging\SQLLogger'); $logMock = $this->createMock('Doctrine\DBAL\Logging\SQLLogger');
$logMock->expects($this->once()) $logMock->expects($this->once())
->method('startQuery') ->method('startQuery')
->with($this->equalTo($sql), $this->equalTo(array())); ->with($this->equalTo($sql), $this->equalTo([]));
$logMock->expects($this->at(1)) $logMock->expects($this->at(1))
->method('stopQuery'); ->method('stopQuery');
$this->_conn->getConfiguration()->setSQLLogger($logMock); $this->_conn->getConfiguration()->setSQLLogger($logMock);
......
...@@ -4,7 +4,10 @@ namespace Doctrine\Tests\DBAL\Functional; ...@@ -4,7 +4,10 @@ namespace Doctrine\Tests\DBAL\Functional;
use Doctrine\DBAL\Connections\MasterSlaveConnection; use Doctrine\DBAL\Connections\MasterSlaveConnection;
use Doctrine\DBAL\DriverManager; use Doctrine\DBAL\DriverManager;
use Doctrine\DBAL\Schema\AbstractSchemaManager;
use Doctrine\DBAL\Schema\Table;
use Doctrine\Tests\DbalFunctionalTestCase; use Doctrine\Tests\DbalFunctionalTestCase;
use Throwable;
use const CASE_LOWER; use const CASE_LOWER;
use function array_change_key_case; use function array_change_key_case;
use function sprintf; use function sprintf;
...@@ -24,25 +27,23 @@ class MasterSlaveConnectionTest extends DbalFunctionalTestCase ...@@ -24,25 +27,23 @@ class MasterSlaveConnectionTest extends DbalFunctionalTestCase
$platformName = $this->_conn->getDatabasePlatform()->getName(); $platformName = $this->_conn->getDatabasePlatform()->getName();
// This is a MySQL specific test, skip other vendors. // This is a MySQL specific test, skip other vendors.
if ($platformName != 'mysql') { if ($platformName !== 'mysql') {
$this->markTestSkipped(sprintf('Test does not work on %s.', $platformName)); $this->markTestSkipped(sprintf('Test does not work on %s.', $platformName));
} }
try { try {
/* @var $sm \Doctrine\DBAL\Schema\AbstractSchemaManager */ /** @var AbstractSchemaManager $sm */
$table = new \Doctrine\DBAL\Schema\Table("master_slave_table"); $table = new Table('master_slave_table');
$table->addColumn('test_int', 'integer'); $table->addColumn('test_int', 'integer');
$table->setPrimaryKey(array('test_int')); $table->setPrimaryKey(['test_int']);
$sm = $this->_conn->getSchemaManager(); $sm = $this->_conn->getSchemaManager();
$sm->createTable($table); $sm->createTable($table);
} catch (Throwable $e) {
} catch(\Exception $e) {
} }
$this->_conn->executeUpdate('DELETE FROM master_slave_table'); $this->_conn->executeUpdate('DELETE FROM master_slave_table');
$this->_conn->insert('master_slave_table', array('test_int' => 1)); $this->_conn->insert('master_slave_table', ['test_int' => 1]);
} }
private function createMasterSlaveConnection(bool $keepSlave = false) : MasterSlaveConnection private function createMasterSlaveConnection(bool $keepSlave = false) : MasterSlaveConnection
...@@ -52,9 +53,9 @@ class MasterSlaveConnectionTest extends DbalFunctionalTestCase ...@@ -52,9 +53,9 @@ class MasterSlaveConnectionTest extends DbalFunctionalTestCase
private function createMasterSlaveConnectionParams(bool $keepSlave = false) : array private function createMasterSlaveConnectionParams(bool $keepSlave = false) : array
{ {
$params = $this->_conn->getParams(); $params = $this->_conn->getParams();
$params['master'] = $params; $params['master'] = $params;
$params['slaves'] = array($params, $params); $params['slaves'] = [$params, $params];
$params['keepSlave'] = $keepSlave; $params['keepSlave'] = $keepSlave;
$params['wrapperClass'] = MasterSlaveConnection::class; $params['wrapperClass'] = MasterSlaveConnection::class;
...@@ -65,17 +66,19 @@ class MasterSlaveConnectionTest extends DbalFunctionalTestCase ...@@ -65,17 +66,19 @@ class MasterSlaveConnectionTest extends DbalFunctionalTestCase
{ {
$charsets = [ $charsets = [
'utf8', 'utf8',
'latin1' 'latin1',
]; ];
foreach ($charsets as $charset) { foreach ($charsets as $charset) {
$params = $this->createMasterSlaveConnectionParams(); $params = $this->createMasterSlaveConnectionParams();
$params['master']['charset'] = $charset; $params['master']['charset'] = $charset;
foreach ($params['slaves'] as $index => $slaveParams) { foreach ($params['slaves'] as $index => $slaveParams) {
if (isset($slaveParams['charset'])) { if (! isset($slaveParams['charset'])) {
unset($params['slaves'][$index]['charset']); continue;
} }
unset($params['slaves'][$index]['charset']);
} }
/** @var MasterSlaveConnection $conn */ /** @var MasterSlaveConnection $conn */
...@@ -108,8 +111,8 @@ class MasterSlaveConnectionTest extends DbalFunctionalTestCase ...@@ -108,8 +111,8 @@ class MasterSlaveConnectionTest extends DbalFunctionalTestCase
{ {
$conn = $this->createMasterSlaveConnection(); $conn = $this->createMasterSlaveConnection();
$sql = "SELECT count(*) as num FROM master_slave_table"; $sql = 'SELECT count(*) as num FROM master_slave_table';
$data = $conn->fetchAll($sql); $data = $conn->fetchAll($sql);
$data[0] = array_change_key_case($data[0], CASE_LOWER); $data[0] = array_change_key_case($data[0], CASE_LOWER);
self::assertEquals(1, $data[0]['num']); self::assertEquals(1, $data[0]['num']);
...@@ -119,12 +122,12 @@ class MasterSlaveConnectionTest extends DbalFunctionalTestCase ...@@ -119,12 +122,12 @@ class MasterSlaveConnectionTest extends DbalFunctionalTestCase
public function testMasterOnWriteOperation() public function testMasterOnWriteOperation()
{ {
$conn = $this->createMasterSlaveConnection(); $conn = $this->createMasterSlaveConnection();
$conn->insert('master_slave_table', array('test_int' => 30)); $conn->insert('master_slave_table', ['test_int' => 30]);
self::assertTrue($conn->isConnectedToMaster()); self::assertTrue($conn->isConnectedToMaster());
$sql = "SELECT count(*) as num FROM master_slave_table"; $sql = 'SELECT count(*) as num FROM master_slave_table';
$data = $conn->fetchAll($sql); $data = $conn->fetchAll($sql);
$data[0] = array_change_key_case($data[0], CASE_LOWER); $data[0] = array_change_key_case($data[0], CASE_LOWER);
self::assertEquals(2, $data[0]['num']); self::assertEquals(2, $data[0]['num']);
...@@ -140,7 +143,7 @@ class MasterSlaveConnectionTest extends DbalFunctionalTestCase ...@@ -140,7 +143,7 @@ class MasterSlaveConnectionTest extends DbalFunctionalTestCase
$conn->connect('slave'); $conn->connect('slave');
$conn->beginTransaction(); $conn->beginTransaction();
$conn->insert('master_slave_table', array('test_int' => 30)); $conn->insert('master_slave_table', ['test_int' => 30]);
$conn->commit(); $conn->commit();
self::assertTrue($conn->isConnectedToMaster()); self::assertTrue($conn->isConnectedToMaster());
...@@ -160,7 +163,7 @@ class MasterSlaveConnectionTest extends DbalFunctionalTestCase ...@@ -160,7 +163,7 @@ class MasterSlaveConnectionTest extends DbalFunctionalTestCase
$conn = $this->createMasterSlaveConnection($keepSlave = true); $conn = $this->createMasterSlaveConnection($keepSlave = true);
$conn->connect('slave'); $conn->connect('slave');
$conn->insert('master_slave_table', array('test_int' => 30)); $conn->insert('master_slave_table', ['test_int' => 30]);
self::assertTrue($conn->isConnectedToMaster()); self::assertTrue($conn->isConnectedToMaster());
......
...@@ -6,13 +6,15 @@ use Doctrine\DBAL\Connection; ...@@ -6,13 +6,15 @@ use Doctrine\DBAL\Connection;
use Doctrine\DBAL\FetchMode; use Doctrine\DBAL\FetchMode;
use Doctrine\DBAL\ParameterType; use Doctrine\DBAL\ParameterType;
use Doctrine\DBAL\Schema\Table; use Doctrine\DBAL\Schema\Table;
use Doctrine\Tests\DbalFunctionalTestCase;
use Throwable;
use const CASE_LOWER; use const CASE_LOWER;
use function array_change_key_case; use function array_change_key_case;
/** /**
* @group DDC-1372 * @group DDC-1372
*/ */
class NamedParametersTest extends \Doctrine\Tests\DbalFunctionalTestCase class NamedParametersTest extends DbalFunctionalTestCase
{ {
public function ticketProvider() public function ticketProvider()
{ {
...@@ -149,61 +151,64 @@ class NamedParametersTest extends \Doctrine\Tests\DbalFunctionalTestCase ...@@ -149,61 +151,64 @@ class NamedParametersTest extends \Doctrine\Tests\DbalFunctionalTestCase
{ {
parent::setUp(); parent::setUp();
if (! $this->_conn->getSchemaManager()->tablesExist('ddc1372_foobar')) { if ($this->_conn->getSchemaManager()->tablesExist('ddc1372_foobar')) {
try { return;
$table = new Table('ddc1372_foobar'); }
$table->addColumn('id', 'integer');
$table->addColumn('foo', 'string');
$table->addColumn('bar', 'string');
$table->setPrimaryKey(['id']);
$sm = $this->_conn->getSchemaManager();
$sm->createTable($table);
$this->_conn->insert('ddc1372_foobar', [ try {
'id' => 1, $table = new Table('ddc1372_foobar');
'foo' => 1, $table->addColumn('id', 'integer');
'bar' => 1, $table->addColumn('foo', 'string');
]); $table->addColumn('bar', 'string');
$this->_conn->insert('ddc1372_foobar', [ $table->setPrimaryKey(['id']);
'id' => 2,
'foo' => 1, $sm = $this->_conn->getSchemaManager();
'bar' => 2, $sm->createTable($table);
]);
$this->_conn->insert('ddc1372_foobar', [ $this->_conn->insert('ddc1372_foobar', [
'id' => 3, 'id' => 1,
'foo' => 1, 'foo' => 1,
'bar' => 3, 'bar' => 1,
]); ]);
$this->_conn->insert('ddc1372_foobar', [ $this->_conn->insert('ddc1372_foobar', [
'id' => 4, 'id' => 2,
'foo' => 1, 'foo' => 1,
'bar' => 4, 'bar' => 2,
]); ]);
$this->_conn->insert('ddc1372_foobar', [ $this->_conn->insert('ddc1372_foobar', [
'id' => 5, 'id' => 3,
'foo' => 2, 'foo' => 1,
'bar' => 1, 'bar' => 3,
]); ]);
$this->_conn->insert('ddc1372_foobar', [ $this->_conn->insert('ddc1372_foobar', [
'id' => 6, 'id' => 4,
'foo' => 2, 'foo' => 1,
'bar' => 2, 'bar' => 4,
]); ]);
} catch(\Exception $e) { $this->_conn->insert('ddc1372_foobar', [
$this->fail($e->getMessage()); 'id' => 5,
} 'foo' => 2,
'bar' => 1,
]);
$this->_conn->insert('ddc1372_foobar', [
'id' => 6,
'foo' => 2,
'bar' => 2,
]);
} catch (Throwable $e) {
$this->fail($e->getMessage());
} }
} }
/** /**
* @dataProvider ticketProvider
* @param string $query * @param string $query
* @param array $params * @param array $params
* @param array $types * @param array $types
* @param array $expected * @param array $expected
*
* @dataProvider ticketProvider
*/ */
public function testTicket($query,$params,$types,$expected) public function testTicket($query, $params, $types, $expected)
{ {
$stmt = $this->_conn->executeQuery($query, $params, $types); $stmt = $this->_conn->executeQuery($query, $params, $types);
$result = $stmt->fetchAll(FetchMode::ASSOCIATIVE); $result = $stmt->fetchAll(FetchMode::ASSOCIATIVE);
......
...@@ -7,16 +7,18 @@ use Doctrine\DBAL\Connection; ...@@ -7,16 +7,18 @@ use Doctrine\DBAL\Connection;
use Doctrine\DBAL\DriverManager; use Doctrine\DBAL\DriverManager;
use Doctrine\DBAL\FetchMode; use Doctrine\DBAL\FetchMode;
use Doctrine\DBAL\Portability\Connection as ConnectionPortability; use Doctrine\DBAL\Portability\Connection as ConnectionPortability;
use Doctrine\DBAL\Schema\AbstractSchemaManager;
use Doctrine\DBAL\Schema\Table;
use Doctrine\Tests\DbalFunctionalTestCase;
use Throwable;
use function strlen; use function strlen;
/** /**
* @group DBAL-56 * @group DBAL-56
*/ */
class PortabilityTest extends \Doctrine\Tests\DbalFunctionalTestCase class PortabilityTest extends DbalFunctionalTestCase
{ {
/** /** @var Connection */
* @var Connection
*/
private $portableConnection; private $portableConnection;
protected function tearDown() protected function tearDown()
...@@ -31,13 +33,14 @@ class PortabilityTest extends \Doctrine\Tests\DbalFunctionalTestCase ...@@ -31,13 +33,14 @@ class PortabilityTest extends \Doctrine\Tests\DbalFunctionalTestCase
/** /**
* @param int $portabilityMode * @param int $portabilityMode
* @param int $case * @param int $case
*
* @return Connection * @return Connection
*/ */
private function getPortableConnection( private function getPortableConnection(
$portabilityMode = ConnectionPortability::PORTABILITY_ALL, $portabilityMode = ConnectionPortability::PORTABILITY_ALL,
$case = ColumnCase::LOWER $case = ColumnCase::LOWER
) { ) {
if (!$this->portableConnection) { if (! $this->portableConnection) {
$params = $this->_conn->getParams(); $params = $this->_conn->getParams();
$params['wrapperClass'] = ConnectionPortability::class; $params['wrapperClass'] = ConnectionPortability::class;
...@@ -47,20 +50,19 @@ class PortabilityTest extends \Doctrine\Tests\DbalFunctionalTestCase ...@@ -47,20 +50,19 @@ class PortabilityTest extends \Doctrine\Tests\DbalFunctionalTestCase
$this->portableConnection = DriverManager::getConnection($params, $this->_conn->getConfiguration(), $this->_conn->getEventManager()); $this->portableConnection = DriverManager::getConnection($params, $this->_conn->getConfiguration(), $this->_conn->getEventManager());
try { try {
/* @var $sm \Doctrine\DBAL\Schema\AbstractSchemaManager */ /** @var AbstractSchemaManager $sm */
$table = new \Doctrine\DBAL\Schema\Table("portability_table"); $table = new Table('portability_table');
$table->addColumn('Test_Int', 'integer'); $table->addColumn('Test_Int', 'integer');
$table->addColumn('Test_String', 'string', array('fixed' => true, 'length' => 32)); $table->addColumn('Test_String', 'string', ['fixed' => true, 'length' => 32]);
$table->addColumn('Test_Null', 'string', array('notnull' => false)); $table->addColumn('Test_Null', 'string', ['notnull' => false]);
$table->setPrimaryKey(array('Test_Int')); $table->setPrimaryKey(['Test_Int']);
$sm = $this->portableConnection->getSchemaManager(); $sm = $this->portableConnection->getSchemaManager();
$sm->createTable($table); $sm->createTable($table);
$this->portableConnection->insert('portability_table', array('Test_Int' => 1, 'Test_String' => 'foo', 'Test_Null' => '')); $this->portableConnection->insert('portability_table', ['Test_Int' => 1, 'Test_String' => 'foo', 'Test_Null' => '']);
$this->portableConnection->insert('portability_table', array('Test_Int' => 2, 'Test_String' => 'foo ', 'Test_Null' => null)); $this->portableConnection->insert('portability_table', ['Test_Int' => 2, 'Test_String' => 'foo ', 'Test_Null' => null]);
} catch(\Exception $e) { } catch (Throwable $e) {
} }
} }
...@@ -103,18 +105,18 @@ class PortabilityTest extends \Doctrine\Tests\DbalFunctionalTestCase ...@@ -103,18 +105,18 @@ class PortabilityTest extends \Doctrine\Tests\DbalFunctionalTestCase
$stmt = $conn->query('SELECT * FROM portability_table'); $stmt = $conn->query('SELECT * FROM portability_table');
foreach ($stmt as $row) { foreach ($stmt as $row) {
$this->assertFetchResultRow($row); $this->assertFetchResultRow($row);
} }
$stmt = $conn->query('SELECT * FROM portability_table'); $stmt = $conn->query('SELECT * FROM portability_table');
while (($row = $stmt->fetch())) { while (($row = $stmt->fetch())) {
$this->assertFetchResultRow($row); $this->assertFetchResultRow($row);
} }
$stmt = $conn->prepare('SELECT * FROM portability_table'); $stmt = $conn->prepare('SELECT * FROM portability_table');
$stmt->execute(); $stmt->execute();
while (($row = $stmt->fetch())) { while (($row = $stmt->fetch())) {
$this->assertFetchResultRow($row); $this->assertFetchResultRow($row);
} }
} }
...@@ -128,9 +130,9 @@ class PortabilityTest extends \Doctrine\Tests\DbalFunctionalTestCase ...@@ -128,9 +130,9 @@ class PortabilityTest extends \Doctrine\Tests\DbalFunctionalTestCase
public function assertFetchResultRow($row) public function assertFetchResultRow($row)
{ {
self::assertContains($row['test_int'], array(1, 2), "Primary key test_int should either be 1 or 2."); self::assertContains($row['test_int'], [1, 2], 'Primary key test_int should either be 1 or 2.');
self::assertArrayHasKey('test_string', $row, "Case should be lowered."); self::assertArrayHasKey('test_string', $row, 'Case should be lowered.');
self::assertEquals(3, strlen($row['test_string']), "test_string should be rtrimed to length of three for CHAR(32) column."); self::assertEquals(3, strlen($row['test_string']), 'test_string should be rtrimed to length of three for CHAR(32) column.');
self::assertNull($row['test_null']); self::assertNull($row['test_null']);
self::assertArrayNotHasKey(0, $row, 'The row should not contain numerical keys.'); self::assertArrayNotHasKey(0, $row, 'The row should not contain numerical keys.');
} }
...@@ -141,12 +143,10 @@ class PortabilityTest extends \Doctrine\Tests\DbalFunctionalTestCase ...@@ -141,12 +143,10 @@ class PortabilityTest extends \Doctrine\Tests\DbalFunctionalTestCase
public function testPortabilityPdoSqlServer() public function testPortabilityPdoSqlServer()
{ {
$portability = ConnectionPortability::PORTABILITY_SQLSRV; $portability = ConnectionPortability::PORTABILITY_SQLSRV;
$params = array( $params = ['portability' => $portability];
'portability' => $portability
);
$driverMock = $this->getMockBuilder('Doctrine\\DBAL\\Driver\\PDOSqlsrv\\Driver') $driverMock = $this->getMockBuilder('Doctrine\\DBAL\\Driver\\PDOSqlsrv\\Driver')
->setMethods(array('connect')) ->setMethods(['connect'])
->getMock(); ->getMock();
$driverMock->expects($this->once()) $driverMock->expects($this->once())
...@@ -174,16 +174,16 @@ class PortabilityTest extends \Doctrine\Tests\DbalFunctionalTestCase ...@@ -174,16 +174,16 @@ class PortabilityTest extends \Doctrine\Tests\DbalFunctionalTestCase
public static function fetchAllColumnProvider() public static function fetchAllColumnProvider()
{ {
return array( return [
'int' => array( 'int' => [
'Test_Int', 'Test_Int',
array(1, 2), [1, 2],
), ],
'string' => array( 'string' => [
'Test_String', 'Test_String',
array('foo', 'foo'), ['foo', 'foo'],
), ],
); ];
} }
public function testFetchAllNullColumn() public function testFetchAllNullColumn()
...@@ -192,6 +192,6 @@ class PortabilityTest extends \Doctrine\Tests\DbalFunctionalTestCase ...@@ -192,6 +192,6 @@ class PortabilityTest extends \Doctrine\Tests\DbalFunctionalTestCase
$stmt = $conn->query('SELECT Test_Null FROM portability_table'); $stmt = $conn->query('SELECT Test_Null FROM portability_table');
$column = $stmt->fetchAll(FetchMode::COLUMN); $column = $stmt->fetchAll(FetchMode::COLUMN);
self::assertSame(array(null, null), $column); self::assertSame([null, null], $column);
} }
} }
...@@ -13,7 +13,7 @@ class Db2SchemaManagerTest extends SchemaManagerFunctionalTestCase ...@@ -13,7 +13,7 @@ class Db2SchemaManagerTest extends SchemaManagerFunctionalTestCase
{ {
$table = new Table('boolean_column_test'); $table = new Table('boolean_column_test');
$table->addColumn('bool', 'boolean'); $table->addColumn('bool', 'boolean');
$table->addColumn('bool_commented', 'boolean', array('comment' => "That's a comment")); $table->addColumn('bool_commented', 'boolean', ['comment' => "That's a comment"]);
$this->_sm->createTable($table); $this->_sm->createTable($table);
......
...@@ -12,9 +12,9 @@ class DrizzleSchemaManagerTest extends SchemaManagerFunctionalTestCase ...@@ -12,9 +12,9 @@ class DrizzleSchemaManagerTest extends SchemaManagerFunctionalTestCase
$table = new Table($tableName); $table = new Table($tableName);
$table->addColumn('id', 'integer'); $table->addColumn('id', 'integer');
$table->addColumn('column_varbinary', 'binary', array()); $table->addColumn('column_varbinary', 'binary', []);
$table->addColumn('column_binary', 'binary', array('fixed' => true)); $table->addColumn('column_binary', 'binary', ['fixed' => true]);
$table->setPrimaryKey(array('id')); $table->setPrimaryKey(['id']);
$this->_sm->createTable($table); $this->_sm->createTable($table);
...@@ -29,7 +29,7 @@ class DrizzleSchemaManagerTest extends SchemaManagerFunctionalTestCase ...@@ -29,7 +29,7 @@ class DrizzleSchemaManagerTest extends SchemaManagerFunctionalTestCase
public function testColumnCollation() public function testColumnCollation()
{ {
$table = new Table('test_collation'); $table = new Table('test_collation');
$table->addOption('collate', $collation = 'utf8_unicode_ci'); $table->addOption('collate', $collation = 'utf8_unicode_ci');
$table->addColumn('id', 'integer'); $table->addColumn('id', 'integer');
$table->addColumn('text', 'text'); $table->addColumn('text', 'text');
......
...@@ -12,8 +12,8 @@ class SQLAnywhereSchemaManagerTest extends SchemaManagerFunctionalTestCase ...@@ -12,8 +12,8 @@ class SQLAnywhereSchemaManagerTest extends SchemaManagerFunctionalTestCase
{ {
$this->createTestTable('view_test_table'); $this->createTestTable('view_test_table');
$name = "doctrine_test_view"; $name = 'doctrine_test_view';
$sql = "SELECT * from DBA.view_test_table"; $sql = 'SELECT * from DBA.view_test_table';
$view = new View($name, $sql); $view = new View($name, $sql);
...@@ -21,7 +21,7 @@ class SQLAnywhereSchemaManagerTest extends SchemaManagerFunctionalTestCase ...@@ -21,7 +21,7 @@ class SQLAnywhereSchemaManagerTest extends SchemaManagerFunctionalTestCase
$views = $this->_sm->listViews(); $views = $this->_sm->listViews();
self::assertCount(1, $views, "Database has to have one view."); self::assertCount(1, $views, 'Database has to have one view.');
self::assertInstanceOf('Doctrine\DBAL\Schema\View', $views[$name]); self::assertInstanceOf('Doctrine\DBAL\Schema\View', $views[$name]);
self::assertEquals($name, $views[$name]->getName()); self::assertEquals($name, $views[$name]->getName());
self::assertEquals($sql, $views[$name]->getSql()); self::assertEquals($sql, $views[$name]->getSql());
...@@ -32,14 +32,14 @@ class SQLAnywhereSchemaManagerTest extends SchemaManagerFunctionalTestCase ...@@ -32,14 +32,14 @@ class SQLAnywhereSchemaManagerTest extends SchemaManagerFunctionalTestCase
$table = $this->getTestTable('test_create_advanced_index'); $table = $this->getTestTable('test_create_advanced_index');
$this->_sm->dropAndCreateTable($table); $this->_sm->dropAndCreateTable($table);
$this->_sm->dropAndCreateIndex( $this->_sm->dropAndCreateIndex(
new Index('test', array('test'), true, false, array('clustered', 'with_nulls_not_distinct', 'for_olap_workload')), new Index('test', ['test'], true, false, ['clustered', 'with_nulls_not_distinct', 'for_olap_workload']),
$table->getName() $table->getName()
); );
$tableIndexes = $this->_sm->listTableIndexes('test_create_advanced_index'); $tableIndexes = $this->_sm->listTableIndexes('test_create_advanced_index');
self::assertInternalType('array', $tableIndexes); self::assertInternalType('array', $tableIndexes);
self::assertEquals('test', $tableIndexes['test']->getName()); self::assertEquals('test', $tableIndexes['test']->getName());
self::assertEquals(array('test'), $tableIndexes['test']->getColumns()); self::assertEquals(['test'], $tableIndexes['test']->getColumns());
self::assertTrue($tableIndexes['test']->isUnique()); self::assertTrue($tableIndexes['test']->isUnique());
self::assertFalse($tableIndexes['test']->isPrimary()); self::assertFalse($tableIndexes['test']->isPrimary());
self::assertTrue($tableIndexes['test']->hasFlag('clustered')); self::assertTrue($tableIndexes['test']->hasFlag('clustered'));
...@@ -50,9 +50,9 @@ class SQLAnywhereSchemaManagerTest extends SchemaManagerFunctionalTestCase ...@@ -50,9 +50,9 @@ class SQLAnywhereSchemaManagerTest extends SchemaManagerFunctionalTestCase
public function testListTableColumnsWithFixedStringTypeColumn() public function testListTableColumnsWithFixedStringTypeColumn()
{ {
$table = new Table('list_table_columns_char'); $table = new Table('list_table_columns_char');
$table->addColumn('id', 'integer', array('notnull' => true)); $table->addColumn('id', 'integer', ['notnull' => true]);
$table->addColumn('test', 'string', array('fixed' => true)); $table->addColumn('test', 'string', ['fixed' => true]);
$table->setPrimaryKey(array('id')); $table->setPrimaryKey(['id']);
$this->_sm->dropAndCreateTable($table); $this->_sm->dropAndCreateTable($table);
......
...@@ -3,15 +3,17 @@ ...@@ -3,15 +3,17 @@
namespace Doctrine\Tests\DBAL\Functional; namespace Doctrine\Tests\DBAL\Functional;
use Doctrine\DBAL\Id\TableGenerator; use Doctrine\DBAL\Id\TableGenerator;
use Doctrine\DBAL\Id\TableGeneratorSchemaVisitor;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Tests\DbalFunctionalTestCase;
use Throwable;
/** /**
* @group DDC-450 * @group DDC-450
*/ */
class TableGeneratorTest extends \Doctrine\Tests\DbalFunctionalTestCase class TableGeneratorTest extends DbalFunctionalTestCase
{ {
/** /** @var TableGenerator */
* @var TableGenerator
*/
private $generator; private $generator;
protected function setUp() protected function setUp()
...@@ -19,43 +21,42 @@ class TableGeneratorTest extends \Doctrine\Tests\DbalFunctionalTestCase ...@@ -19,43 +21,42 @@ class TableGeneratorTest extends \Doctrine\Tests\DbalFunctionalTestCase
parent::setUp(); parent::setUp();
$platform = $this->_conn->getDatabasePlatform(); $platform = $this->_conn->getDatabasePlatform();
if ($platform->getName() == "sqlite") { if ($platform->getName() === 'sqlite') {
$this->markTestSkipped('TableGenerator does not work with SQLite'); $this->markTestSkipped('TableGenerator does not work with SQLite');
} }
try { try {
$schema = new \Doctrine\DBAL\Schema\Schema(); $schema = new Schema();
$visitor = new \Doctrine\DBAL\Id\TableGeneratorSchemaVisitor(); $visitor = new TableGeneratorSchemaVisitor();
$schema->visit($visitor); $schema->visit($visitor);
foreach ($schema->toSql($platform) as $sql) { foreach ($schema->toSql($platform) as $sql) {
$this->_conn->exec($sql); $this->_conn->exec($sql);
} }
} catch (Throwable $e) {
} catch(\Exception $e) {
} }
$this->generator = new TableGenerator($this->_conn); $this->generator = new TableGenerator($this->_conn);
} }
public function testNextVal() public function testNextVal()
{ {
$id1 = $this->generator->nextValue("tbl1"); $id1 = $this->generator->nextValue('tbl1');
$id2 = $this->generator->nextValue("tbl1"); $id2 = $this->generator->nextValue('tbl1');
$id3 = $this->generator->nextValue("tbl2"); $id3 = $this->generator->nextValue('tbl2');
self::assertGreaterThan(0, $id1, "First id has to be larger than 0"); self::assertGreaterThan(0, $id1, 'First id has to be larger than 0');
self::assertEquals($id1 + 1, $id2, "Second id is one larger than first one."); self::assertEquals($id1 + 1, $id2, 'Second id is one larger than first one.');
self::assertEquals($id1, $id3, "First ids from different tables are equal."); self::assertEquals($id1, $id3, 'First ids from different tables are equal.');
} }
public function testNextValNotAffectedByOuterTransactions() public function testNextValNotAffectedByOuterTransactions()
{ {
$this->_conn->beginTransaction(); $this->_conn->beginTransaction();
$id1 = $this->generator->nextValue("tbl1"); $id1 = $this->generator->nextValue('tbl1');
$this->_conn->rollBack(); $this->_conn->rollBack();
$id2 = $this->generator->nextValue("tbl1"); $id2 = $this->generator->nextValue('tbl1');
self::assertGreaterThan(0, $id1, "First id has to be larger than 0"); self::assertGreaterThan(0, $id1, 'First id has to be larger than 0');
self::assertEquals($id1 + 1, $id2, "Second id is one larger than first one."); self::assertEquals($id1 + 1, $id2, 'Second id is one larger than first one.');
} }
} }
...@@ -2,22 +2,25 @@ ...@@ -2,22 +2,25 @@
namespace Doctrine\Tests\DBAL\Functional\Ticket; namespace Doctrine\Tests\DBAL\Functional\Ticket;
use Doctrine\DBAL\Schema\Table;
use Doctrine\Tests\DbalFunctionalTestCase;
/** /**
* @group DBAL-168 * @group DBAL-168
*/ */
class DBAL168Test extends \Doctrine\Tests\DbalFunctionalTestCase class DBAL168Test extends DbalFunctionalTestCase
{ {
public function testDomainsTable() public function testDomainsTable()
{ {
if ($this->_conn->getDatabasePlatform()->getName() != "postgresql") { if ($this->_conn->getDatabasePlatform()->getName() !== 'postgresql') {
$this->markTestSkipped('PostgreSQL only test'); $this->markTestSkipped('PostgreSQL only test');
} }
$table = new \Doctrine\DBAL\Schema\Table("domains"); $table = new Table('domains');
$table->addColumn('id', 'integer'); $table->addColumn('id', 'integer');
$table->addColumn('parent_id', 'integer'); $table->addColumn('parent_id', 'integer');
$table->setPrimaryKey(array('id')); $table->setPrimaryKey(['id']);
$table->addForeignKeyConstraint('domains', array('parent_id'), array('id')); $table->addForeignKeyConstraint('domains', ['parent_id'], ['id']);
$this->_conn->getSchemaManager()->createTable($table); $this->_conn->getSchemaManager()->createTable($table);
$table = $this->_conn->getSchemaManager()->listTableDetails('domains'); $table = $this->_conn->getSchemaManager()->listTableDetails('domains');
......
...@@ -22,6 +22,7 @@ class MariaDb1027PlatformTest extends AbstractMySQLPlatformTestCase ...@@ -22,6 +22,7 @@ class MariaDb1027PlatformTest extends AbstractMySQLPlatformTestCase
/** /**
* From MariaDB 10.2.7, JSON type is an alias to LONGTEXT * From MariaDB 10.2.7, JSON type is an alias to LONGTEXT
*
* @link https://mariadb.com/kb/en/library/json-data-type/ * @link https://mariadb.com/kb/en/library/json-data-type/
*/ */
public function testReturnsJsonTypeDeclarationSQL() : void public function testReturnsJsonTypeDeclarationSQL() : void
......
...@@ -9,7 +9,7 @@ class MySqlPlatformTest extends AbstractMySQLPlatformTestCase ...@@ -9,7 +9,7 @@ class MySqlPlatformTest extends AbstractMySQLPlatformTestCase
{ {
public function createPlatform() public function createPlatform()
{ {
return new MysqlPlatform; return new MysqlPlatform();
} }
public function testHasCorrectDefaultTransactionIsolationLevel() public function testHasCorrectDefaultTransactionIsolationLevel()
......
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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