Unverified Commit 37908510 authored by Sergei Morozov's avatar Sergei Morozov Committed by GitHub

Merge pull request #3303 from morozov/doctrine-coding-standard-5

Updated doctrine/coding-standard to 5.0, 
parents 9355a2ba 9d513ca0
......@@ -442,7 +442,7 @@ jobs:
git fetch origin $TRAVIS_BRANCH;
fi
- git merge-base origin/$TRAVIS_BRANCH $TRAVIS_PULL_REQUEST_SHA || git fetch origin +refs/pull/$TRAVIS_PULL_REQUEST/merge --unshallow
- wget https://github.com/diff-sniffer/git/releases/download/0.1.0/git-phpcs.phar
- wget https://github.com/diff-sniffer/git/releases/download/0.2.0/git-phpcs.phar
- php git-phpcs.phar origin/$TRAVIS_BRANCH...$TRAVIS_PULL_REQUEST_SHA
- stage: Coding standard
......
......@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "c1b5ddb5a1259c7ac793dd9c6e6d657a",
"content-hash": "a6e554864457c4bf9babe37f88174255",
"packages": [
{
"name": "doctrine/cache",
......@@ -270,28 +270,28 @@
},
{
"name": "doctrine/coding-standard",
"version": "4.0.0",
"version": "5.0.0",
"source": {
"type": "git",
"url": "https://github.com/doctrine/coding-standard.git",
"reference": "0469c18a1a4724c278f2879c0dd7b1fa860b52de"
"reference": "bb8de042a25c4fb59a2c55c350dc55cc00227a8c"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/doctrine/coding-standard/zipball/0469c18a1a4724c278f2879c0dd7b1fa860b52de",
"reference": "0469c18a1a4724c278f2879c0dd7b1fa860b52de",
"url": "https://api.github.com/repos/doctrine/coding-standard/zipball/bb8de042a25c4fb59a2c55c350dc55cc00227a8c",
"reference": "bb8de042a25c4fb59a2c55c350dc55cc00227a8c",
"shasum": ""
},
"require": {
"dealerdirect/phpcodesniffer-composer-installer": "^0.4.2",
"dealerdirect/phpcodesniffer-composer-installer": "^0.4.4",
"php": "^7.1",
"slevomat/coding-standard": "^4.5.0",
"squizlabs/php_codesniffer": "^3.2.3"
"slevomat/coding-standard": "^4.8.0",
"squizlabs/php_codesniffer": "^3.3.2"
},
"type": "phpcodesniffer-standard",
"extra": {
"branch-alias": {
"dev-master": "3.0.x-dev"
"dev-master": "5.0.x-dev"
}
},
"autoload": {
......@@ -313,18 +313,21 @@
"email": "st.mueller@dzh-online.de"
}
],
"description": "Doctrine Coding Standard",
"homepage": "http://www.doctrine-project.org",
"description": "The Doctrine Coding Standard is a set of PHPCS rules applied to all Doctrine projects.",
"homepage": "https://www.doctrine-project.org/projects/coding-standard.html",
"keywords": [
"checks",
"code",
"coding",
"cs",
"doctrine",
"rules",
"sniffer",
"sniffs",
"standard",
"style"
],
"time": "2018-03-03T23:49:15+00:00"
"time": "2018-09-24T19:08:56+00:00"
},
{
"name": "doctrine/instantiator",
......@@ -2519,30 +2522,29 @@
},
{
"name": "slevomat/coding-standard",
"version": "4.5.2",
"version": "4.8.3",
"source": {
"type": "git",
"url": "https://github.com/slevomat/coding-standard.git",
"reference": "1e609159241fa90d5a429f185b2ea9b881340a7c"
"reference": "32e1ca205fc34920f323582ed29c0602e3897ae3"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/slevomat/coding-standard/zipball/1e609159241fa90d5a429f185b2ea9b881340a7c",
"reference": "1e609159241fa90d5a429f185b2ea9b881340a7c",
"url": "https://api.github.com/repos/slevomat/coding-standard/zipball/32e1ca205fc34920f323582ed29c0602e3897ae3",
"reference": "32e1ca205fc34920f323582ed29c0602e3897ae3",
"shasum": ""
},
"require": {
"php": "^7.1",
"squizlabs/php_codesniffer": "^3.2.3"
"squizlabs/php_codesniffer": "^3.3.0"
},
"require-dev": {
"jakub-onderka/php-parallel-lint": "1.0.0",
"phing/phing": "2.16",
"phing/phing": "2.16.1",
"phpstan/phpstan": "0.9.2",
"phpstan/phpstan-phpunit": "0.9.4",
"phpstan/phpstan-strict-rules": "0.9",
"phpunit/php-code-coverage": "6.0.1",
"phpunit/phpunit": "7.0.2"
"phpunit/phpunit": "7.3.5"
},
"type": "phpcodesniffer-standard",
"autoload": {
......@@ -2555,20 +2557,20 @@
"MIT"
],
"description": "Slevomat Coding Standard for PHP_CodeSniffer complements Consistence Coding Standard by providing sniffs with additional checks.",
"time": "2018-03-08T08:14:33+00:00"
"time": "2018-09-25T21:21:11+00:00"
},
{
"name": "squizlabs/php_codesniffer",
"version": "3.2.3",
"version": "3.3.2",
"source": {
"type": "git",
"url": "https://github.com/squizlabs/PHP_CodeSniffer.git",
"reference": "4842476c434e375f9d3182ff7b89059583aa8b27"
"reference": "6ad28354c04b364c3c71a34e4a18b629cc3b231e"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/4842476c434e375f9d3182ff7b89059583aa8b27",
"reference": "4842476c434e375f9d3182ff7b89059583aa8b27",
"url": "https://api.github.com/repos/squizlabs/PHP_CodeSniffer/zipball/6ad28354c04b364c3c71a34e4a18b629cc3b231e",
"reference": "6ad28354c04b364c3c71a34e4a18b629cc3b231e",
"shasum": ""
},
"require": {
......@@ -2606,7 +2608,7 @@
"phpcs",
"standards"
],
"time": "2018-02-20T21:35:23+00:00"
"time": "2018-09-23T23:08:17+00:00"
},
{
"name": "symfony/console",
......
......@@ -35,4 +35,9 @@
<rule ref="SlevomatCodingStandard.Classes.UnusedPrivateElements.UnusedProperty">
<exclude-pattern>tests/Doctrine/Tests/DBAL/Tools/TestAsset/*</exclude-pattern>
</rule>
<!-- see https://github.com/squizlabs/PHP_CodeSniffer/issues/2165 -->
<rule ref="Squiz.Arrays.ArrayDeclaration.SpaceBeforeComma">
<exclude-pattern>tests/Doctrine/Tests/DBAL/SQLParserUtilsTest.php</exclude-pattern>
</rule>
</ruleset>
......@@ -12,36 +12,26 @@ 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',
'password' => 'database_password',
'host' => 'database_host',
'driver' => 'database_driver',
];
'dbname' => 'database_name',
'user' => 'database_user',
'password' => 'database_password',
'host' => 'database_host',
'driver' => 'database_driver',
];
protected function setUp()
{
......@@ -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,
......
<?php
/*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the MIT license. For more information, see
* <http://www.doctrine-project.org>.
*/
namespace Doctrine\Tests\DBAL;
......@@ -24,15 +7,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}
......@@ -49,14 +51,14 @@ class DBALExceptionTest extends DbalTestCase
{
}
};
$ex = new DriverException('', $inner);
$e = DBALException::driverExceptionDuringQuery($driver, $ex, '');
$ex = new DriverException('', $inner);
$e = DBALException::driverExceptionDuringQuery($driver, $ex, '');
self::assertSame($ex, $e);
}
public function testDriverRequiredWithUrl()
{
$url = 'mysql://localhost';
$url = 'mysql://localhost';
$exception = DBALException::driverRequired($url);
self::assertInstanceOf(DBALException::class, $exception);
......@@ -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,6 +3,7 @@
namespace Doctrine\Tests\DBAL\Driver;
use Doctrine\DBAL\Connection;
use Doctrine\DBAL\Driver\AbstractDB2Driver;
use Doctrine\DBAL\Platforms\DB2Platform;
use Doctrine\DBAL\Schema\DB2SchemaManager;
......@@ -10,7 +11,7 @@ class AbstractDB2DriverTest extends AbstractDriverTest
{
protected function createDriver()
{
return $this->getMockForAbstractClass('Doctrine\DBAL\Driver\AbstractDB2Driver');
return $this->getMockForAbstractClass(AbstractDB2Driver::class);
}
protected function createPlatform()
......
......@@ -3,11 +3,13 @@
namespace Doctrine\Tests\DBAL\Driver;
use Doctrine\DBAL\Connection;
use Doctrine\DBAL\Driver\AbstractMySQLDriver;
use Doctrine\DBAL\Platforms\MariaDb1027Platform;
use Doctrine\DBAL\Platforms\MySQL57Platform;
use Doctrine\DBAL\Platforms\MySQL80Platform;
use Doctrine\DBAL\Platforms\MySqlPlatform;
use Doctrine\DBAL\Schema\MySqlSchemaManager;
use Doctrine\Tests\Mocks\DriverResultStatementMock;
class AbstractMySQLDriverTest extends AbstractDriverTest
{
......@@ -16,12 +18,12 @@ class AbstractMySQLDriverTest extends AbstractDriverTest
parent::testReturnsDatabaseName();
$database = 'bloo';
$params = array(
$params = [
'user' => 'foo',
'password' => 'bar',
);
];
$statement = $this->createMock('Doctrine\Tests\Mocks\DriverResultStatementMock');
$statement = $this->createMock(DriverResultStatementMock::class);
$statement->expects($this->once())
->method('fetchColumn')
......@@ -42,7 +44,7 @@ class AbstractMySQLDriverTest extends AbstractDriverTest
protected function createDriver()
{
return $this->getMockForAbstractClass('Doctrine\DBAL\Driver\AbstractMySQLDriver');
return $this->getMockForAbstractClass(AbstractMySQLDriver::class);
}
protected function createPlatform()
......@@ -55,6 +57,9 @@ class AbstractMySQLDriverTest extends AbstractDriverTest
return new MySqlSchemaManager($connection);
}
/**
* @return mixed[][]
*/
protected function getDatabasePlatformsForVersions() : array
{
return [
......@@ -74,85 +79,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
......
......@@ -3,6 +3,7 @@
namespace Doctrine\Tests\DBAL\Driver;
use Doctrine\DBAL\Connection;
use Doctrine\DBAL\Driver\AbstractOracleDriver;
use Doctrine\DBAL\Platforms\OraclePlatform;
use Doctrine\DBAL\Schema\OracleSchemaManager;
......@@ -10,11 +11,11 @@ class AbstractOracleDriverTest extends AbstractDriverTest
{
public function testReturnsDatabaseName()
{
$params = array(
$params = [
'user' => 'foo',
'password' => 'bar',
'dbname' => 'baz',
);
];
$connection = $this->getConnectionMock();
......@@ -27,13 +28,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();
......@@ -46,7 +47,7 @@ class AbstractOracleDriverTest extends AbstractDriverTest
protected function createDriver()
{
return $this->getMockForAbstractClass('Doctrine\DBAL\Driver\AbstractOracleDriver');
return $this->getMockForAbstractClass(AbstractOracleDriver::class);
}
protected function createPlatform()
......@@ -61,38 +62,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],
],
];
}
}
......@@ -3,9 +3,14 @@
namespace Doctrine\Tests\DBAL\Driver;
use Doctrine\DBAL\Connection;
use Doctrine\DBAL\Driver\AbstractPostgreSQLDriver;
use Doctrine\DBAL\Platforms\PostgreSQL100Platform;
use Doctrine\DBAL\Platforms\PostgreSQL91Platform;
use Doctrine\DBAL\Platforms\PostgreSQL92Platform;
use Doctrine\DBAL\Platforms\PostgreSQL94Platform;
use Doctrine\DBAL\Platforms\PostgreSqlPlatform;
use Doctrine\DBAL\Schema\PostgreSqlSchemaManager;
use Doctrine\Tests\Mocks\DriverResultStatementMock;
class AbstractPostgreSQLDriverTest extends AbstractDriverTest
{
......@@ -14,12 +19,12 @@ class AbstractPostgreSQLDriverTest extends AbstractDriverTest
parent::testReturnsDatabaseName();
$database = 'bloo';
$params = array(
$params = [
'user' => 'foo',
'password' => 'bar',
);
];
$statement = $this->createMock('Doctrine\Tests\Mocks\DriverResultStatementMock');
$statement = $this->createMock(DriverResultStatementMock::class);
$statement->expects($this->once())
->method('fetchColumn')
......@@ -40,7 +45,7 @@ class AbstractPostgreSQLDriverTest extends AbstractDriverTest
protected function createDriver()
{
return $this->getMockForAbstractClass('Doctrine\DBAL\Driver\AbstractPostgreSQLDriver');
return $this->getMockForAbstractClass(AbstractPostgreSQLDriver::class);
}
protected function createPlatform()
......@@ -55,57 +60,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', PostgreSqlPlatform::class],
['9.1', PostgreSQL91Platform::class],
['9.1.0', PostgreSQL91Platform::class],
['9.1.1', PostgreSQL91Platform::class],
['9.1.9', PostgreSQL91Platform::class],
['9.2', PostgreSQL92Platform::class],
['9.2.0', PostgreSQL92Platform::class],
['9.2.1', PostgreSQL92Platform::class],
['9.3.6', PostgreSQL92Platform::class],
['9.4', PostgreSQL94Platform::class],
['9.4.0', PostgreSQL94Platform::class],
['9.4.1', PostgreSQL94Platform::class],
['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],
],
];
}
}
......@@ -3,14 +3,18 @@
namespace Doctrine\Tests\DBAL\Driver;
use Doctrine\DBAL\Connection;
use Doctrine\DBAL\Driver\AbstractSQLAnywhereDriver;
use Doctrine\DBAL\Platforms\SQLAnywhere11Platform;
use Doctrine\DBAL\Platforms\SQLAnywhere12Platform;
use Doctrine\DBAL\Platforms\SQLAnywhere16Platform;
use Doctrine\DBAL\Platforms\SQLAnywherePlatform;
use Doctrine\DBAL\Schema\SQLAnywhereSchemaManager;
class AbstractSQLAnywhereDriverTest extends AbstractDriverTest
{
protected function createDriver()
{
return $this->getMockForAbstractClass('Doctrine\DBAL\Driver\AbstractSQLAnywhereDriver');
return $this->getMockForAbstractClass(AbstractSQLAnywhereDriver::class);
}
protected function createPlatform()
......@@ -25,84 +29,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', SQLAnywherePlatform::class],
['10.0', SQLAnywherePlatform::class],
['10.0.0', SQLAnywherePlatform::class],
['10.0.0.0', SQLAnywherePlatform::class],
['10.1.2.3', SQLAnywherePlatform::class],
['10.9.9.9', SQLAnywherePlatform::class],
['11', SQLAnywhere11Platform::class],
['11.0', SQLAnywhere11Platform::class],
['11.0.0', SQLAnywhere11Platform::class],
['11.0.0.0', SQLAnywhere11Platform::class],
['11.1.2.3', SQLAnywhere11Platform::class],
['11.9.9.9', SQLAnywhere11Platform::class],
['12', SQLAnywhere12Platform::class],
['12.0', SQLAnywhere12Platform::class],
['12.0.0', SQLAnywhere12Platform::class],
['12.0.0.0', SQLAnywhere12Platform::class],
['12.1.2.3', SQLAnywhere12Platform::class],
['12.9.9.9', SQLAnywhere12Platform::class],
['13', SQLAnywhere12Platform::class],
['14', SQLAnywhere12Platform::class],
['15', SQLAnywhere12Platform::class],
['15.9.9.9', SQLAnywhere12Platform::class],
['16', SQLAnywhere16Platform::class],
['16.0', SQLAnywhere16Platform::class],
['16.0.0', SQLAnywhere16Platform::class],
['16.0.0.0', SQLAnywhere16Platform::class],
['16.1.2.3', SQLAnywhere16Platform::class],
['16.9.9.9', SQLAnywhere16Platform::class],
['17', SQLAnywhere16Platform::class],
];
}
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],
],
];
}
}
......@@ -3,14 +3,18 @@
namespace Doctrine\Tests\DBAL\Driver;
use Doctrine\DBAL\Connection;
use Doctrine\DBAL\Driver\AbstractSQLServerDriver;
use Doctrine\DBAL\Platforms\SQLServer2005Platform;
use Doctrine\DBAL\Platforms\SQLServer2008Platform;
use Doctrine\DBAL\Platforms\SQLServer2012Platform;
use Doctrine\DBAL\Platforms\SQLServerPlatform;
use Doctrine\DBAL\Schema\SQLServerSchemaManager;
class AbstractSQLServerDriverTest extends AbstractDriverTest
{
protected function createDriver()
{
return $this->getMockForAbstractClass('Doctrine\DBAL\Driver\AbstractSQLServerDriver');
return $this->getMockForAbstractClass(AbstractSQLServerDriver::class);
}
protected function createPlatform()
......@@ -25,33 +29,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', SQLServerPlatform::class],
['9.00', SQLServerPlatform::class],
['9.00.0', SQLServerPlatform::class],
['9.00.1398', SQLServerPlatform::class],
['9.00.1398.99', SQLServerPlatform::class],
['9.00.1399', SQLServer2005Platform::class],
['9.00.1399.0', SQLServer2005Platform::class],
['9.00.1399.99', SQLServer2005Platform::class],
['9.00.1400', SQLServer2005Platform::class],
['9.10', SQLServer2005Platform::class],
['9.10.9999', SQLServer2005Platform::class],
['10.00.1599', SQLServer2005Platform::class],
['10.00.1599.99', SQLServer2005Platform::class],
['10.00.1600', SQLServer2008Platform::class],
['10.00.1600.0', SQLServer2008Platform::class],
['10.00.1600.99', SQLServer2008Platform::class],
['10.00.1601', SQLServer2008Platform::class],
['10.10', SQLServer2008Platform::class],
['10.10.9999', SQLServer2008Platform::class],
['11.00.2099', SQLServer2008Platform::class],
['11.00.2099.99', SQLServer2008Platform::class],
['11.00.2100', SQLServer2012Platform::class],
['11.00.2100.0', SQLServer2012Platform::class],
['11.00.2100.99', SQLServer2012Platform::class],
['11.00.2101', SQLServer2012Platform::class],
['12', SQLServer2012Platform::class],
];
}
}
......@@ -3,6 +3,7 @@
namespace Doctrine\Tests\DBAL\Driver;
use Doctrine\DBAL\Connection;
use Doctrine\DBAL\Driver\AbstractSQLiteDriver;
use Doctrine\DBAL\Platforms\SqlitePlatform;
use Doctrine\DBAL\Schema\SqliteSchemaManager;
......@@ -10,12 +11,12 @@ class AbstractSQLiteDriverTest extends AbstractDriverTest
{
public function testReturnsDatabaseName()
{
$params = array(
$params = [
'user' => 'foo',
'password' => 'bar',
'dbname' => 'baz',
'path' => 'bloo',
);
];
$connection = $this->getConnectionMock();
......@@ -28,7 +29,7 @@ class AbstractSQLiteDriverTest extends AbstractDriverTest
protected function createDriver()
{
return $this->getMockForAbstractClass('Doctrine\DBAL\Driver\AbstractSQLiteDriver');
return $this->getMockForAbstractClass(AbstractSQLiteDriver::class);
}
protected function createPlatform()
......@@ -43,39 +44,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'],
],
];
}
}
......@@ -35,12 +35,15 @@ class DriverTest extends PDOMySQLDriverTest
return new DrizzleSchemaManager($connection);
}
/**
* @return mixed[][]
*/
protected function getDatabasePlatformsForVersions() : array
{
return [
['foo', 'Doctrine\DBAL\Platforms\DrizzlePlatform'],
['bar', 'Doctrine\DBAL\Platforms\DrizzlePlatform'],
['baz', 'Doctrine\DBAL\Platforms\DrizzlePlatform'],
['foo', DrizzlePlatform::class],
['bar', DrizzlePlatform::class],
['baz', DrizzlePlatform::class],
];
}
}
......@@ -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,19 +12,19 @@ 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.');
}
parent::setUp();
$this->connectionMock = $this->getMockBuilder('Doctrine\DBAL\Driver\IBMDB2\DB2Connection')
$this->connectionMock = $this->getMockBuilder(DB2Connection::class)
->disableOriginalConstructor()
->getMockForAbstractClass();
}
......
......@@ -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,19 +16,19 @@ 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.');
}
parent::setUp();
if (! $this->_conn->getDatabasePlatform() instanceof MySqlPlatform) {
if (! $this->connection->getDatabasePlatform() instanceof MySqlPlatform) {
$this->markTestSkipped('MySQL only test.');
}
......@@ -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,19 +12,19 @@ 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.');
}
parent::setUp();
$this->connectionMock = $this->getMockBuilder('Doctrine\DBAL\Driver\OCI8\OCI8Connection')
$this->connectionMock = $this->getMockBuilder(OCI8Connection::class)
->disableOriginalConstructor()
->getMockForAbstractClass();
}
......
......@@ -2,16 +2,18 @@
namespace Doctrine\Tests\DBAL\Driver\OCI8;
use Doctrine\DBAL\Driver\OCI8\OCI8Connection;
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.');
}
......@@ -27,13 +29,15 @@ class OCI8StatementTest extends DbalTestCase
*
* The expected exception is due to oci_execute failing due to no valid connection.
*
* @param mixed[] $params
*
* @dataProvider executeDataProvider
* @expectedException \Doctrine\DBAL\Driver\OCI8\OCI8Exception
*/
public function testExecute(array $params)
{
$statement = $this->getMockBuilder('\Doctrine\DBAL\Driver\OCI8\OCI8Statement')
->setMethods(array('bindValue', 'errorInfo'))
$statement = $this->getMockBuilder(OCI8Statement::class)
->setMethods(['bindValue', 'errorInfo'])
->disableOriginalConstructor()
->getMock();
......@@ -54,18 +58,18 @@ class OCI8StatementTest extends DbalTestCase
->with(
$this->equalTo(3),
$this->equalTo($params[2])
);
);
// 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'))
$conn = $this->getMockBuilder(OCI8Connection::class)
->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 +78,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 +102,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);
}
......
......@@ -2,10 +2,12 @@
namespace Doctrine\Tests\DBAL\Driver\PDOPgSql;
use Doctrine\DBAL\Driver\PDOConnection;
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,15 +25,15 @@ 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']
);
self::assertInstanceOf('Doctrine\DBAL\Driver\PDOConnection', $connection);
self::assertInstanceOf(PDOConnection::class, $connection);
try {
self::assertTrue($connection->getAttribute(PDO::PGSQL_ATTR_DISABLE_PREPARES));
......@@ -49,16 +51,16 @@ 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);
self::assertInstanceOf(PDOConnection::class, $connection);
try {
self::assertNotSame(true, $connection->getAttribute(PDO::PGSQL_ATTR_DISABLE_PREPARES));
......@@ -76,16 +78,16 @@ 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);
self::assertInstanceOf(PDOConnection::class, $connection);
try {
self::assertTrue($connection->getAttribute(PDO::PGSQL_ATTR_DISABLE_PREPARES));
......@@ -104,7 +106,7 @@ class DriverTest extends AbstractPostgreSQLDriverTest
}
/**
* @throws \PHPUnit_Framework_SkippedTestError
* @throws PHPUnit_Framework_SkippedTestError
*/
private function skipWhenNotUsingPhp56AndPdoPgsql()
{
......@@ -112,8 +114,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,19 +12,19 @@ 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.');
}
parent::setUp();
$this->connectionMock = $this->getMockBuilder('Doctrine\DBAL\Driver\SQLAnywhere\SQLAnywhereConnection')
$this->connectionMock = $this->getMockBuilder(SQLAnywhereConnection::class)
->disableOriginalConstructor()
->getMockForAbstractClass();
}
......
......@@ -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,19 +12,19 @@ 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.');
}
parent::setUp();
$this->connectionMock = $this->getMockBuilder('Doctrine\DBAL\Driver\SQLSrv\SQLSrvConnection')
$this->connectionMock = $this->getMockBuilder(SQLSrvConnection::class)
->disableOriginalConstructor()
->getMockForAbstractClass();
}
......
......@@ -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()
......@@ -58,11 +59,11 @@ class StatementIteratorTest extends \Doctrine\Tests\DbalTestCase
private function configureStatement(MockObject $stmt, int &$calls) : void
{
$values = ['foo', '', 'bar', '0', 'baz', 0, 'qux', null, 'quz', false, 'impossible'];
$calls = 0;
$calls = 0;
$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];
......
......@@ -2,6 +2,7 @@
namespace Doctrine\Tests\DBAL\Events;
use Doctrine\DBAL\Connection;
use Doctrine\DBAL\Event\ConnectionEventArgs;
use Doctrine\DBAL\Event\Listeners\MysqlSessionInit;
use Doctrine\DBAL\Events;
......@@ -11,14 +12,13 @@ class MysqlSessionInitTest extends DbalTestCase
{
public function testPostConnect()
{
$connectionMock = $this->createMock('Doctrine\DBAL\Connection');
$connectionMock = $this->createMock(Connection::class);
$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 +26,6 @@ class MysqlSessionInitTest extends DbalTestCase
public function testGetSubscribedEvents()
{
$listener = new MysqlSessionInit();
self::assertEquals(array(Events::postConnect), $listener->getSubscribedEvents());
self::assertEquals([Events::postConnect], $listener->getSubscribedEvents());
}
}
......@@ -2,6 +2,7 @@
namespace Doctrine\Tests\DBAL\Events;
use Doctrine\DBAL\Connection;
use Doctrine\DBAL\Event\ConnectionEventArgs;
use Doctrine\DBAL\Event\Listeners\OracleSessionInit;
use Doctrine\DBAL\Events;
......@@ -12,26 +13,24 @@ class OracleSessionInitTest extends DbalTestCase
{
public function testPostConnect()
{
$connectionMock = $this->createMock('Doctrine\DBAL\Connection');
$connectionMock = $this->createMock(Connection::class);
$connectionMock->expects($this->once())
->method('executeUpdate')
->with($this->isType('string'));
$eventArgs = new ConnectionEventArgs($connectionMock);
$listener = new OracleSessionInit();
$listener->postConnect($eventArgs);
}
/**
* @group DBAL-1824
*
* @dataProvider getPostConnectWithSessionParameterValuesData
*/
public function testPostConnectQuotesSessionParameterValues($name, $value)
{
$connectionMock = $this->getMockBuilder('Doctrine\DBAL\Connection')
$connectionMock = $this->getMockBuilder(Connection::class)
->disableOriginalConstructor()
->getMock();
$connectionMock->expects($this->once())
......@@ -40,21 +39,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());
}
}
......@@ -2,6 +2,7 @@
namespace Doctrine\Tests\DBAL\Events;
use Doctrine\DBAL\Connection;
use Doctrine\DBAL\Event\ConnectionEventArgs;
use Doctrine\DBAL\Event\Listeners\SQLSessionInit;
use Doctrine\DBAL\Events;
......@@ -14,7 +15,7 @@ class SQLSessionInitTest extends DbalTestCase
{
public function testPostConnect()
{
$connectionMock = $this->createMock('Doctrine\DBAL\Connection');
$connectionMock = $this->createMock(Connection::class);
$connectionMock->expects($this->once())
->method('exec')
->with($this->equalTo("SET SEARCH_PATH TO foo, public, TIMEZONE TO 'Europe/Berlin'"));
......@@ -28,6 +29,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());
}
}
<?php
/*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* This software consists of voluntary contributions made by many individuals
* and is licensed under the MIT license. For more information, see
* <http://www.doctrine-project.org>.
*/
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()
{
$exception = InvalidArgumentException::fromEmptyCriteria();
self::assertInstanceOf('Doctrine\DBAL\Exception\InvalidArgumentException', $exception);
self::assertInstanceOf(InvalidArgumentException::class, $exception);
self::assertSame('Empty criteria was used, expected non-empty criteria', $exception->getMessage());
}
}
......@@ -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,30 +17,30 @@ use function stream_get_contents;
/**
* @group DBAL-6
*/
class BlobTest extends \Doctrine\Tests\DbalFunctionalTestCase
class BlobTest extends DbalFunctionalTestCase
{
protected function setUp()
{
parent::setUp();
if ($this->_conn->getDriver() instanceof PDOSQLSrvDriver) {
if ($this->connection->getDriver() instanceof PDOSQLSrvDriver) {
$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');
$table->addColumn('blobfield', 'blob');
$table->setPrimaryKey(['id']);
$sm = $this->_conn->getSchemaManager();
$sm = $this->connection->getSchemaManager();
$sm->dropAndCreateTable($table);
}
public function testInsert()
{
$ret = $this->_conn->insert('blob_table', [
$ret = $this->connection->insert('blob_table', [
'id' => 1,
'clobfield' => 'test',
'blobfield' => 'test',
......@@ -53,14 +55,14 @@ class BlobTest extends \Doctrine\Tests\DbalFunctionalTestCase
public function testInsertProcessesStream()
{
if (in_array($this->_conn->getDatabasePlatform()->getName(), ['oracle', 'db2'], true)) {
if (in_array($this->connection->getDatabasePlatform()->getName(), ['oracle', 'db2'], true)) {
// https://github.com/doctrine/dbal/issues/3288 for DB2
// https://github.com/doctrine/dbal/issues/3290 for Oracle
$this->markTestIncomplete('Platform does not support stream resources as parameters');
}
$longBlob = str_repeat('x', 4 * 8192); // send 4 chunks
$this->_conn->insert('blob_table', [
$this->connection->insert('blob_table', [
'id' => 1,
'clobfield' => 'ignored',
'blobfield' => fopen('data://text/plain,' . $longBlob, 'r'),
......@@ -75,7 +77,7 @@ class BlobTest extends \Doctrine\Tests\DbalFunctionalTestCase
public function testSelect()
{
$this->_conn->insert('blob_table', [
$this->connection->insert('blob_table', [
'id' => 1,
'clobfield' => 'test',
'blobfield' => 'test',
......@@ -90,7 +92,7 @@ class BlobTest extends \Doctrine\Tests\DbalFunctionalTestCase
public function testUpdate()
{
$this->_conn->insert('blob_table', [
$this->connection->insert('blob_table', [
'id' => 1,
'clobfield' => 'test',
'blobfield' => 'test',
......@@ -100,9 +102,7 @@ class BlobTest extends \Doctrine\Tests\DbalFunctionalTestCase
ParameterType::LARGE_OBJECT,
]);
$this->_conn->update('blob_table', [
'blobfield' => 'test2',
], ['id' => 1], [
$this->connection->update('blob_table', ['blobfield' => 'test2'], ['id' => 1], [
ParameterType::LARGE_OBJECT,
ParameterType::INTEGER,
]);
......@@ -112,13 +112,13 @@ class BlobTest extends \Doctrine\Tests\DbalFunctionalTestCase
public function testUpdateProcessesStream()
{
if (in_array($this->_conn->getDatabasePlatform()->getName(), ['oracle', 'db2'], true)) {
if (in_array($this->connection->getDatabasePlatform()->getName(), ['oracle', 'db2'], true)) {
// https://github.com/doctrine/dbal/issues/3288 for DB2
// https://github.com/doctrine/dbal/issues/3290 for Oracle
$this->markTestIncomplete('Platform does not support stream resources as parameters');
}
$this->_conn->insert('blob_table', [
$this->connection->insert('blob_table', [
'id' => 1,
'clobfield' => 'ignored',
'blobfield' => 'test',
......@@ -128,7 +128,7 @@ class BlobTest extends \Doctrine\Tests\DbalFunctionalTestCase
ParameterType::LARGE_OBJECT,
]);
$this->_conn->update('blob_table', [
$this->connection->update('blob_table', [
'id' => 1,
'blobfield' => fopen('data://text/plain,test2', 'r'),
], ['id' => 1], [
......@@ -141,13 +141,13 @@ class BlobTest extends \Doctrine\Tests\DbalFunctionalTestCase
public function testBindParamProcessesStream()
{
if (in_array($this->_conn->getDatabasePlatform()->getName(), ['oracle', 'db2'], true)) {
if (in_array($this->connection->getDatabasePlatform()->getName(), ['oracle', 'db2'], true)) {
// https://github.com/doctrine/dbal/issues/3288 for DB2
// https://github.com/doctrine/dbal/issues/3290 for Oracle
$this->markTestIncomplete('Platform does not support stream resources as parameters');
}
$stmt = $this->_conn->prepare("INSERT INTO blob_table(id, clobfield, blobfield) VALUES (1, 'ignored', ?)");
$stmt = $this->connection->prepare("INSERT INTO blob_table(id, clobfield, blobfield) VALUES (1, 'ignored', ?)");
$stream = null;
$stmt->bindParam(1, $stream, ParameterType::LARGE_OBJECT);
......@@ -162,11 +162,11 @@ class BlobTest extends \Doctrine\Tests\DbalFunctionalTestCase
private function assertBlobContains($text)
{
$rows = $this->_conn->query('SELECT blobfield FROM blob_table')->fetchAll(FetchMode::COLUMN);
$rows = $this->connection->query('SELECT blobfield FROM blob_table')->fetchAll(FetchMode::COLUMN);
self::assertCount(1, $rows);
$blobValue = Type::getType('blob')->convertToPHPValue($rows[0], $this->_conn->getDatabasePlatform());
$blobValue = Type::getType('blob')->convertToPHPValue($rows[0], $this->connection->getDatabasePlatform());
self::assertInternalType('resource', $blobValue);
self::assertEquals($text, stream_get_contents($blobValue));
......
......@@ -3,6 +3,8 @@
namespace Doctrine\Tests\DBAL\Functional\Driver;
use Doctrine\DBAL\Connection;
use Doctrine\DBAL\Driver;
use Doctrine\DBAL\Driver\Connection as DriverConnection;
use Doctrine\Tests\DbalFunctionalTestCase;
abstract class AbstractDriverTest extends DbalFunctionalTestCase
......@@ -10,7 +12,7 @@ abstract class AbstractDriverTest extends DbalFunctionalTestCase
/**
* The driver instance under test.
*
* @var \Doctrine\DBAL\Driver
* @var Driver
*/
protected $driver;
......@@ -26,15 +28,15 @@ abstract class AbstractDriverTest extends DbalFunctionalTestCase
*/
public function testConnectsWithoutDatabaseNameParameter()
{
$params = $this->_conn->getParams();
$params = $this->connection->getParams();
unset($params['dbname']);
$user = $params['user'] ?? null;
$user = $params['user'] ?? null;
$password = $params['password'] ?? null;
$connection = $this->driver->connect($params, $user, $password);
self::assertInstanceOf('Doctrine\DBAL\Driver\Connection', $connection);
self::assertInstanceOf(DriverConnection::class, $connection);
}
/**
......@@ -42,14 +44,14 @@ abstract class AbstractDriverTest extends DbalFunctionalTestCase
*/
public function testReturnsDatabaseNameWithoutDatabaseNameParameter()
{
$params = $this->_conn->getParams();
$params = $this->connection->getParams();
unset($params['dbname']);
$connection = new Connection(
$params,
$this->_conn->getDriver(),
$this->_conn->getConfiguration(),
$this->_conn->getEventManager()
$this->connection->getDriver(),
$this->connection->getConfiguration(),
$this->connection->getEventManager()
);
self::assertSame(
......@@ -59,7 +61,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->connection->getDriver() instanceof DB2Driver) {
return;
}
$this->markTestSkipped('ibm_db2 only test.');
}
/**
......
......@@ -13,20 +13,22 @@ 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->connection->getDriver() instanceof DB2Driver) {
return;
}
$this->markTestSkipped('ibm_db2 only test.');
}
public function testExecutionErrorsAreNotSuppressed()
{
$stmt = $this->_conn->prepare('SELECT * FROM SYSIBM.SYSDUMMY1 WHERE \'foo\' = ?');
$stmt = $this->connection->prepare('SELECT * FROM SYSIBM.SYSDUMMY1 WHERE \'foo\' = ?');
// unwrap the statement to prevent the wrapper from handling the PHPUnit-originated exception
$wrappedStmt = $stmt->getWrappedStatement();
......
<?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->connection->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(MysqliConnection::class, $connection);
}
/**
......@@ -37,22 +43,25 @@ 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());
}
/**
* @param mixed[] $driverOptions
*/
private function getConnection(array $driverOptions)
{
return new \Doctrine\DBAL\Driver\Mysqli\MysqliConnection(
array(
'host' => $GLOBALS['db_host'],
'dbname' => $GLOBALS['db_name'],
),
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->connection->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->connection->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()
......@@ -22,11 +21,11 @@ class OCI8ConnectionTest extends DbalFunctionalTestCase
parent::setUp();
if (! $this->_conn->getDriver() instanceof Driver) {
if (! $this->connection->getDriver() instanceof Driver) {
$this->markTestSkipped('oci8 only test.');
}
$this->driverConnection = $this->_conn->getWrappedConnection();
$this->driverConnection = $this->connection->getWrappedConnection();
}
/**
......@@ -34,18 +33,18 @@ class OCI8ConnectionTest extends DbalFunctionalTestCase
*/
public function testLastInsertIdAcceptsFqn()
{
$platform = $this->_conn->getDatabasePlatform();
$schemaManager = $this->_conn->getSchemaManager();
$platform = $this->connection->getDatabasePlatform();
$schemaManager = $this->connection->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);
$this->_conn->executeUpdate('INSERT INTO DBAL2595 (foo) VALUES (1)');
$this->connection->executeUpdate('INSERT INTO DBAL2595 (foo) VALUES (1)');
$schema = $this->_conn->getDatabase();
$schema = $this->connection->getDatabase();
$sequence = $platform->getIdentitySequenceName($schema . '.DBAL2595', 'id');
self::assertSame(1, $this->driverConnection->lastInsertId($sequence));
......
......@@ -16,71 +16,70 @@ class StatementTest extends DbalFunctionalTestCase
parent::setUp();
if (! $this->_conn->getDriver() instanceof Driver) {
$this->markTestSkipped('oci8 only test.');
if ($this->connection->getDriver() instanceof Driver) {
return;
}
$this->markTestSkipped('oci8 only test.');
}
/**
* @param mixed[] $params
* @param mixed[] $expected
*
* @dataProvider queryConversionProvider
*/
public function testQueryConversion($query, array $params, array $expected)
{
self::assertEquals(
$expected,
$this->_conn->executeQuery($query, $params)->fetch()
$this->connection->executeQuery($query, $params)->fetch()
);
}
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,23 +13,25 @@ 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.');
}
parent::setUp();
$this->driverConnection = $this->_conn->getWrappedConnection();
$this->driverConnection = $this->connection->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()
......@@ -66,13 +68,13 @@ class PDOConnectionTest extends DbalFunctionalTestCase
*/
public function testThrowsWrappedExceptionOnPrepare()
{
if ($this->_conn->getDriver()->getName() === 'pdo_sqlsrv') {
if ($this->connection->getDriver()->getName() === 'pdo_sqlsrv') {
$this->markTestSkipped('pdo_sqlsrv does not allow setting PDO::ATTR_EMULATE_PREPARES at connection level.');
}
// 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');
......@@ -84,7 +86,7 @@ class PDOConnectionTest extends DbalFunctionalTestCase
sprintf(
'The PDO adapter %s does not check the query to be prepared server-side, ' .
'so no assertions can be made.',
$this->_conn->getDriver()->getName()
$this->connection->getDriver()->getName()
)
);
}
......
......@@ -16,9 +16,11 @@ class DriverTest extends AbstractDriverTest
parent::setUp();
if (! $this->_conn->getDriver() instanceof Driver) {
$this->markTestSkipped('pdo_mysql only test.');
if ($this->connection->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->connection->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->connection->getDriver() instanceof Driver) {
return;
}
$this->markTestSkipped('pdo_pgsql only test.');
}
/**
......@@ -31,15 +33,15 @@ class DriverTest extends AbstractDriverTest
*/
public function testDatabaseParameters($databaseName, $defaultDatabaseName, $expectedDatabaseName)
{
$params = $this->_conn->getParams();
$params['dbname'] = $databaseName;
$params = $this->connection->getParams();
$params['dbname'] = $databaseName;
$params['default_dbname'] = $defaultDatabaseName;
$connection = new Connection(
$params,
$this->_conn->getDriver(),
$this->_conn->getConfiguration(),
$this->_conn->getEventManager()
$this->connection->getDriver(),
$this->connection->getConfiguration(),
$this->connection->getEventManager()
);
self::assertSame(
......@@ -50,17 +52,17 @@ class DriverTest extends AbstractDriverTest
public function getDatabaseParameter()
{
$params = TestUtil::getConnection()->getParams();
$realDatabaseName = $params['dbname'] ?? '';
$params = TestUtil::getConnection()->getParams();
$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()],
];
}
/**
......@@ -68,18 +70,18 @@ class DriverTest extends AbstractDriverTest
*/
public function testConnectsWithApplicationNameParameter()
{
$parameters = $this->_conn->getParams();
$parameters = $this->connection->getParams();
$parameters['application_name'] = 'doctrine';
$user = $parameters['user'] ?? null;
$user = $parameters['user'] ?? null;
$password = $parameters['password'] ?? null;
$connection = $this->driver->connect($parameters, $user, $password);
$hash = microtime(true); // required to identify the record in the results uniquely
$sql = sprintf('SELECT * FROM pg_stat_activity WHERE %d = %d', $hash, $hash);
$hash = microtime(true); // required to identify the record in the results uniquely
$sql = sprintf('SELECT * FROM pg_stat_activity WHERE %d = %d', $hash, $hash);
$statement = $connection->query($sql);
$records = $statement->fetchAll();
$records = $statement->fetchAll();
foreach ($records as $record) {
// The query column is named "current_query" on PostgreSQL < 9.2
......
......@@ -12,34 +12,35 @@ 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->connection->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)
{
$params = $this->_conn->getParams();
$params = $this->connection->getParams();
$params['charset'] = $charset;
$connection = DriverManager::getConnection(
$params,
$this->_conn->getConfiguration(),
$this->_conn->getEventManager()
$this->connection->getConfiguration(),
$this->connection->getEventManager()
);
self::assertEquals(
......@@ -50,13 +51,13 @@ class PDOPgsqlConnectionTest extends DbalFunctionalTestCase
}
/**
* @return array
* @return mixed[][]
*/
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->connection->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;
......@@ -18,7 +18,7 @@ class DriverTest extends AbstractDriverTest
parent::setUp();
if ($this->_conn->getDriver() instanceof Driver) {
if ($this->connection->getDriver() instanceof Driver) {
return;
}
......@@ -46,7 +46,7 @@ class DriverTest extends AbstractDriverTest
*/
protected function getConnection(array $driverOptions) : Connection
{
return $this->_conn->getDriver()->connect(
return $this->connection->getDriver()->connect(
[
'host' => $GLOBALS['db_host'],
'port' => $GLOBALS['db_port'],
......
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.
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