PHPCBF

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