Enforced parameter and return value types in test classes

parent a2450fb0
......@@ -15,14 +15,20 @@
<rule ref="Doctrine">
<exclude name="SlevomatCodingStandard.TypeHints.DeclareStrictTypes"/>
<exclude name="SlevomatCodingStandard.TypeHints.TypeHintDeclaration.MissingParameterTypeHint"/>
<exclude name="SlevomatCodingStandard.TypeHints.TypeHintDeclaration.MissingReturnTypeHint"/>
<exclude name="SlevomatCodingStandard.Classes.SuperfluousAbstractClassNaming"/>
<exclude name="SlevomatCodingStandard.Classes.SuperfluousExceptionNaming"/>
<exclude name="SlevomatCodingStandard.ControlStructures.ControlStructureSpacing.IncorrectLinesCountAfterLastControlStructure"/>
<exclude name="SlevomatCodingStandard.Classes.DisallowLateStaticBindingForConstants.DisallowedLateStaticBindingForConstant"/>
</rule>
<rule ref="SlevomatCodingStandard.TypeHints.TypeHintDeclaration.MissingParameterTypeHint">
<exclude-pattern>*/lib/*</exclude-pattern>
</rule>
<rule ref="SlevomatCodingStandard.TypeHints.TypeHintDeclaration.MissingReturnTypeHint">
<exclude-pattern>*/lib/*</exclude-pattern>
</rule>
<rule ref="PSR1.Classes.ClassDeclaration.MultipleClasses">
<exclude-pattern>*/tests/*</exclude-pattern>
</rule>
......@@ -43,6 +49,7 @@
<rule ref="Squiz.Commenting.FunctionComment.InvalidNoReturn">
<exclude-pattern>lib/Doctrine/DBAL/Platforms/AbstractPlatform.php</exclude-pattern>
<exclude-pattern>lib/Doctrine/DBAL/Schema/AbstractSchemaManager.php</exclude-pattern>
<exclude-pattern>tests/Doctrine/Tests/DBAL/Platforms/AbstractPlatformTestCase.php</exclude-pattern>
</rule>
<!-- some statement classes close cursor using an empty while-loop -->
......
......@@ -38,7 +38,7 @@ class QueryCacheProfileTest extends DbalTestCase
$this->queryCacheProfile = new QueryCacheProfile(self::LIFETIME, self::CACHE_KEY);
}
public function testShouldUseTheGivenCacheKeyIfPresent()
public function testShouldUseTheGivenCacheKeyIfPresent() : void
{
[$cacheKey] = $this->queryCacheProfile->generateCacheKeys(
$this->query,
......@@ -50,7 +50,7 @@ class QueryCacheProfileTest extends DbalTestCase
self::assertEquals(self::CACHE_KEY, $cacheKey, 'The returned cache key should match the given one');
}
public function testShouldGenerateAnAutomaticKeyIfNoKeyHasBeenGiven()
public function testShouldGenerateAnAutomaticKeyIfNoKeyHasBeenGiven() : void
{
$this->queryCacheProfile = $this->queryCacheProfile->setCacheKey(null);
......@@ -70,7 +70,7 @@ class QueryCacheProfileTest extends DbalTestCase
self::assertNotEmpty($cacheKey, 'The generated cache key should not be empty');
}
public function testShouldGenerateDifferentKeysForSameQueryAndParamsAndDifferentConnections()
public function testShouldGenerateDifferentKeysForSameQueryAndParamsAndDifferentConnections() : void
{
$this->queryCacheProfile = $this->queryCacheProfile->setCacheKey(null);
......@@ -93,7 +93,7 @@ class QueryCacheProfileTest extends DbalTestCase
self::assertNotEquals($firstCacheKey, $secondCacheKey, 'Cache keys should be different');
}
public function testConnectionParamsShouldBeHashed()
public function testConnectionParamsShouldBeHashed() : void
{
$this->queryCacheProfile = $this->queryCacheProfile->setCacheKey(null);
......@@ -114,7 +114,7 @@ class QueryCacheProfileTest extends DbalTestCase
}
}
public function testShouldGenerateSameKeysIfNoneOfTheParamsChanges()
public function testShouldGenerateSameKeysIfNoneOfTheParamsChanges() : void
{
$this->queryCacheProfile = $this->queryCacheProfile->setCacheKey(null);
......
......@@ -30,7 +30,7 @@ class ConfigurationTest extends DbalTestCase
*
* @group DBAL-81
*/
public function testReturnsDefaultConnectionAutoCommitMode()
public function testReturnsDefaultConnectionAutoCommitMode() : void
{
self::assertTrue($this->config->getAutoCommit());
}
......@@ -40,7 +40,7 @@ class ConfigurationTest extends DbalTestCase
*
* @group DBAL-81
*/
public function testSetsDefaultConnectionAutoCommitMode()
public function testSetsDefaultConnectionAutoCommitMode() : void
{
$this->config->setAutoCommit(false);
......
......@@ -15,7 +15,7 @@ use function sprintf;
class DBALExceptionTest extends DbalTestCase
{
public function testDriverExceptionDuringQueryAcceptsBinaryData()
public function testDriverExceptionDuringQueryAcceptsBinaryData() : void
{
/** @var Driver $driver */
$driver = $this->createMock(Driver::class);
......@@ -23,7 +23,7 @@ class DBALExceptionTest extends DbalTestCase
self::assertStringContainsString('with params ["ABC", "\x80"]', $e->getMessage());
}
public function testDriverExceptionDuringQueryAcceptsResource()
public function testDriverExceptionDuringQueryAcceptsResource() : void
{
/** @var Driver $driver */
$driver = $this->createMock(Driver::class);
......@@ -31,7 +31,7 @@ class DBALExceptionTest extends DbalTestCase
self::assertStringContainsString('Resource', $e->getMessage());
}
public function testAvoidOverWrappingOnDriverException()
public function testAvoidOverWrappingOnDriverException() : void
{
/** @var Driver $driver */
$driver = $this->createMock(Driver::class);
......@@ -44,7 +44,7 @@ class DBALExceptionTest extends DbalTestCase
self::assertSame($ex, $e);
}
public function testDriverRequiredWithUrl()
public function testDriverRequiredWithUrl() : void
{
$url = 'mysql://localhost';
$exception = DBALException::driverRequired($url);
......
......@@ -3,23 +3,26 @@
namespace Doctrine\Tests\DBAL\Driver;
use Doctrine\DBAL\Connection;
use Doctrine\DBAL\Driver;
use Doctrine\DBAL\Driver\AbstractDB2Driver;
use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Platforms\DB2Platform;
use Doctrine\DBAL\Schema\AbstractSchemaManager;
use Doctrine\DBAL\Schema\DB2SchemaManager;
class AbstractDB2DriverTest extends AbstractDriverTest
{
protected function createDriver()
protected function createDriver() : Driver
{
return $this->getMockForAbstractClass(AbstractDB2Driver::class);
}
protected function createPlatform()
protected function createPlatform() : AbstractPlatform
{
return new DB2Platform();
}
protected function createSchemaManager(Connection $connection)
protected function createSchemaManager(Connection $connection) : AbstractSchemaManager
{
return new DB2SchemaManager($connection);
}
......
......@@ -69,9 +69,11 @@ abstract class AbstractDriverTest extends DbalTestCase
}
/**
* @param int|string $errorCode
*
* @dataProvider exceptionConversionProvider
*/
public function testConvertsException($errorCode, $sqlState, $message, string $expectedClass) : void
public function testConvertsException($errorCode, ?string $sqlState, ?string $message, string $expectedClass) : void
{
if (! $this->driver instanceof ExceptionConverterDriver) {
$this->markTestSkipped('This test is only intended for exception converter drivers.');
......@@ -97,7 +99,7 @@ abstract class AbstractDriverTest extends DbalTestCase
self::assertSame($dbalMessage, $dbalException->getMessage());
}
public function testCreatesDatabasePlatformForVersion()
public function testCreatesDatabasePlatformForVersion() : void
{
if (! $this->driver instanceof VersionAwarePlatformDriver) {
$this->markTestSkipped('This test is only intended for version aware platform drivers.');
......@@ -130,7 +132,7 @@ abstract class AbstractDriverTest extends DbalTestCase
}
}
public function testThrowsExceptionOnCreatingDatabasePlatformsForInvalidVersion()
public function testThrowsExceptionOnCreatingDatabasePlatformsForInvalidVersion() : void
{
if (! $this->driver instanceof VersionAwarePlatformDriver) {
$this->markTestSkipped('This test is only intended for version aware platform drivers.');
......@@ -140,7 +142,7 @@ abstract class AbstractDriverTest extends DbalTestCase
$this->driver->createDatabasePlatformForVersion('foo');
}
public function testReturnsDatabaseName()
public function testReturnsDatabaseName() : void
{
$params = [
'user' => 'foo',
......@@ -157,12 +159,12 @@ abstract class AbstractDriverTest extends DbalTestCase
self::assertSame($params['dbname'], $this->driver->getDatabase($connection));
}
public function testReturnsDatabasePlatform()
public function testReturnsDatabasePlatform() : void
{
self::assertEquals($this->createPlatform(), $this->driver->getDatabasePlatform());
}
public function testReturnsSchemaManager()
public function testReturnsSchemaManager() : void
{
$connection = $this->getConnectionMock();
$schemaManager = $this->driver->getSchemaManager($connection);
......@@ -177,20 +179,16 @@ abstract class AbstractDriverTest extends DbalTestCase
/**
* Factory method for creating the driver instance under test.
*
* @return Driver
*/
abstract protected function createDriver();
abstract protected function createDriver() : Driver;
/**
* Factory method for creating the the platform instance return by the driver under test.
*
* The platform instance returned by this method must be the same as returned by
* the driver's getDatabasePlatform() method.
*
* @return AbstractPlatform
*/
abstract protected function createPlatform();
abstract protected function createPlatform() : AbstractPlatform;
/**
* Factory method for creating the the schema manager instance return by the driver under test.
......@@ -199,19 +197,20 @@ abstract class AbstractDriverTest extends DbalTestCase
* the driver's getSchemaManager() method.
*
* @param Connection $connection The underlying connection to use.
*
* @return AbstractSchemaManager
*/
abstract protected function createSchemaManager(Connection $connection);
abstract protected function createSchemaManager(Connection $connection) : AbstractSchemaManager;
protected function getConnectionMock()
protected function getConnectionMock() : Connection
{
return $this->getMockBuilder(Connection::class)
->disableOriginalConstructor()
->getMock();
}
protected function getDatabasePlatformsForVersions()
/**
* @return array<int, array<int, string>>
*/
protected function getDatabasePlatformsForVersions() : array
{
return [];
}
......
......@@ -3,17 +3,20 @@
namespace Doctrine\Tests\DBAL\Driver;
use Doctrine\DBAL\Connection;
use Doctrine\DBAL\Driver;
use Doctrine\DBAL\Driver\AbstractMySQLDriver;
use Doctrine\DBAL\Driver\ResultStatement;
use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Platforms\MariaDb1027Platform;
use Doctrine\DBAL\Platforms\MySQL57Platform;
use Doctrine\DBAL\Platforms\MySQL80Platform;
use Doctrine\DBAL\Platforms\MySqlPlatform;
use Doctrine\DBAL\Schema\AbstractSchemaManager;
use Doctrine\DBAL\Schema\MySqlSchemaManager;
class AbstractMySQLDriverTest extends AbstractDriverTest
{
public function testReturnsDatabaseName()
public function testReturnsDatabaseName() : void
{
parent::testReturnsDatabaseName();
......@@ -42,23 +45,23 @@ class AbstractMySQLDriverTest extends AbstractDriverTest
self::assertSame($database, $this->driver->getDatabase($connection));
}
protected function createDriver()
protected function createDriver() : Driver
{
return $this->getMockForAbstractClass(AbstractMySQLDriver::class);
}
protected function createPlatform()
protected function createPlatform() : AbstractPlatform
{
return new MySqlPlatform();
}
protected function createSchemaManager(Connection $connection)
protected function createSchemaManager(Connection $connection) : AbstractSchemaManager
{
return new MySqlSchemaManager($connection);
}
/**
* @return mixed[][]
* {@inheritDoc}
*/
protected function getDatabasePlatformsForVersions() : array
{
......
......@@ -3,13 +3,16 @@
namespace Doctrine\Tests\DBAL\Driver;
use Doctrine\DBAL\Connection;
use Doctrine\DBAL\Driver;
use Doctrine\DBAL\Driver\AbstractOracleDriver;
use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Platforms\OraclePlatform;
use Doctrine\DBAL\Schema\AbstractSchemaManager;
use Doctrine\DBAL\Schema\OracleSchemaManager;
class AbstractOracleDriverTest extends AbstractDriverTest
{
public function testReturnsDatabaseName()
public function testReturnsDatabaseName() : void
{
$params = [
'user' => 'foo',
......@@ -26,7 +29,7 @@ class AbstractOracleDriverTest extends AbstractDriverTest
self::assertSame($params['user'], $this->driver->getDatabase($connection));
}
public function testReturnsDatabaseNameWithConnectDescriptor()
public function testReturnsDatabaseNameWithConnectDescriptor() : void
{
$params = [
'user' => 'foo',
......@@ -45,17 +48,17 @@ class AbstractOracleDriverTest extends AbstractDriverTest
self::assertSame($params['user'], $this->driver->getDatabase($connection));
}
protected function createDriver()
protected function createDriver() : Driver
{
return $this->getMockForAbstractClass(AbstractOracleDriver::class);
}
protected function createPlatform()
protected function createPlatform() : AbstractPlatform
{
return new OraclePlatform();
}
protected function createSchemaManager(Connection $connection)
protected function createSchemaManager(Connection $connection) : AbstractSchemaManager
{
return new OracleSchemaManager($connection);
}
......
......@@ -3,18 +3,21 @@
namespace Doctrine\Tests\DBAL\Driver;
use Doctrine\DBAL\Connection;
use Doctrine\DBAL\Driver;
use Doctrine\DBAL\Driver\AbstractPostgreSQLDriver;
use Doctrine\DBAL\Driver\ResultStatement;
use Doctrine\DBAL\Platforms\AbstractPlatform;
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\AbstractSchemaManager;
use Doctrine\DBAL\Schema\PostgreSqlSchemaManager;
class AbstractPostgreSQLDriverTest extends AbstractDriverTest
{
public function testReturnsDatabaseName()
public function testReturnsDatabaseName() : void
{
parent::testReturnsDatabaseName();
......@@ -43,22 +46,25 @@ class AbstractPostgreSQLDriverTest extends AbstractDriverTest
self::assertSame($database, $this->driver->getDatabase($connection));
}
protected function createDriver()
protected function createDriver() : Driver
{
return $this->getMockForAbstractClass(AbstractPostgreSQLDriver::class);
}
protected function createPlatform()
protected function createPlatform() : AbstractPlatform
{
return new PostgreSqlPlatform();
}
protected function createSchemaManager(Connection $connection)
protected function createSchemaManager(Connection $connection) : AbstractSchemaManager
{
return new PostgreSqlSchemaManager($connection);
}
protected function getDatabasePlatformsForVersions()
/**
* {@inheritDoc}
*/
protected function getDatabasePlatformsForVersions() : array
{
return [
['9.0.9', PostgreSqlPlatform::class],
......
......@@ -3,31 +3,37 @@
namespace Doctrine\Tests\DBAL\Driver;
use Doctrine\DBAL\Connection;
use Doctrine\DBAL\Driver;
use Doctrine\DBAL\Driver\AbstractSQLAnywhereDriver;
use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Platforms\SQLAnywhere11Platform;
use Doctrine\DBAL\Platforms\SQLAnywhere12Platform;
use Doctrine\DBAL\Platforms\SQLAnywhere16Platform;
use Doctrine\DBAL\Platforms\SQLAnywherePlatform;
use Doctrine\DBAL\Schema\AbstractSchemaManager;
use Doctrine\DBAL\Schema\SQLAnywhereSchemaManager;
class AbstractSQLAnywhereDriverTest extends AbstractDriverTest
{
protected function createDriver()
protected function createDriver() : Driver
{
return $this->getMockForAbstractClass(AbstractSQLAnywhereDriver::class);
}
protected function createPlatform()
protected function createPlatform() : AbstractPlatform
{
return new SQLAnywhere12Platform();
}
protected function createSchemaManager(Connection $connection)
protected function createSchemaManager(Connection $connection) : AbstractSchemaManager
{
return new SQLAnywhereSchemaManager($connection);
}
protected function getDatabasePlatformsForVersions()
/**
* {@inheritDoc}
*/
protected function getDatabasePlatformsForVersions() : array
{
return [
['10', SQLAnywherePlatform::class],
......
......@@ -3,31 +3,37 @@
namespace Doctrine\Tests\DBAL\Driver;
use Doctrine\DBAL\Connection;
use Doctrine\DBAL\Driver;
use Doctrine\DBAL\Driver\AbstractSQLServerDriver;
use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Platforms\SQLServer2005Platform;
use Doctrine\DBAL\Platforms\SQLServer2008Platform;
use Doctrine\DBAL\Platforms\SQLServer2012Platform;
use Doctrine\DBAL\Platforms\SQLServerPlatform;
use Doctrine\DBAL\Schema\AbstractSchemaManager;
use Doctrine\DBAL\Schema\SQLServerSchemaManager;
class AbstractSQLServerDriverTest extends AbstractDriverTest
{
protected function createDriver()
protected function createDriver() : Driver
{
return $this->getMockForAbstractClass(AbstractSQLServerDriver::class);
}
protected function createPlatform()
protected function createPlatform() : AbstractPlatform
{
return new SQLServer2008Platform();
}
protected function createSchemaManager(Connection $connection)
protected function createSchemaManager(Connection $connection) : AbstractSchemaManager
{
return new SQLServerSchemaManager($connection);
}
protected function getDatabasePlatformsForVersions()
/**
* {@inheritDoc}
*/
protected function getDatabasePlatformsForVersions() : array
{
return [
['9', SQLServerPlatform::class],
......
......@@ -3,13 +3,16 @@
namespace Doctrine\Tests\DBAL\Driver;
use Doctrine\DBAL\Connection;
use Doctrine\DBAL\Driver;
use Doctrine\DBAL\Driver\AbstractSQLiteDriver;
use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Platforms\SqlitePlatform;
use Doctrine\DBAL\Schema\AbstractSchemaManager;
use Doctrine\DBAL\Schema\SqliteSchemaManager;
class AbstractSQLiteDriverTest extends AbstractDriverTest
{
public function testReturnsDatabaseName()
public function testReturnsDatabaseName() : void
{
$params = [
'user' => 'foo',
......@@ -27,17 +30,17 @@ class AbstractSQLiteDriverTest extends AbstractDriverTest
self::assertSame($params['path'], $this->driver->getDatabase($connection));
}
protected function createDriver()
protected function createDriver() : Driver
{
return $this->getMockForAbstractClass(AbstractSQLiteDriver::class);
}
protected function createPlatform()
protected function createPlatform() : AbstractPlatform
{
return new SqlitePlatform();
}
protected function createSchemaManager(Connection $connection)
protected function createSchemaManager(Connection $connection) : AbstractSchemaManager
{
return new SqliteSchemaManager($connection);
}
......
......@@ -3,34 +3,37 @@
namespace Doctrine\Tests\DBAL\Driver\DrizzlePDOMySql;
use Doctrine\DBAL\Connection;
use Doctrine\DBAL\Driver as DriverInterface;
use Doctrine\DBAL\Driver\DrizzlePDOMySql\Driver;
use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Platforms\DrizzlePlatform;
use Doctrine\DBAL\Schema\AbstractSchemaManager;
use Doctrine\DBAL\Schema\DrizzleSchemaManager;
use Doctrine\Tests\DBAL\Driver\PDOMySql\DriverTest as PDOMySQLDriverTest;
class DriverTest extends PDOMySQLDriverTest
{
public function testReturnsName()
public function testReturnsName() : void
{
self::assertSame('drizzle_pdo_mysql', $this->driver->getName());
}
public function testThrowsExceptionOnCreatingDatabasePlatformsForInvalidVersion()
public function testThrowsExceptionOnCreatingDatabasePlatformsForInvalidVersion() : void
{
$this->markTestSkipped('This test does not work on Drizzle as it is not version aware.');
}
protected function createDriver()
protected function createDriver() : DriverInterface
{
return new Driver();
}
protected function createPlatform()
protected function createPlatform() : AbstractPlatform
{
return new DrizzlePlatform();
}
protected function createSchemaManager(Connection $connection)
protected function createSchemaManager(Connection $connection) : AbstractSchemaManager
{
return new DrizzleSchemaManager($connection);
}
......
......@@ -29,7 +29,7 @@ class DB2ConnectionTest extends DbalTestCase
->getMockForAbstractClass();
}
public function testDoesNotRequireQueryForServerVersion()
public function testDoesNotRequireQueryForServerVersion() : void
{
self::assertFalse($this->connectionMock->requiresQueryForServerVersion());
}
......
......@@ -2,17 +2,18 @@
namespace Doctrine\Tests\DBAL\Driver\IBMDB2;
use Doctrine\DBAL\Driver as DriverInterface;
use Doctrine\DBAL\Driver\IBMDB2\DB2Driver;
use Doctrine\Tests\DBAL\Driver\AbstractDB2DriverTest;
class DB2DriverTest extends AbstractDB2DriverTest
{
public function testReturnsName()
public function testReturnsName() : void
{
self::assertSame('ibm_db2', $this->driver->getName());
}
protected function createDriver()
protected function createDriver() : DriverInterface
{
return new DB2Driver();
}
......
......@@ -2,17 +2,18 @@
namespace Doctrine\Tests\DBAL\Driver\Mysqli;
use Doctrine\DBAL\Driver as DriverInterface;
use Doctrine\DBAL\Driver\Mysqli\Driver;
use Doctrine\Tests\DBAL\Driver\AbstractMySQLDriverTest;
class DriverTest extends AbstractMySQLDriverTest
{
public function testReturnsName()
public function testReturnsName() : void
{
self::assertSame('mysqli', $this->driver->getName());
}
protected function createDriver()
protected function createDriver() : DriverInterface
{
return new Driver();
}
......
......@@ -37,14 +37,14 @@ class MysqliConnectionTest extends DbalFunctionalTestCase
->getMockForAbstractClass();
}
public function testDoesNotRequireQueryForServerVersion()
public function testDoesNotRequireQueryForServerVersion() : void
{
self::assertFalse($this->connectionMock->requiresQueryForServerVersion());
}
public function testRestoresErrorHandlerOnException()
public function testRestoresErrorHandlerOnException() : void
{
$handler = static function () {
$handler = static function () : void {
self::fail('Never expected this to be called');
};
$default_handler = set_error_handler($handler);
......
......@@ -2,17 +2,18 @@
namespace Doctrine\Tests\DBAL\Driver\OCI8;
use Doctrine\DBAL\Driver as DriverInterface;
use Doctrine\DBAL\Driver\OCI8\Driver;
use Doctrine\Tests\DBAL\Driver\AbstractOracleDriverTest;
class DriverTest extends AbstractOracleDriverTest
{
public function testReturnsName()
public function testReturnsName() : void
{
self::assertSame('oci8', $this->driver->getName());
}
protected function createDriver()
protected function createDriver() : DriverInterface
{
return new Driver();
}
......
......@@ -29,7 +29,7 @@ class OCI8ConnectionTest extends DbalTestCase
->getMockForAbstractClass();
}
public function testDoesNotRequireQueryForServerVersion()
public function testDoesNotRequireQueryForServerVersion() : void
{
self::assertFalse($this->connectionMock->requiresQueryForServerVersion());
}
......
......@@ -33,7 +33,7 @@ class OCI8StatementTest extends DbalTestCase
*
* @dataProvider executeDataProvider
*/
public function testExecute(array $params)
public function testExecute(array $params) : void
{
$statement = $this->getMockBuilder(OCI8Statement::class)
->setMethods(['bindValue', 'errorInfo'])
......@@ -76,7 +76,10 @@ class OCI8StatementTest extends DbalTestCase
$statement->execute($params);
}
public static function executeDataProvider()
/**
* @return array<int, array<int, mixed>>
*/
public static function executeDataProvider() : iterable
{
return [
// $hasZeroIndex = isset($params[0]); == true
......@@ -93,14 +96,17 @@ class OCI8StatementTest extends DbalTestCase
/**
* @dataProvider nonTerminatedLiteralProvider
*/
public function testConvertNonTerminatedLiteral($sql, $message)
public function testConvertNonTerminatedLiteral(string $sql, string $message) : void
{
$this->expectException(OCI8Exception::class);
$this->expectExceptionMessageRegExp($message);
OCI8Statement::convertPositionalToNamedPlaceholders($sql);
}
public static function nonTerminatedLiteralProvider()
/**
* @return array<string, array<int, mixed>>
*/
public static function nonTerminatedLiteralProvider() : iterable
{
return [
'no-matching-quote' => [
......
......@@ -44,27 +44,27 @@ class PDOExceptionTest extends DbalTestCase
$this->exception = new PDOException($this->wrappedException);
}
public function testReturnsCode()
public function testReturnsCode() : void
{
self::assertSame(self::SQLSTATE, $this->exception->getCode());
}
public function testReturnsErrorCode()
public function testReturnsErrorCode() : void
{
self::assertSame(self::ERROR_CODE, $this->exception->getErrorCode());
}
public function testReturnsMessage()
public function testReturnsMessage() : void
{
self::assertSame(self::MESSAGE, $this->exception->getMessage());
}
public function testReturnsSQLState()
public function testReturnsSQLState() : void
{
self::assertSame(self::SQLSTATE, $this->exception->getSQLState());
}
public function testOriginalExceptionIsInChain()
public function testOriginalExceptionIsInChain() : void
{
self::assertSame($this->wrappedException, $this->exception->getPrevious());
}
......
......@@ -2,17 +2,18 @@
namespace Doctrine\Tests\DBAL\Driver\PDOIbm;
use Doctrine\DBAL\Driver as DriverInterface;
use Doctrine\DBAL\Driver\PDOIbm\Driver;
use Doctrine\Tests\DBAL\Driver\AbstractDB2DriverTest;
class DriverTest extends AbstractDB2DriverTest
{
public function testReturnsName()
public function testReturnsName() : void
{
self::assertSame('pdo_ibm', $this->driver->getName());
}
protected function createDriver()
protected function createDriver() : DriverInterface
{
return new Driver();
}
......
......@@ -2,17 +2,18 @@
namespace Doctrine\Tests\DBAL\Driver\PDOMySql;
use Doctrine\DBAL\Driver as DriverInterface;
use Doctrine\DBAL\Driver\PDOMySql\Driver;
use Doctrine\Tests\DBAL\Driver\AbstractMySQLDriverTest;
class DriverTest extends AbstractMySQLDriverTest
{
public function testReturnsName()
public function testReturnsName() : void
{
self::assertSame('pdo_mysql', $this->driver->getName());
}
protected function createDriver()
protected function createDriver() : DriverInterface
{
return new Driver();
}
......
......@@ -2,17 +2,18 @@
namespace Doctrine\Tests\DBAL\Driver\PDOOracle;
use Doctrine\DBAL\Driver as DriverInterface;
use Doctrine\DBAL\Driver\PDOOracle\Driver;
use Doctrine\Tests\DBAL\Driver\AbstractOracleDriverTest;
class DriverTest extends AbstractOracleDriverTest
{
public function testReturnsName()
public function testReturnsName() : void
{
self::assertSame('pdo_oracle', $this->driver->getName());
}
protected function createDriver()
protected function createDriver() : DriverInterface
{
return new Driver();
}
......
......@@ -2,17 +2,17 @@
namespace Doctrine\Tests\DBAL\Driver\PDOPgSql;
use Doctrine\DBAL\Driver as DriverInterface;
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
{
public function testReturnsName()
public function testReturnsName() : void
{
self::assertSame('pdo_pgsql', $this->driver->getName());
}
......@@ -20,7 +20,7 @@ class DriverTest extends AbstractPostgreSQLDriverTest
/**
* @group DBAL-920
*/
public function testConnectionDisablesPreparesOnPhp56()
public function testConnectionDisablesPreparesOnPhp56() : void
{
$this->skipWhenNotUsingPhp56AndPdoPgsql();
......@@ -46,7 +46,7 @@ class DriverTest extends AbstractPostgreSQLDriverTest
/**
* @group DBAL-920
*/
public function testConnectionDoesNotDisablePreparesOnPhp56WhenAttributeDefined()
public function testConnectionDoesNotDisablePreparesOnPhp56WhenAttributeDefined() : void
{
$this->skipWhenNotUsingPhp56AndPdoPgsql();
......@@ -73,7 +73,7 @@ class DriverTest extends AbstractPostgreSQLDriverTest
/**
* @group DBAL-920
*/
public function testConnectionDisablePreparesOnPhp56WhenDisablePreparesIsExplicitlyDefined()
public function testConnectionDisablePreparesOnPhp56WhenDisablePreparesIsExplicitlyDefined() : void
{
$this->skipWhenNotUsingPhp56AndPdoPgsql();
......@@ -100,15 +100,12 @@ class DriverTest extends AbstractPostgreSQLDriverTest
/**
* {@inheritDoc}
*/
protected function createDriver()
protected function createDriver() : DriverInterface
{
return new Driver();
}
/**
* @throws PHPUnit_Framework_SkippedTestError
*/
private function skipWhenNotUsingPhp56AndPdoPgsql()
private function skipWhenNotUsingPhp56AndPdoPgsql() : void
{
if (! defined('PDO::PGSQL_ATTR_DISABLE_PREPARES')) {
$this->markTestSkipped('Test requires PHP 5.6+');
......
......@@ -2,17 +2,18 @@
namespace Doctrine\Tests\DBAL\Driver\PDOSqlite;
use Doctrine\DBAL\Driver as DriverInterface;
use Doctrine\DBAL\Driver\PDOSqlite\Driver;
use Doctrine\Tests\DBAL\Driver\AbstractSQLiteDriverTest;
class DriverTest extends AbstractSQLiteDriverTest
{
public function testReturnsName()
public function testReturnsName() : void
{
self::assertSame('pdo_sqlite', $this->driver->getName());
}
protected function createDriver()
protected function createDriver() : DriverInterface
{
return new Driver();
}
......
......@@ -2,17 +2,18 @@
namespace Doctrine\Tests\DBAL\Driver\PDOSqlsrv;
use Doctrine\DBAL\Driver as DriverInterface;
use Doctrine\DBAL\Driver\PDOSqlsrv\Driver;
use Doctrine\Tests\DBAL\Driver\AbstractSQLServerDriverTest;
class DriverTest extends AbstractSQLServerDriverTest
{
public function testReturnsName()
public function testReturnsName() : void
{
self::assertSame('pdo_sqlsrv', $this->driver->getName());
}
protected function createDriver()
protected function createDriver() : DriverInterface
{
return new Driver();
}
......
......@@ -2,17 +2,18 @@
namespace Doctrine\Tests\DBAL\Driver\SQLAnywhere;
use Doctrine\DBAL\Driver as DriverInterface;
use Doctrine\DBAL\Driver\SQLAnywhere\Driver;
use Doctrine\Tests\DBAL\Driver\AbstractSQLAnywhereDriverTest;
class DriverTest extends AbstractSQLAnywhereDriverTest
{
public function testReturnsName()
public function testReturnsName() : void
{
self::assertSame('sqlanywhere', $this->driver->getName());
}
protected function createDriver()
protected function createDriver() : DriverInterface
{
return new Driver();
}
......
......@@ -29,7 +29,7 @@ class SQLAnywhereConnectionTest extends DbalTestCase
->getMockForAbstractClass();
}
public function testRequiresQueryForServerVersion()
public function testRequiresQueryForServerVersion() : void
{
self::assertTrue($this->connectionMock->requiresQueryForServerVersion());
}
......
......@@ -2,17 +2,18 @@
namespace Doctrine\Tests\DBAL\Driver\SQLSrv;
use Doctrine\DBAL\Driver as DriverInterface;
use Doctrine\DBAL\Driver\SQLSrv\Driver;
use Doctrine\Tests\DBAL\Driver\AbstractSQLServerDriverTest;
class DriverTest extends AbstractSQLServerDriverTest
{
public function testReturnsName()
public function testReturnsName() : void
{
self::assertSame('sqlsrv', $this->driver->getName());
}
protected function createDriver()
protected function createDriver() : DriverInterface
{
return new Driver();
}
......
......@@ -29,7 +29,7 @@ class SQLSrvConnectionTest extends DbalTestCase
->getMockForAbstractClass();
}
public function testDoesNotRequireQueryForServerVersion()
public function testDoesNotRequireQueryForServerVersion() : void
{
self::assertFalse($this->connectionMock->requiresQueryForServerVersion());
}
......
......@@ -27,7 +27,7 @@ class DriverManagerTest extends DbalTestCase
/**
* @requires extension pdo_sqlite
*/
public function testInvalidPdoInstance()
public function testInvalidPdoInstance() : void
{
$this->expectException(DBALException::class);
DriverManager::getConnection(['pdo' => 'test']);
......@@ -36,7 +36,7 @@ class DriverManagerTest extends DbalTestCase
/**
* @requires extension pdo_sqlite
*/
public function testValidPdoInstance()
public function testValidPdoInstance() : void
{
$conn = DriverManager::getConnection([
'pdo' => new PDO('sqlite::memory:'),
......@@ -49,7 +49,7 @@ class DriverManagerTest extends DbalTestCase
* @group DBAL-32
* @requires extension pdo_sqlite
*/
public function testPdoInstanceSetErrorMode()
public function testPdoInstanceSetErrorMode() : void
{
$pdo = new PDO('sqlite::memory:');
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_SILENT);
......@@ -59,14 +59,14 @@ class DriverManagerTest extends DbalTestCase
self::assertEquals(PDO::ERRMODE_EXCEPTION, $pdo->getAttribute(PDO::ATTR_ERRMODE));
}
public function testCheckParams()
public function testCheckParams() : void
{
$this->expectException(DBALException::class);
DriverManager::getConnection([]);
}
public function testInvalidDriver()
public function testInvalidDriver() : void
{
$this->expectException(DBALException::class);
......@@ -76,7 +76,7 @@ class DriverManagerTest extends DbalTestCase
/**
* @requires extension pdo_sqlite
*/
public function testCustomPlatform()
public function testCustomPlatform() : void
{
$platform = $this->createMock(AbstractPlatform::class);
$options = [
......@@ -91,7 +91,7 @@ class DriverManagerTest extends DbalTestCase
/**
* @requires extension pdo_sqlite
*/
public function testCustomWrapper()
public function testCustomWrapper() : void
{
$wrapper = $this->createMock(Connection::class);
$wrapperClass = get_class($wrapper);
......@@ -108,7 +108,7 @@ class DriverManagerTest extends DbalTestCase
/**
* @requires extension pdo_sqlite
*/
public function testInvalidWrapperClass()
public function testInvalidWrapperClass() : void
{
$this->expectException(DBALException::class);
......@@ -120,7 +120,7 @@ class DriverManagerTest extends DbalTestCase
DriverManager::getConnection($options);
}
public function testInvalidDriverClass()
public function testInvalidDriverClass() : void
{
$this->expectException(DBALException::class);
......@@ -129,7 +129,7 @@ class DriverManagerTest extends DbalTestCase
DriverManager::getConnection($options);
}
public function testValidDriverClass()
public function testValidDriverClass() : void
{
$options = ['driverClass' => PDOMySQLDriver::class];
......@@ -137,7 +137,7 @@ class DriverManagerTest extends DbalTestCase
self::assertInstanceOf(PDOMySQLDriver::class, $conn->getDriver());
}
public function testDatabaseUrlMasterSlave()
public function testDatabaseUrlMasterSlave() : void
{
$options = [
'driver' => 'pdo_mysql',
......@@ -169,7 +169,7 @@ class DriverManagerTest extends DbalTestCase
self::assertEquals('baz_slave', $params['slaves']['slave1']['dbname']);
}
public function testDatabaseUrlShard()
public function testDatabaseUrlShard() : void
{
$options = [
'driver' => 'pdo_mysql',
......@@ -206,9 +206,12 @@ class DriverManagerTest extends DbalTestCase
}
/**
* @param mixed $url
* @param mixed $expected
*
* @dataProvider databaseUrls
*/
public function testDatabaseUrl($url, $expected)
public function testDatabaseUrl($url, $expected) : void
{
$options = is_array($url) ? $url : ['url' => $url];
......@@ -238,7 +241,10 @@ class DriverManagerTest extends DbalTestCase
}
}
public function databaseUrls()
/**
* @return array<string, array<int, mixed>>
*/
public function databaseUrls() : iterable
{
$driver = $this->createMock(Driver::class);
$driverClass = get_class($driver);
......
......@@ -10,7 +10,7 @@ use Doctrine\Tests\DbalTestCase;
class MysqlSessionInitTest extends DbalTestCase
{
public function testPostConnect()
public function testPostConnect() : void
{
$connectionMock = $this->createMock(Connection::class);
$connectionMock->expects($this->once())
......@@ -23,7 +23,7 @@ class MysqlSessionInitTest extends DbalTestCase
$listener->postConnect($eventArgs);
}
public function testGetSubscribedEvents()
public function testGetSubscribedEvents() : void
{
$listener = new MysqlSessionInit();
self::assertEquals([Events::postConnect], $listener->getSubscribedEvents());
......
......@@ -11,7 +11,7 @@ use function sprintf;
class OracleSessionInitTest extends DbalTestCase
{
public function testPostConnect()
public function testPostConnect() : void
{
$connectionMock = $this->createMock(Connection::class);
$connectionMock->expects($this->once())
......@@ -28,7 +28,7 @@ class OracleSessionInitTest extends DbalTestCase
* @group DBAL-1824
* @dataProvider getPostConnectWithSessionParameterValuesData
*/
public function testPostConnectQuotesSessionParameterValues($name, $value)
public function testPostConnectQuotesSessionParameterValues(string $name, string $value) : void
{
$connectionMock = $this->getMockBuilder(Connection::class)
->disableOriginalConstructor()
......@@ -43,14 +43,17 @@ class OracleSessionInitTest extends DbalTestCase
$listener->postConnect($eventArgs);
}
public function getPostConnectWithSessionParameterValuesData()
/**
* @return array<int, array<int, mixed>>
*/
public static function getPostConnectWithSessionParameterValuesData() : iterable
{
return [
['CURRENT_SCHEMA', 'foo'],
];
}
public function testGetSubscribedEvents()
public function testGetSubscribedEvents() : void
{
$listener = new OracleSessionInit();
self::assertEquals([Events::postConnect], $listener->getSubscribedEvents());
......
......@@ -13,7 +13,7 @@ use Doctrine\Tests\DbalTestCase;
*/
class SQLSessionInitTest extends DbalTestCase
{
public function testPostConnect()
public function testPostConnect() : void
{
$connectionMock = $this->createMock(Connection::class);
$connectionMock->expects($this->once())
......@@ -26,7 +26,7 @@ class SQLSessionInitTest extends DbalTestCase
$listener->postConnect($eventArgs);
}
public function testGetSubscribedEvents()
public function testGetSubscribedEvents() : void
{
$listener = new SQLSessionInit("SET SEARCH_PATH TO foo, public, TIMEZONE TO 'Europe/Berlin'");
self::assertEquals([Events::postConnect], $listener->getSubscribedEvents());
......
......@@ -12,7 +12,7 @@ use PHPUnit\Framework\TestCase;
*/
class InvalidArgumentExceptionTest extends TestCase
{
public function testFromEmptyCriteria()
public function testFromEmptyCriteria() : void
{
$exception = InvalidArgumentException::fromEmptyCriteria();
......
......@@ -38,7 +38,7 @@ class BlobTest extends DbalFunctionalTestCase
$sm->dropAndCreateTable($table);
}
public function testInsert()
public function testInsert() : void
{
$ret = $this->connection->insert('blob_table', [
'id' => 1,
......@@ -53,7 +53,7 @@ class BlobTest extends DbalFunctionalTestCase
self::assertEquals(1, $ret);
}
public function testInsertProcessesStream()
public function testInsertProcessesStream() : void
{
// https://github.com/doctrine/dbal/issues/3290
if ($this->connection->getDriver() instanceof OCI8Driver) {
......@@ -74,7 +74,7 @@ class BlobTest extends DbalFunctionalTestCase
$this->assertBlobContains($longBlob);
}
public function testSelect()
public function testSelect() : void
{
$this->connection->insert('blob_table', [
'id' => 1,
......@@ -89,7 +89,7 @@ class BlobTest extends DbalFunctionalTestCase
$this->assertBlobContains('test');
}
public function testUpdate()
public function testUpdate() : void
{
$this->connection->insert('blob_table', [
'id' => 1,
......@@ -109,7 +109,7 @@ class BlobTest extends DbalFunctionalTestCase
$this->assertBlobContains('test2');
}
public function testUpdateProcessesStream()
public function testUpdateProcessesStream() : void
{
// https://github.com/doctrine/dbal/issues/3290
if ($this->connection->getDriver() instanceof OCI8Driver) {
......@@ -137,7 +137,7 @@ class BlobTest extends DbalFunctionalTestCase
$this->assertBlobContains('test2');
}
public function testBindParamProcessesStream()
public function testBindParamProcessesStream() : void
{
if ($this->connection->getDriver() instanceof OCI8Driver) {
$this->markTestIncomplete('The oci8 driver does not support stream resources as parameters');
......@@ -156,7 +156,7 @@ class BlobTest extends DbalFunctionalTestCase
$this->assertBlobContains('test');
}
private function assertBlobContains($text)
private function assertBlobContains(string $text) : void
{
$rows = $this->connection->query('SELECT blobfield FROM blob_table')->fetchAll(FetchMode::COLUMN);
......
......@@ -31,12 +31,12 @@ class ConnectionTest extends DbalFunctionalTestCase
$this->resetSharedConn();
}
public function testGetWrappedConnection()
public function testGetWrappedConnection() : void
{
self::assertInstanceOf(DriverConnection::class, $this->connection->getWrappedConnection());
}
public function testCommitWithRollbackOnlyThrowsException()
public function testCommitWithRollbackOnlyThrowsException() : void
{
$this->connection->beginTransaction();
$this->connection->setRollbackOnly();
......@@ -45,7 +45,7 @@ class ConnectionTest extends DbalFunctionalTestCase
$this->connection->commit();
}
public function testTransactionNestingBehavior()
public function testTransactionNestingBehavior() : void
{
try {
$this->connection->beginTransaction();
......@@ -72,7 +72,7 @@ class ConnectionTest extends DbalFunctionalTestCase
}
}
public function testTransactionNestingBehaviorWithSavepoints()
public function testTransactionNestingBehaviorWithSavepoints() : void
{
if (! $this->connection->getDatabasePlatform()->supportsSavepoints()) {
$this->markTestSkipped('This test requires the platform to support savepoints.');
......@@ -111,7 +111,7 @@ class ConnectionTest extends DbalFunctionalTestCase
}
}
public function testTransactionNestingBehaviorCantBeChangedInActiveTransaction()
public function testTransactionNestingBehaviorCantBeChangedInActiveTransaction() : void
{
if (! $this->connection->getDatabasePlatform()->supportsSavepoints()) {
$this->markTestSkipped('This test requires the platform to support savepoints.');
......@@ -122,7 +122,7 @@ class ConnectionTest extends DbalFunctionalTestCase
$this->connection->setNestTransactionsWithSavepoints(true);
}
public function testSetNestedTransactionsThroughSavepointsNotSupportedThrowsException()
public function testSetNestedTransactionsThroughSavepointsNotSupportedThrowsException() : void
{
if ($this->connection->getDatabasePlatform()->supportsSavepoints()) {
$this->markTestSkipped('This test requires the platform not to support savepoints.');
......@@ -134,7 +134,7 @@ class ConnectionTest extends DbalFunctionalTestCase
$this->connection->setNestTransactionsWithSavepoints(true);
}
public function testCreateSavepointsNotSupportedThrowsException()
public function testCreateSavepointsNotSupportedThrowsException() : void
{
if ($this->connection->getDatabasePlatform()->supportsSavepoints()) {
$this->markTestSkipped('This test requires the platform not to support savepoints.');
......@@ -146,7 +146,7 @@ class ConnectionTest extends DbalFunctionalTestCase
$this->connection->createSavepoint('foo');
}
public function testReleaseSavepointsNotSupportedThrowsException()
public function testReleaseSavepointsNotSupportedThrowsException() : void
{
if ($this->connection->getDatabasePlatform()->supportsSavepoints()) {
$this->markTestSkipped('This test requires the platform not to support savepoints.');
......@@ -158,7 +158,7 @@ class ConnectionTest extends DbalFunctionalTestCase
$this->connection->releaseSavepoint('foo');
}
public function testRollbackSavepointsNotSupportedThrowsException()
public function testRollbackSavepointsNotSupportedThrowsException() : void
{
if ($this->connection->getDatabasePlatform()->supportsSavepoints()) {
$this->markTestSkipped('This test requires the platform not to support savepoints.');
......@@ -170,7 +170,7 @@ class ConnectionTest extends DbalFunctionalTestCase
$this->connection->rollbackSavepoint('foo');
}
public function testTransactionBehaviorWithRollback()
public function testTransactionBehaviorWithRollback() : void
{
try {
$this->connection->beginTransaction();
......@@ -186,7 +186,7 @@ class ConnectionTest extends DbalFunctionalTestCase
}
}
public function testTransactionBehaviour()
public function testTransactionBehaviour() : void
{
try {
$this->connection->beginTransaction();
......@@ -200,10 +200,10 @@ class ConnectionTest extends DbalFunctionalTestCase
self::assertEquals(0, $this->connection->getTransactionNestingLevel());
}
public function testTransactionalWithException()
public function testTransactionalWithException() : void
{
try {
$this->connection->transactional(static function ($conn) {
$this->connection->transactional(static function ($conn) : void {
/** @var Connection $conn */
$conn->executeQuery($conn->getDatabasePlatform()->getDummySelectSQL());
throw new RuntimeException('Ooops!');
......@@ -214,10 +214,10 @@ class ConnectionTest extends DbalFunctionalTestCase
}
}
public function testTransactionalWithThrowable()
public function testTransactionalWithThrowable() : void
{
try {
$this->connection->transactional(static function ($conn) {
$this->connection->transactional(static function ($conn) : void {
/** @var Connection $conn */
$conn->executeQuery($conn->getDatabasePlatform()->getDummySelectSQL());
throw new Error('Ooops!');
......@@ -228,9 +228,9 @@ class ConnectionTest extends DbalFunctionalTestCase
}
}
public function testTransactional()
public function testTransactional() : void
{
$res = $this->connection->transactional(static function ($conn) {
$res = $this->connection->transactional(static function ($conn) : void {
/** @var Connection $conn */
$conn->executeQuery($conn->getDatabasePlatform()->getDummySelectSQL());
});
......@@ -238,7 +238,7 @@ class ConnectionTest extends DbalFunctionalTestCase
self::assertNull($res);
}
public function testTransactionalReturnValue()
public function testTransactionalReturnValue() : void
{
$res = $this->connection->transactional(static function () {
return 42;
......@@ -250,7 +250,7 @@ class ConnectionTest extends DbalFunctionalTestCase
/**
* Tests that the quote function accepts DBAL and PDO types.
*/
public function testQuote()
public function testQuote() : void
{
self::assertEquals(
$this->connection->quote('foo', Types::STRING),
......@@ -258,7 +258,7 @@ class ConnectionTest extends DbalFunctionalTestCase
);
}
public function testPingDoesTriggersConnect()
public function testPingDoesTriggersConnect() : void
{
self::assertTrue($this->connection->ping());
self::assertTrue($this->connection->isConnected());
......@@ -267,7 +267,7 @@ class ConnectionTest extends DbalFunctionalTestCase
/**
* @group DBAL-1025
*/
public function testConnectWithoutExplicitDatabaseName()
public function testConnectWithoutExplicitDatabaseName() : void
{
if (in_array($this->connection->getDatabasePlatform()->getName(), ['oracle', 'db2'], true)) {
$this->markTestSkipped('Platform does not support connecting without database name.');
......@@ -290,7 +290,7 @@ class ConnectionTest extends DbalFunctionalTestCase
/**
* @group DBAL-990
*/
public function testDeterminesDatabasePlatformWhenConnectingToNonExistentDatabase()
public function testDeterminesDatabasePlatformWhenConnectingToNonExistentDatabase() : void
{
if (in_array($this->connection->getDatabasePlatform()->getName(), ['oracle', 'db2'], true)) {
$this->markTestSkipped('Platform does not support connecting without database name.');
......
......@@ -26,7 +26,7 @@ abstract class AbstractDriverTest extends DbalFunctionalTestCase
/**
* @group DBAL-1215
*/
public function testConnectsWithoutDatabaseNameParameter()
public function testConnectsWithoutDatabaseNameParameter() : void
{
$params = $this->connection->getParams();
unset($params['dbname']);
......@@ -42,7 +42,7 @@ abstract class AbstractDriverTest extends DbalFunctionalTestCase
/**
* @group DBAL-1215
*/
public function testReturnsDatabaseNameWithoutDatabaseNameParameter()
public function testReturnsDatabaseNameWithoutDatabaseNameParameter() : void
{
$params = $this->connection->getParams();
unset($params['dbname']);
......@@ -60,10 +60,7 @@ abstract class AbstractDriverTest extends DbalFunctionalTestCase
);
}
/**
* @return Driver
*/
abstract protected function createDriver();
abstract protected function createDriver() : Driver;
protected static function getDatabaseNameForConnectionWithoutDatabaseNameParameter() : ?string
{
......
......@@ -2,6 +2,7 @@
namespace Doctrine\Tests\DBAL\Functional\Driver\IBMDB2;
use Doctrine\DBAL\Driver;
use Doctrine\DBAL\Driver\IBMDB2\DB2Driver;
use Doctrine\Tests\DBAL\Functional\Driver\AbstractDriverTest;
use function extension_loaded;
......@@ -26,7 +27,7 @@ class DB2DriverTest extends AbstractDriverTest
/**
* {@inheritdoc}
*/
public function testConnectsWithoutDatabaseNameParameter()
public function testConnectsWithoutDatabaseNameParameter() : void
{
$this->markTestSkipped('IBM DB2 does not support connecting without database name.');
}
......@@ -34,7 +35,7 @@ class DB2DriverTest extends AbstractDriverTest
/**
* {@inheritdoc}
*/
public function testReturnsDatabaseNameWithoutDatabaseNameParameter()
public function testReturnsDatabaseNameWithoutDatabaseNameParameter() : void
{
$this->markTestSkipped('IBM DB2 does not support connecting without database name.');
}
......@@ -42,7 +43,7 @@ class DB2DriverTest extends AbstractDriverTest
/**
* {@inheritdoc}
*/
protected function createDriver()
protected function createDriver() : Driver
{
return new DB2Driver();
}
......
......@@ -26,7 +26,7 @@ class DB2StatementTest extends DbalFunctionalTestCase
$this->markTestSkipped('ibm_db2 only test.');
}
public function testExecutionErrorsAreNotSuppressed()
public function testExecutionErrorsAreNotSuppressed() : void
{
$stmt = $this->connection->prepare('SELECT * FROM SYSIBM.SYSDUMMY1 WHERE \'foo\' = ?');
......
......@@ -31,7 +31,7 @@ class ConnectionTest extends DbalFunctionalTestCase
parent::tearDown();
}
public function testDriverOptions()
public function testDriverOptions() : void
{
$driverOptions = [MYSQLI_OPT_CONNECT_TIMEOUT => 1];
......@@ -39,14 +39,14 @@ class ConnectionTest extends DbalFunctionalTestCase
self::assertInstanceOf(MysqliConnection::class, $connection);
}
public function testUnsupportedDriverOption()
public function testUnsupportedDriverOption() : void
{
$this->expectException(MysqliException::class);
$this->getConnection(['hello' => 'world']); // use local infile
}
public function testPing()
public function testPing() : void
{
$conn = $this->getConnection([]);
self::assertTrue($conn->ping());
......@@ -55,7 +55,7 @@ class ConnectionTest extends DbalFunctionalTestCase
/**
* @param mixed[] $driverOptions
*/
private function getConnection(array $driverOptions)
private function getConnection(array $driverOptions) : MysqliConnection
{
return new MysqliConnection(
[
......
......@@ -2,6 +2,7 @@
namespace Doctrine\Tests\DBAL\Functional\Driver\Mysqli;
use Doctrine\DBAL\Driver as DriverInterface;
use Doctrine\DBAL\Driver\Mysqli\Driver;
use Doctrine\Tests\DBAL\Functional\Driver\AbstractDriverTest;
use function extension_loaded;
......@@ -26,7 +27,7 @@ class DriverTest extends AbstractDriverTest
/**
* {@inheritdoc}
*/
protected function createDriver()
protected function createDriver() : DriverInterface
{
return new Driver();
}
......
......@@ -2,6 +2,7 @@
namespace Doctrine\Tests\DBAL\Functional\Driver\OCI8;
use Doctrine\DBAL\Driver as DriverInterface;
use Doctrine\DBAL\Driver\OCI8\Driver;
use Doctrine\Tests\DBAL\Functional\Driver\AbstractDriverTest;
use function extension_loaded;
......@@ -26,7 +27,7 @@ class DriverTest extends AbstractDriverTest
/**
* {@inheritdoc}
*/
public function testConnectsWithoutDatabaseNameParameter()
public function testConnectsWithoutDatabaseNameParameter() : void
{
$this->markTestSkipped('Oracle does not support connecting without database name.');
}
......@@ -34,7 +35,7 @@ class DriverTest extends AbstractDriverTest
/**
* {@inheritdoc}
*/
public function testReturnsDatabaseNameWithoutDatabaseNameParameter()
public function testReturnsDatabaseNameWithoutDatabaseNameParameter() : void
{
$this->markTestSkipped('Oracle does not support connecting without database name.');
}
......@@ -42,7 +43,7 @@ class DriverTest extends AbstractDriverTest
/**
* {@inheritdoc}
*/
protected function createDriver()
protected function createDriver() : DriverInterface
{
return new Driver();
}
......
......@@ -31,7 +31,7 @@ class OCI8ConnectionTest extends DbalFunctionalTestCase
/**
* @group DBAL-2595
*/
public function testLastInsertIdAcceptsFqn()
public function testLastInsertIdAcceptsFqn() : void
{
$platform = $this->connection->getDatabasePlatform();
$schemaManager = $this->connection->getSchemaManager();
......
......@@ -29,7 +29,7 @@ class StatementTest extends DbalFunctionalTestCase
*
* @dataProvider queryConversionProvider
*/
public function testQueryConversion($query, array $params, array $expected)
public function testQueryConversion(string $query, array $params, array $expected) : void
{
self::assertEquals(
$expected,
......@@ -37,7 +37,10 @@ class StatementTest extends DbalFunctionalTestCase
);
}
public static function queryConversionProvider()
/**
* @return array<string, array<int, mixed>>
*/
public static function queryConversionProvider() : iterable
{
return [
'simple' => [
......
......@@ -46,12 +46,12 @@ class PDOConnectionTest extends DbalFunctionalTestCase
parent::tearDown();
}
public function testDoesNotRequireQueryForServerVersion()
public function testDoesNotRequireQueryForServerVersion() : void
{
self::assertFalse($this->driverConnection->requiresQueryForServerVersion());
}
public function testThrowsWrappedExceptionOnConstruct()
public function testThrowsWrappedExceptionOnConstruct() : void
{
$this->expectException(PDOException::class);
......@@ -61,14 +61,14 @@ class PDOConnectionTest extends DbalFunctionalTestCase
/**
* @group DBAL-1022
*/
public function testThrowsWrappedExceptionOnExec()
public function testThrowsWrappedExceptionOnExec() : void
{
$this->expectException(PDOException::class);
$this->driverConnection->exec('foo');
}
public function testThrowsWrappedExceptionOnPrepare()
public function testThrowsWrappedExceptionOnPrepare() : void
{
$driver = $this->connection->getDriver();
......@@ -97,7 +97,7 @@ class PDOConnectionTest extends DbalFunctionalTestCase
$this->driverConnection->prepare('foo');
}
public function testThrowsWrappedExceptionOnQuery()
public function testThrowsWrappedExceptionOnQuery() : void
{
$this->expectException(PDOException::class);
......
......@@ -2,6 +2,7 @@
namespace Doctrine\Tests\DBAL\Functional\Driver\PDOMySql;
use Doctrine\DBAL\Driver as DriverInterface;
use Doctrine\DBAL\Driver\PDOMySql\Driver;
use Doctrine\Tests\DBAL\Functional\Driver\AbstractDriverTest;
use function extension_loaded;
......@@ -26,7 +27,7 @@ class DriverTest extends AbstractDriverTest
/**
* {@inheritdoc}
*/
protected function createDriver()
protected function createDriver() : DriverInterface
{
return new Driver();
}
......
......@@ -2,6 +2,7 @@
namespace Doctrine\Tests\DBAL\Functional\Driver\PDOOracle;
use Doctrine\DBAL\Driver as DriverInterface;
use Doctrine\DBAL\Driver\PDOOracle\Driver;
use Doctrine\Tests\DBAL\Functional\Driver\AbstractDriverTest;
use function extension_loaded;
......@@ -26,7 +27,7 @@ class DriverTest extends AbstractDriverTest
/**
* {@inheritdoc}
*/
public function testConnectsWithoutDatabaseNameParameter()
public function testConnectsWithoutDatabaseNameParameter() : void
{
$this->markTestSkipped('Oracle does not support connecting without database name.');
}
......@@ -34,7 +35,7 @@ class DriverTest extends AbstractDriverTest
/**
* {@inheritdoc}
*/
public function testReturnsDatabaseNameWithoutDatabaseNameParameter()
public function testReturnsDatabaseNameWithoutDatabaseNameParameter() : void
{
$this->markTestSkipped('Oracle does not support connecting without database name.');
}
......@@ -42,7 +43,7 @@ class DriverTest extends AbstractDriverTest
/**
* {@inheritdoc}
*/
protected function createDriver()
protected function createDriver() : DriverInterface
{
return new Driver();
}
......
......@@ -3,6 +3,7 @@
namespace Doctrine\Tests\DBAL\Functional\Driver\PDOPgSql;
use Doctrine\DBAL\Connection;
use Doctrine\DBAL\Driver as DriverInterface;
use Doctrine\DBAL\Driver\PDOPgSql\Driver;
use Doctrine\Tests\DBAL\Functional\Driver\AbstractDriverTest;
use Doctrine\Tests\TestUtil;
......@@ -31,7 +32,7 @@ class DriverTest extends AbstractDriverTest
/**
* @dataProvider getDatabaseParameter
*/
public function testDatabaseParameters($databaseName, $defaultDatabaseName, $expectedDatabaseName)
public function testDatabaseParameters(?string $databaseName, ?string $defaultDatabaseName, ?string $expectedDatabaseName) : void
{
$params = $this->connection->getParams();
$params['dbname'] = $databaseName;
......@@ -71,7 +72,7 @@ class DriverTest extends AbstractDriverTest
/**
* @group DBAL-1146
*/
public function testConnectsWithApplicationNameParameter()
public function testConnectsWithApplicationNameParameter() : void
{
$parameters = $this->connection->getParams();
$parameters['application_name'] = 'doctrine';
......@@ -103,7 +104,7 @@ class DriverTest extends AbstractDriverTest
/**
* {@inheritdoc}
*/
protected function createDriver()
protected function createDriver() : DriverInterface
{
return new Driver();
}
......
......@@ -26,13 +26,11 @@ class PDOPgsqlConnectionTest extends DbalFunctionalTestCase
}
/**
* @param string $charset
*
* @group DBAL-1183
* @group DBAL-1189
* @dataProvider getValidCharsets
*/
public function testConnectsWithValidCharsetOption($charset)
public function testConnectsWithValidCharsetOption(string $charset) : void
{
$params = $this->connection->getParams();
$params['charset'] = $charset;
......@@ -53,7 +51,7 @@ class PDOPgsqlConnectionTest extends DbalFunctionalTestCase
/**
* @return mixed[][]
*/
public function getValidCharsets()
public static function getValidCharsets() : iterable
{
return [
['UTF8'],
......
......@@ -2,6 +2,7 @@
namespace Doctrine\Tests\DBAL\Functional\Driver\PDOSqlite;
use Doctrine\DBAL\Driver as DriverInterface;
use Doctrine\DBAL\Driver\PDOSqlite\Driver;
use Doctrine\Tests\DBAL\Functional\Driver\AbstractDriverTest;
use function extension_loaded;
......@@ -26,7 +27,7 @@ class DriverTest extends AbstractDriverTest
/**
* {@inheritdoc}
*/
protected function createDriver()
protected function createDriver() : DriverInterface
{
return new Driver();
}
......
......@@ -2,6 +2,7 @@
namespace Doctrine\Tests\DBAL\Functional\Driver\PDOSqlsrv;
use Doctrine\DBAL\Driver as DriverInterface;
use Doctrine\DBAL\Driver\Connection;
use Doctrine\DBAL\Driver\PDOSqlsrv\Driver;
use Doctrine\Tests\DBAL\Functional\Driver\AbstractDriverTest;
......@@ -28,7 +29,7 @@ class DriverTest extends AbstractDriverTest
/**
* {@inheritdoc}
*/
protected function createDriver()
protected function createDriver() : DriverInterface
{
return new Driver();
}
......
......@@ -24,7 +24,7 @@ class ConnectionTest extends DbalFunctionalTestCase
$this->markTestSkipped('sqlanywhere only test.');
}
public function testNonPersistentConnection()
public function testNonPersistentConnection() : void
{
$params = $this->connection->getParams();
$params['persistent'] = false;
......@@ -36,7 +36,7 @@ class ConnectionTest extends DbalFunctionalTestCase
self::assertTrue($conn->isConnected(), 'No SQLAnywhere-nonpersistent connection established');
}
public function testPersistentConnection()
public function testPersistentConnection() : void
{
$params = $this->connection->getParams();
$params['persistent'] = true;
......
......@@ -3,6 +3,7 @@
namespace Doctrine\Tests\DBAL\Functional\Driver\SQLAnywhere;
use Doctrine\DBAL\Connection;
use Doctrine\DBAL\Driver as DriverInterface;
use Doctrine\DBAL\Driver\SQLAnywhere\Driver;
use Doctrine\Tests\DBAL\Functional\Driver\AbstractDriverTest;
use function extension_loaded;
......@@ -24,7 +25,7 @@ class DriverTest extends AbstractDriverTest
$this->markTestSkipped('sqlanywhere only test.');
}
public function testReturnsDatabaseNameWithoutDatabaseNameParameter()
public function testReturnsDatabaseNameWithoutDatabaseNameParameter() : void
{
$params = $this->connection->getParams();
unset($params['dbname']);
......@@ -44,7 +45,7 @@ class DriverTest extends AbstractDriverTest
/**
* {@inheritdoc}
*/
protected function createDriver()
protected function createDriver() : DriverInterface
{
return new Driver();
}
......
......@@ -24,7 +24,7 @@ class StatementTest extends DbalFunctionalTestCase
$this->markTestSkipped('sqlanywhere only test.');
}
public function testNonPersistentStatement()
public function testNonPersistentStatement() : void
{
$params = $this->connection->getParams();
$params['persistent'] = false;
......@@ -39,7 +39,7 @@ class StatementTest extends DbalFunctionalTestCase
self::assertTrue($prepStmt->execute(), ' Statement non-persistent failed');
}
public function testPersistentStatement()
public function testPersistentStatement() : void
{
$params = $this->connection->getParams();
$params['persistent'] = true;
......
......@@ -2,6 +2,7 @@
namespace Doctrine\Tests\DBAL\Functional\Driver\SQLSrv;
use Doctrine\DBAL\Driver as DriverInterface;
use Doctrine\DBAL\Driver\SQLSrv\Driver;
use Doctrine\Tests\DBAL\Functional\Driver\AbstractDriverTest;
use function extension_loaded;
......@@ -26,7 +27,7 @@ class DriverTest extends AbstractDriverTest
/**
* {@inheritdoc}
*/
protected function createDriver()
protected function createDriver() : DriverInterface
{
return new Driver();
}
......
......@@ -24,7 +24,7 @@ class StatementTest extends DbalFunctionalTestCase
self::markTestSkipped('sqlsrv only test');
}
public function testFailureToPrepareResultsInException()
public function testFailureToPrepareResultsInException() : void
{
// use the driver connection directly to avoid having exception wrapped
$stmt = $this->connection->getWrappedConnection()->prepare(null);
......
......@@ -34,7 +34,7 @@ class ExceptionTest extends DbalFunctionalTestCase
$this->markTestSkipped('Driver does not support special exception handling.');
}
public function testPrimaryConstraintViolationException()
public function testPrimaryConstraintViolationException() : void
{
$table = new Table('duplicatekey_table');
$table->addColumn('id', 'integer', []);
......@@ -48,7 +48,7 @@ class ExceptionTest extends DbalFunctionalTestCase
$this->connection->insert('duplicatekey_table', ['id' => 1]);
}
public function testTableNotFoundException()
public function testTableNotFoundException() : void
{
$sql = 'SELECT * FROM unknown_table';
......@@ -56,7 +56,7 @@ class ExceptionTest extends DbalFunctionalTestCase
$this->connection->executeQuery($sql);
}
public function testTableExistsException()
public function testTableExistsException() : void
{
$schemaManager = $this->connection->getSchemaManager();
$table = new Table('alreadyexist_table');
......@@ -68,7 +68,7 @@ class ExceptionTest extends DbalFunctionalTestCase
$schemaManager->createTable($table);
}
public function testForeignKeyConstraintViolationExceptionOnInsert()
public function testForeignKeyConstraintViolationExceptionOnInsert() : void
{
if (! $this->connection->getDatabasePlatform()->supportsForeignKeyConstraints()) {
$this->markTestSkipped('Only fails on platforms with foreign key constraints.');
......@@ -102,7 +102,7 @@ class ExceptionTest extends DbalFunctionalTestCase
$this->tearDownForeignKeyConstraintViolationExceptionTest();
}
public function testForeignKeyConstraintViolationExceptionOnUpdate()
public function testForeignKeyConstraintViolationExceptionOnUpdate() : void
{
if (! $this->connection->getDatabasePlatform()->supportsForeignKeyConstraints()) {
$this->markTestSkipped('Only fails on platforms with foreign key constraints.');
......@@ -136,7 +136,7 @@ class ExceptionTest extends DbalFunctionalTestCase
$this->tearDownForeignKeyConstraintViolationExceptionTest();
}
public function testForeignKeyConstraintViolationExceptionOnDelete()
public function testForeignKeyConstraintViolationExceptionOnDelete() : void
{
if (! $this->connection->getDatabasePlatform()->supportsForeignKeyConstraints()) {
$this->markTestSkipped('Only fails on platforms with foreign key constraints.');
......@@ -170,7 +170,7 @@ class ExceptionTest extends DbalFunctionalTestCase
$this->tearDownForeignKeyConstraintViolationExceptionTest();
}
public function testForeignKeyConstraintViolationExceptionOnTruncate()
public function testForeignKeyConstraintViolationExceptionOnTruncate() : void
{
$platform = $this->connection->getDatabasePlatform();
......@@ -206,7 +206,7 @@ class ExceptionTest extends DbalFunctionalTestCase
$this->tearDownForeignKeyConstraintViolationExceptionTest();
}
public function testNotNullConstraintViolationException()
public function testNotNullConstraintViolationException() : void
{
$schema = new Schema();
......@@ -223,7 +223,7 @@ class ExceptionTest extends DbalFunctionalTestCase
$this->connection->insert('notnull_table', ['id' => 1, 'value' => null]);
}
public function testInvalidFieldNameException()
public function testInvalidFieldNameException() : void
{
$schema = new Schema();
......@@ -238,7 +238,7 @@ class ExceptionTest extends DbalFunctionalTestCase
$this->connection->insert('bad_fieldname_table', ['name' => 5]);
}
public function testNonUniqueFieldNameException()
public function testNonUniqueFieldNameException() : void
{
$schema = new Schema();
......@@ -257,7 +257,7 @@ class ExceptionTest extends DbalFunctionalTestCase
$this->connection->executeQuery($sql);
}
public function testUniqueConstraintViolationException()
public function testUniqueConstraintViolationException() : void
{
$schema = new Schema();
......@@ -274,7 +274,7 @@ class ExceptionTest extends DbalFunctionalTestCase
$this->connection->insert('unique_field_table', ['id' => 5]);
}
public function testSyntaxErrorException()
public function testSyntaxErrorException() : void
{
$table = new Table('syntax_error_table');
$table->addColumn('id', 'integer', []);
......@@ -287,7 +287,7 @@ class ExceptionTest extends DbalFunctionalTestCase
$this->connection->executeQuery($sql);
}
public function testConnectionExceptionSqLite()
public function testConnectionExceptionSqLite() : void
{
if ($this->connection->getDatabasePlatform()->getName() !== 'sqlite') {
$this->markTestSkipped('Only fails this way on sqlite');
......@@ -337,9 +337,11 @@ EOT
}
/**
* @param array<string, mixed> $params
*
* @dataProvider getConnectionParams
*/
public function testConnectionException($params)
public function testConnectionException(array $params) : void
{
if ($this->connection->getDatabasePlatform()->getName() === 'sqlite') {
$this->markTestSkipped('Only skipped if platform is not sqlite');
......@@ -369,7 +371,10 @@ EOT
}
}
public function getConnectionParams()
/**
* @return array<int, array<int, mixed>>
*/
public static function getConnectionParams() : iterable
{
return [
[['user' => 'not_existing']],
......@@ -378,7 +383,7 @@ EOT
];
}
private function setUpForeignKeyConstraintViolationExceptionTest()
private function setUpForeignKeyConstraintViolationExceptionTest() : void
{
$schemaManager = $this->connection->getSchemaManager();
......@@ -396,7 +401,7 @@ EOT
$schemaManager->createTable($owningTable);
}
private function tearDownForeignKeyConstraintViolationExceptionTest()
private function tearDownForeignKeyConstraintViolationExceptionTest() : void
{
$schemaManager = $this->connection->getSchemaManager();
......
......@@ -7,7 +7,7 @@ use Doctrine\Tests\DbalFunctionalTestCase;
class LoggingTest extends DbalFunctionalTestCase
{
public function testLogExecuteQuery()
public function testLogExecuteQuery() : void
{
$sql = $this->connection->getDatabasePlatform()->getDummySelectSQL();
......@@ -21,7 +21,7 @@ class LoggingTest extends DbalFunctionalTestCase
$this->connection->executeQuery($sql, []);
}
public function testLogExecuteUpdate()
public function testLogExecuteUpdate() : void
{
$this->markTestSkipped('Test breaks MySQL but works on all other platforms (Unbuffered Queries stuff).');
......@@ -37,7 +37,7 @@ class LoggingTest extends DbalFunctionalTestCase
$this->connection->executeUpdate($sql, []);
}
public function testLogPrepareExecute()
public function testLogPrepareExecute() : void
{
$sql = $this->connection->getDatabasePlatform()->getDummySelectSQL();
......
......@@ -98,7 +98,7 @@ class MasterSlaveConnectionTest extends DbalFunctionalTestCase
}
}
public function testMasterOnConnect()
public function testMasterOnConnect() : void
{
$conn = $this->createMasterSlaveConnection();
......@@ -109,7 +109,7 @@ class MasterSlaveConnectionTest extends DbalFunctionalTestCase
self::assertTrue($conn->isConnectedToMaster());
}
public function testNoMasterOnExecuteQuery()
public function testNoMasterOnExecuteQuery() : void
{
$conn = $this->createMasterSlaveConnection();
......@@ -121,7 +121,7 @@ class MasterSlaveConnectionTest extends DbalFunctionalTestCase
self::assertFalse($conn->isConnectedToMaster());
}
public function testMasterOnWriteOperation()
public function testMasterOnWriteOperation() : void
{
$conn = $this->createMasterSlaveConnection();
$conn->insert('master_slave_table', ['test_int' => 30]);
......@@ -139,7 +139,7 @@ class MasterSlaveConnectionTest extends DbalFunctionalTestCase
/**
* @group DBAL-335
*/
public function testKeepSlaveBeginTransactionStaysOnMaster()
public function testKeepSlaveBeginTransactionStaysOnMaster() : void
{
$conn = $this->createMasterSlaveConnection($keepSlave = true);
$conn->connect('slave');
......@@ -160,7 +160,7 @@ class MasterSlaveConnectionTest extends DbalFunctionalTestCase
/**
* @group DBAL-335
*/
public function testKeepSlaveInsertStaysOnMaster()
public function testKeepSlaveInsertStaysOnMaster() : void
{
$conn = $this->createMasterSlaveConnection($keepSlave = true);
$conn->connect('slave');
......@@ -176,7 +176,7 @@ class MasterSlaveConnectionTest extends DbalFunctionalTestCase
self::assertFalse($conn->isConnectedToMaster());
}
public function testMasterSlaveConnectionCloseAndReconnect()
public function testMasterSlaveConnectionCloseAndReconnect() : void
{
$conn = $this->createMasterSlaveConnection();
$conn->connect('master');
......@@ -189,7 +189,7 @@ class MasterSlaveConnectionTest extends DbalFunctionalTestCase
self::assertTrue($conn->isConnectedToMaster());
}
public function testQueryOnMaster()
public function testQueryOnMaster() : void
{
$conn = $this->createMasterSlaveConnection();
......@@ -213,7 +213,7 @@ class MasterSlaveConnectionTest extends DbalFunctionalTestCase
self::assertEquals(1, $data[0]['num']);
}
public function testQueryOnSlave()
public function testQueryOnSlave() : void
{
$conn = $this->createMasterSlaveConnection();
$conn->connect('slave');
......
......@@ -36,7 +36,7 @@ class ModifyLimitQueryTest extends DbalFunctionalTestCase
$this->connection->exec($this->connection->getDatabasePlatform()->getTruncateTableSQL('modify_limit_table2'));
}
public function testModifyLimitQuerySimpleQuery()
public function testModifyLimitQuerySimpleQuery() : void
{
$this->connection->insert('modify_limit_table', ['test_int' => 1]);
$this->connection->insert('modify_limit_table', ['test_int' => 2]);
......@@ -51,7 +51,7 @@ class ModifyLimitQueryTest extends DbalFunctionalTestCase
$this->assertLimitResult([2, 3, 4], $sql, null, 1);
}
public function testModifyLimitQueryJoinQuery()
public function testModifyLimitQueryJoinQuery() : void
{
$this->connection->insert('modify_limit_table', ['test_int' => 1]);
$this->connection->insert('modify_limit_table', ['test_int' => 2]);
......@@ -69,7 +69,7 @@ class ModifyLimitQueryTest extends DbalFunctionalTestCase
$this->assertLimitResult([2, 2], $sql, 2, 0);
}
public function testModifyLimitQueryNonDeterministic()
public function testModifyLimitQueryNonDeterministic() : void
{
$this->connection->insert('modify_limit_table', ['test_int' => 1]);
$this->connection->insert('modify_limit_table', ['test_int' => 2]);
......@@ -83,7 +83,7 @@ class ModifyLimitQueryTest extends DbalFunctionalTestCase
$this->assertLimitResult([2, 1], $sql, 2, 2, false);
}
public function testModifyLimitQueryGroupBy()
public function testModifyLimitQueryGroupBy() : void
{
$this->connection->insert('modify_limit_table', ['test_int' => 1]);
$this->connection->insert('modify_limit_table', ['test_int' => 2]);
......@@ -103,7 +103,7 @@ class ModifyLimitQueryTest extends DbalFunctionalTestCase
$this->assertLimitResult([2], $sql, 1, 1);
}
public function testModifyLimitQuerySubSelect()
public function testModifyLimitQuerySubSelect() : void
{
$this->connection->insert('modify_limit_table', ['test_int' => 1]);
$this->connection->insert('modify_limit_table', ['test_int' => 2]);
......@@ -117,7 +117,7 @@ class ModifyLimitQueryTest extends DbalFunctionalTestCase
$this->assertLimitResult([2, 1], $sql, 2, 2);
}
public function testModifyLimitQueryFromSubSelect()
public function testModifyLimitQueryFromSubSelect() : void
{
$this->connection->insert('modify_limit_table', ['test_int' => 1]);
$this->connection->insert('modify_limit_table', ['test_int' => 2]);
......@@ -131,7 +131,7 @@ class ModifyLimitQueryTest extends DbalFunctionalTestCase
$this->assertLimitResult([2, 1], $sql, 2, 2);
}
public function testModifyLimitQueryLineBreaks()
public function testModifyLimitQueryLineBreaks() : void
{
$this->connection->insert('modify_limit_table', ['test_int' => 1]);
$this->connection->insert('modify_limit_table', ['test_int' => 2]);
......@@ -151,7 +151,7 @@ SQL;
$this->assertLimitResult([2], $sql, 1, 1);
}
public function testModifyLimitQueryZeroOffsetNoLimit()
public function testModifyLimitQueryZeroOffsetNoLimit() : void
{
$this->connection->insert('modify_limit_table', ['test_int' => 1]);
$this->connection->insert('modify_limit_table', ['test_int' => 2]);
......@@ -161,7 +161,10 @@ SQL;
$this->assertLimitResult([1, 2], $sql, null, 0);
}
public function assertLimitResult($expectedResults, $sql, $limit, $offset, $deterministic = true)
/**
* @param array<int, int> $expectedResults
*/
private function assertLimitResult(array $expectedResults, string $sql, ?int $limit, int $offset, bool $deterministic = true) : void
{
$p = $this->connection->getDatabasePlatform();
$data = [];
......
......@@ -16,7 +16,10 @@ use function array_change_key_case;
*/
class NamedParametersTest extends DbalFunctionalTestCase
{
public function ticketProvider()
/**
* @return iterable<int, array<int, mixed>>
*/
public static function ticketProvider() : iterable
{
return [
[
......@@ -201,14 +204,13 @@ class NamedParametersTest extends DbalFunctionalTestCase
}
/**
* @param string $query
* @param mixed[] $params
* @param int[] $types
* @param int[] $expected
*
* @dataProvider ticketProvider
*/
public function testTicket($query, $params, $types, $expected)
public function testTicket(string $query, array $params, array $types, array $expected) : void
{
$stmt = $this->connection->executeQuery($query, $params, $types);
$result = $stmt->fetchAll(FetchMode::ASSOCIATIVE);
......
......@@ -32,7 +32,7 @@ class PDOStatementTest extends DbalFunctionalTestCase
* @group legacy
* @expectedDeprecation Using a PDO fetch mode or their combination (%d given) is deprecated and will cause an error in Doctrine 3.0
*/
public function testPDOSpecificModeIsAccepted()
public function testPDOSpecificModeIsAccepted() : void
{
$this->connection->insert('stmt_test', [
'id' => 1,
......
......@@ -2,6 +2,7 @@
namespace Doctrine\Tests\DBAL\Functional\Platform;
use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Schema\Comparator;
use Doctrine\Tests\DbalFunctionalTestCase;
use function in_array;
......@@ -30,7 +31,7 @@ final class NewPrimaryKeyWithNewAutoIncrementColumnTest extends DbalFunctionalTe
* SQLSTATE[42000]: Syntax error or access violation: 1075 Incorrect table definition; there can be only one auto
* column and it must be defined as a key
*/
public function testAlterPrimaryKeyToAutoIncrementColumn()
public function testAlterPrimaryKeyToAutoIncrementColumn() : void
{
$schemaManager = $this->connection->getSchemaManager();
$schema = $schemaManager->createSchema();
......@@ -62,7 +63,7 @@ final class NewPrimaryKeyWithNewAutoIncrementColumnTest extends DbalFunctionalTe
$this->assertSame(['new_id'], $validationTable->getPrimaryKeyColumns());
}
private function getPlatform()
private function getPlatform() : AbstractPlatform
{
return $this->connection->getDatabasePlatform();
}
......
......@@ -29,16 +29,10 @@ class PortabilityTest extends DbalFunctionalTestCase
parent::tearDown();
}
/**
* @param int $portabilityMode
* @param int $case
*
* @return Connection
*/
private function getPortableConnection(
$portabilityMode = ConnectionPortability::PORTABILITY_ALL,
$case = ColumnCase::LOWER
) {
int $portabilityMode = ConnectionPortability::PORTABILITY_ALL,
int $case = ColumnCase::LOWER
) : Connection {
if (! $this->portableConnection) {
$params = $this->connection->getParams();
......@@ -67,7 +61,7 @@ class PortabilityTest extends DbalFunctionalTestCase
return $this->portableConnection;
}
public function testFullFetchMode()
public function testFullFetchMode() : void
{
$rows = $this->getPortableConnection()->fetchAll('SELECT * FROM portability_table');
$this->assertFetchResultRows($rows);
......@@ -93,7 +87,7 @@ class PortabilityTest extends DbalFunctionalTestCase
}
}
public function testConnFetchMode()
public function testConnFetchMode() : void
{
$conn = $this->getPortableConnection();
$conn->setFetchMode(FetchMode::ASSOCIATIVE);
......@@ -118,7 +112,10 @@ class PortabilityTest extends DbalFunctionalTestCase
}
}
public function assertFetchResultRows($rows)
/**
* @param array<int, array<string, mixed>> $rows
*/
private function assertFetchResultRows(array $rows) : void
{
self::assertCount(2, $rows);
foreach ($rows as $row) {
......@@ -126,7 +123,10 @@ class PortabilityTest extends DbalFunctionalTestCase
}
}
public function assertFetchResultRow($row)
/**
* @param array<string, mixed> $row
*/
public function assertFetchResultRow(array $row) : void
{
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.');
......@@ -136,12 +136,11 @@ class PortabilityTest extends DbalFunctionalTestCase
}
/**
* @param string $field
* @param mixed[] $expected
*
* @dataProvider fetchAllColumnProvider
*/
public function testFetchAllColumn($field, array $expected)
public function testFetchAllColumn(string $field, array $expected) : void
{
$conn = $this->getPortableConnection();
$stmt = $conn->query('SELECT ' . $field . ' FROM portability_table');
......@@ -150,7 +149,10 @@ class PortabilityTest extends DbalFunctionalTestCase
self::assertEquals($expected, $column);
}
public static function fetchAllColumnProvider()
/**
* @return iterable<string, array<int, mixed>>
*/
public static function fetchAllColumnProvider() : iterable
{
return [
'int' => [
......@@ -164,7 +166,7 @@ class PortabilityTest extends DbalFunctionalTestCase
];
}
public function testFetchAllNullColumn()
public function testFetchAllNullColumn() : void
{
$conn = $this->getPortableConnection();
$stmt = $conn->query('SELECT Test_Null FROM portability_table');
......
......@@ -4,6 +4,7 @@ namespace Doctrine\Tests\DBAL\Functional;
use Doctrine\Common\Cache\ArrayCache;
use Doctrine\DBAL\Cache\QueryCacheProfile;
use Doctrine\DBAL\Driver\ResultStatement;
use Doctrine\DBAL\FetchMode;
use Doctrine\DBAL\Logging\DebugStack;
use Doctrine\DBAL\Schema\Table;
......@@ -20,7 +21,7 @@ use function is_array;
*/
class ResultCacheTest extends DbalFunctionalTestCase
{
/** @var int[][]|string[][] */
/** @var array<int, array<int, int|string>> */
private $expectedResult = [['test_int' => 100, 'test_string' => 'foo'], ['test_int' => 200, 'test_string' => 'bar'], ['test_int' => 300, 'test_string' => 'baz']];
/** @var DebugStack */
......@@ -56,45 +57,45 @@ class ResultCacheTest extends DbalFunctionalTestCase
parent::tearDown();
}
public function testCacheFetchAssoc()
public function testCacheFetchAssoc() : void
{
self::assertCacheNonCacheSelectSameFetchModeAreEqual(
$this->assertCacheNonCacheSelectSameFetchModeAreEqual(
$this->expectedResult,
FetchMode::ASSOCIATIVE
);
}
public function testFetchNum()
public function testFetchNum() : void
{
$expectedResult = [];
foreach ($this->expectedResult as $v) {
$expectedResult[] = array_values($v);
}
self::assertCacheNonCacheSelectSameFetchModeAreEqual($expectedResult, FetchMode::NUMERIC);
$this->assertCacheNonCacheSelectSameFetchModeAreEqual($expectedResult, FetchMode::NUMERIC);
}
public function testFetchBoth()
public function testFetchBoth() : void
{
$expectedResult = [];
foreach ($this->expectedResult as $v) {
$expectedResult[] = array_merge($v, array_values($v));
}
self::assertCacheNonCacheSelectSameFetchModeAreEqual($expectedResult, FetchMode::MIXED);
$this->assertCacheNonCacheSelectSameFetchModeAreEqual($expectedResult, FetchMode::MIXED);
}
public function testFetchColumn()
public function testFetchColumn() : void
{
$expectedResult = [];
foreach ($this->expectedResult as $v) {
$expectedResult[] = array_shift($v);
}
self::assertCacheNonCacheSelectSameFetchModeAreEqual($expectedResult, FetchMode::COLUMN);
$this->assertCacheNonCacheSelectSameFetchModeAreEqual($expectedResult, FetchMode::COLUMN);
}
public function testMixingFetch()
public function testMixingFetch() : void
{
$numExpectedResult = [];
foreach ($this->expectedResult as $v) {
......@@ -113,14 +114,14 @@ class ResultCacheTest extends DbalFunctionalTestCase
self::assertEquals($numExpectedResult, $data);
}
public function testIteratorFetch()
public function testIteratorFetch() : void
{
self::assertStandardAndIteratorFetchAreEqual(FetchMode::MIXED);
self::assertStandardAndIteratorFetchAreEqual(FetchMode::ASSOCIATIVE);
self::assertStandardAndIteratorFetchAreEqual(FetchMode::NUMERIC);
}
public function assertStandardAndIteratorFetchAreEqual($fetchMode)
private function assertStandardAndIteratorFetchAreEqual(int $fetchMode) : void
{
$stmt = $this->connection->executeQuery('SELECT * FROM caching ORDER BY test_int ASC', [], [], new QueryCacheProfile(10, 'testcachekey'));
$data = $this->hydrateStmt($stmt, $fetchMode);
......@@ -131,7 +132,7 @@ class ResultCacheTest extends DbalFunctionalTestCase
self::assertEquals($data, $data_iterator);
}
public function testDontCloseNoCache()
public function testDontCloseNoCache() : void
{
$stmt = $this->connection->executeQuery('SELECT * FROM caching ORDER BY test_int ASC', [], [], new QueryCacheProfile(10, 'testcachekey'));
......@@ -152,7 +153,7 @@ class ResultCacheTest extends DbalFunctionalTestCase
self::assertCount(2, $this->sqlLogger->queries);
}
public function testDontFinishNoCache()
public function testDontFinishNoCache() : void
{
$stmt = $this->connection->executeQuery('SELECT * FROM caching ORDER BY test_int ASC', [], [], new QueryCacheProfile(10, 'testcachekey'));
......@@ -166,7 +167,7 @@ class ResultCacheTest extends DbalFunctionalTestCase
self::assertCount(2, $this->sqlLogger->queries);
}
public function testFetchAllAndFinishSavesCache()
public function testFetchAllAndFinishSavesCache() : void
{
$layerCache = new ArrayCache();
$stmt = $this->connection->executeQuery('SELECT * FROM caching WHERE test_int > 500', [], [], new QueryCacheProfile(10, 'testcachekey', $layerCache));
......@@ -176,7 +177,10 @@ class ResultCacheTest extends DbalFunctionalTestCase
self::assertCount(1, $layerCache->fetch('testcachekey'));
}
public function assertCacheNonCacheSelectSameFetchModeAreEqual($expectedResult, $fetchMode)
/**
* @param array<int, array<int, int|string>> $expectedResult
*/
private function assertCacheNonCacheSelectSameFetchModeAreEqual(array $expectedResult, int $fetchMode) : void
{
$stmt = $this->connection->executeQuery('SELECT * FROM caching ORDER BY test_int ASC', [], [], new QueryCacheProfile(10, 'testcachekey'));
......@@ -192,7 +196,7 @@ class ResultCacheTest extends DbalFunctionalTestCase
self::assertCount(1, $this->sqlLogger->queries, 'just one dbal hit');
}
public function testEmptyResultCache()
public function testEmptyResultCache() : void
{
$stmt = $this->connection->executeQuery('SELECT * FROM caching WHERE test_int > 500', [], [], new QueryCacheProfile(10, 'emptycachekey'));
$data = $this->hydrateStmt($stmt);
......@@ -203,7 +207,7 @@ class ResultCacheTest extends DbalFunctionalTestCase
self::assertCount(1, $this->sqlLogger->queries, 'just one dbal hit');
}
public function testChangeCacheImpl()
public function testChangeCacheImpl() : void
{
$stmt = $this->connection->executeQuery('SELECT * FROM caching WHERE test_int > 500', [], [], new QueryCacheProfile(10, 'emptycachekey'));
$data = $this->hydrateStmt($stmt);
......@@ -216,7 +220,10 @@ class ResultCacheTest extends DbalFunctionalTestCase
self::assertCount(1, $secondCache->fetch('emptycachekey'));
}
private function hydrateStmt($stmt, $fetchMode = FetchMode::ASSOCIATIVE)
/**
* @return array<int, mixed>
*/
private function hydrateStmt(ResultStatement $stmt, int $fetchMode = FetchMode::ASSOCIATIVE) : array
{
$data = [];
while ($row = $stmt->fetch($fetchMode)) {
......@@ -227,7 +234,10 @@ class ResultCacheTest extends DbalFunctionalTestCase
return $data;
}
private function hydrateStmtIterator($stmt, $fetchMode = FetchMode::ASSOCIATIVE)
/**
* @return array<int, mixed>
*/
private function hydrateStmtIterator(ResultStatement $stmt, int $fetchMode = FetchMode::ASSOCIATIVE) : array
{
$data = [];
$stmt->setFetchMode($fetchMode);
......
......@@ -10,7 +10,7 @@ class Db2SchemaManagerTest extends SchemaManagerFunctionalTestCase
/**
* @group DBAL-939
*/
public function testGetBooleanColumn()
public function testGetBooleanColumn() : void
{
$table = new Table('boolean_column_test');
$table->addColumn('bool', 'boolean');
......@@ -27,7 +27,7 @@ class Db2SchemaManagerTest extends SchemaManagerFunctionalTestCase
self::assertSame("That's a comment", $columns['bool_commented']->getComment());
}
public function testListTableWithBinary()
public function testListTableWithBinary() : void
{
self::markTestSkipped('Binary data type is currently not supported on DB2 LUW');
}
......
......@@ -40,9 +40,11 @@ class DefaultValueTest extends DbalFunctionalTestCase
}
/**
* @param mixed $expectedDefault
*
* @dataProvider columnProvider
*/
public function testEscapedDefaultValueCanBeIntrospected(string $name, $expectedDefault) : void
public function testEscapedDefaultValueCanBeIntrospected(string $name, ?string $expectedDefault) : void
{
self::assertSame(
$expectedDefault,
......@@ -55,9 +57,11 @@ class DefaultValueTest extends DbalFunctionalTestCase
}
/**
* @param mixed $expectedDefault
*
* @dataProvider columnProvider
*/
public function testEscapedDefaultValueCanBeInserted(string $name, $expectedDefault) : void
public function testEscapedDefaultValueCanBeInserted(string $name, ?string $expectedDefault) : void
{
$value = $this->connection->fetchColumn(
sprintf('SELECT %s FROM default_value', $name)
......
......@@ -7,7 +7,7 @@ use Doctrine\DBAL\Types\BinaryType;
class DrizzleSchemaManagerTest extends SchemaManagerFunctionalTestCase
{
public function testListTableWithBinary()
public function testListTableWithBinary() : void
{
$tableName = 'test_binary_table';
......@@ -28,7 +28,7 @@ class DrizzleSchemaManagerTest extends SchemaManagerFunctionalTestCase
self::assertFalse($table->getColumn('column_binary')->getFixed());
}
public function testColumnCollation()
public function testColumnCollation() : void
{
$table = new Table('test_collation');
$table->addOption('collate', $collation = 'utf8_unicode_ci');
......
......@@ -27,7 +27,7 @@ class MySqlSchemaManagerTest extends SchemaManagerFunctionalTestCase
Type::addType('point', MySqlPointType::class);
}
public function testSwitchPrimaryKeyColumns()
public function testSwitchPrimaryKeyColumns() : void
{
$tableOld = new Table('switch_primary_key_columns');
$tableOld->addColumn('foo_id', 'integer');
......@@ -49,7 +49,7 @@ class MySqlSchemaManagerTest extends SchemaManagerFunctionalTestCase
self::assertContains('foo_id', $primaryKey);
}
public function testDiffTableBug()
public function testDiffTableBug() : void
{
$schema = new Schema();
$table = $schema->createTable('diffbug_routing_translations');
......@@ -72,7 +72,7 @@ class MySqlSchemaManagerTest extends SchemaManagerFunctionalTestCase
self::assertFalse($diff, 'no changes expected.');
}
public function testFulltextIndex()
public function testFulltextIndex() : void
{
$table = new Table('fulltext_index');
$table->addColumn('text', 'text');
......@@ -89,7 +89,7 @@ class MySqlSchemaManagerTest extends SchemaManagerFunctionalTestCase
self::assertTrue($indexes['f_index']->hasFlag('fulltext'));
}
public function testSpatialIndex()
public function testSpatialIndex() : void
{
$table = new Table('spatial_index');
$table->addColumn('point', 'point');
......@@ -122,7 +122,7 @@ class MySqlSchemaManagerTest extends SchemaManagerFunctionalTestCase
/**
* @group DBAL-400
*/
public function testAlterTableAddPrimaryKey()
public function testAlterTableAddPrimaryKey() : void
{
$table = new Table('alter_table_add_pk');
$table->addColumn('id', 'integer');
......@@ -148,7 +148,7 @@ class MySqlSchemaManagerTest extends SchemaManagerFunctionalTestCase
/**
* @group DBAL-464
*/
public function testDropPrimaryKeyWithAutoincrementColumn()
public function testDropPrimaryKeyWithAutoincrementColumn() : void
{
$table = new Table('drop_primary_key');
$table->addColumn('id', 'integer', ['autoincrement' => true]);
......@@ -174,7 +174,7 @@ class MySqlSchemaManagerTest extends SchemaManagerFunctionalTestCase
/**
* @group DBAL-789
*/
public function testDoesNotPropagateDefaultValuesForUnsupportedColumnTypes()
public function testDoesNotPropagateDefaultValuesForUnsupportedColumnTypes() : void
{
if ($this->schemaManager->getDatabasePlatform() instanceof MariaDb1027Platform) {
$this->markTestSkipped(
......@@ -213,7 +213,7 @@ class MySqlSchemaManagerTest extends SchemaManagerFunctionalTestCase
self::assertFalse($onlineTable->getColumn('def_blob_null')->getNotnull());
}
public function testColumnCharset()
public function testColumnCharset() : void
{
$table = new Table('test_column_charset');
$table->addColumn('id', 'integer');
......@@ -230,7 +230,7 @@ class MySqlSchemaManagerTest extends SchemaManagerFunctionalTestCase
self::assertEquals('latin1', $columns['bar']->getPlatformOption('charset'));
}
public function testAlterColumnCharset()
public function testAlterColumnCharset() : void
{
$tableName = 'test_alter_column_charset';
......@@ -251,7 +251,7 @@ class MySqlSchemaManagerTest extends SchemaManagerFunctionalTestCase
self::assertEquals('ascii', $table->getColumn('col_text')->getPlatformOption('charset'));
}
public function testColumnCharsetChange()
public function testColumnCharsetChange() : void
{
$table = new Table('test_column_charset_change');
$table->addColumn('col_string', 'string')->setLength(100)->setNotnull(true)->setPlatformOption('charset', 'utf8');
......@@ -266,7 +266,7 @@ class MySqlSchemaManagerTest extends SchemaManagerFunctionalTestCase
self::assertContains('ALTER TABLE test_column_charset_change CHANGE col_string col_string VARCHAR(100) CHARACTER SET ascii NOT NULL', $diff);
}
public function testColumnCollation()
public function testColumnCollation() : void
{
$table = new Table('test_collation');
$table->addOption('collate', $collation = 'latin1_swedish_ci');
......@@ -288,7 +288,7 @@ class MySqlSchemaManagerTest extends SchemaManagerFunctionalTestCase
/**
* @group DBAL-843
*/
public function testListLobTypeColumns()
public function testListLobTypeColumns() : void
{
$tableName = 'lob_type_columns';
$table = new Table($tableName);
......@@ -347,7 +347,7 @@ class MySqlSchemaManagerTest extends SchemaManagerFunctionalTestCase
/**
* @group DBAL-423
*/
public function testDiffListGuidTableColumn()
public function testDiffListGuidTableColumn() : void
{
$offlineTable = new Table('list_guid_table_column');
$offlineTable->addColumn('col_guid', 'guid');
......@@ -367,7 +367,7 @@ class MySqlSchemaManagerTest extends SchemaManagerFunctionalTestCase
/**
* @group DBAL-1082
*/
public function testListDecimalTypeColumns()
public function testListDecimalTypeColumns() : void
{
$tableName = 'test_list_decimal_columns';
$table = new Table($tableName);
......@@ -388,7 +388,7 @@ class MySqlSchemaManagerTest extends SchemaManagerFunctionalTestCase
/**
* @group DBAL-1082
*/
public function testListFloatTypeColumns()
public function testListFloatTypeColumns() : void
{
$tableName = 'test_list_float_columns';
$table = new Table($tableName);
......@@ -440,7 +440,7 @@ class MySqlSchemaManagerTest extends SchemaManagerFunctionalTestCase
self::assertFalse($diff, 'Tables should be identical with column defaults.');
}
public function testColumnDefaultsAreValid()
public function testColumnDefaultsAreValid() : void
{
$table = new Table('test_column_defaults_are_valid');
......
......@@ -32,7 +32,7 @@ class OracleSchemaManagerTest extends SchemaManagerFunctionalTestCase
self::$privilegesGranted = true;
}
public function testRenameTable()
public function testRenameTable() : void
{
$this->schemaManager->tryMethod('DropTable', 'list_tables_test');
$this->schemaManager->tryMethod('DropTable', 'list_tables_test_new_name');
......@@ -45,7 +45,7 @@ class OracleSchemaManagerTest extends SchemaManagerFunctionalTestCase
self::assertHasTable($tables, 'list_tables_test_new_name');
}
public function testListTableWithBinary()
public function testListTableWithBinary() : void
{
$tableName = 'test_binary_table';
......@@ -70,7 +70,7 @@ class OracleSchemaManagerTest extends SchemaManagerFunctionalTestCase
* @group DBAL-472
* @group DBAL-1001
*/
public function testAlterTableColumnNotNull()
public function testAlterTableColumnNotNull() : void
{
$comparator = new Schema\Comparator();
$tableName = 'list_table_column_notnull';
......@@ -102,7 +102,7 @@ class OracleSchemaManagerTest extends SchemaManagerFunctionalTestCase
self::assertTrue($columns['bar']->getNotnull());
}
public function testListDatabases()
public function testListDatabases() : void
{
// We need the temp connection that has privileges to create a database.
$sm = TestUtil::getTempConnection()->getSchemaManager();
......@@ -118,7 +118,7 @@ class OracleSchemaManagerTest extends SchemaManagerFunctionalTestCase
/**
* @group DBAL-831
*/
public function testListTableDetailsWithDifferentIdentifierQuotingRequirements()
public function testListTableDetailsWithDifferentIdentifierQuotingRequirements() : void
{
$primaryTableName = '"Primary_Table"';
$offlinePrimaryTable = new Schema\Table($primaryTableName);
......@@ -226,7 +226,7 @@ class OracleSchemaManagerTest extends SchemaManagerFunctionalTestCase
);
}
public function testListTableColumnsSameTableNamesInDifferentSchemas()
public function testListTableColumnsSameTableNamesInDifferentSchemas() : void
{
$table = $this->createListTableColumns();
$this->schemaManager->dropAndCreateTable($table);
......@@ -242,7 +242,7 @@ class OracleSchemaManagerTest extends SchemaManagerFunctionalTestCase
/**
* @group DBAL-1234
*/
public function testListTableIndexesPrimaryKeyConstraintNameDiffersFromIndexName()
public function testListTableIndexesPrimaryKeyConstraintNameDiffersFromIndexName() : void
{
$table = new Table('list_table_indexes_pk_id_test');
$table->setSchemaConfig($this->schemaManager->createSchemaConfig());
......@@ -265,7 +265,7 @@ class OracleSchemaManagerTest extends SchemaManagerFunctionalTestCase
/**
* @group DBAL-2555
*/
public function testListTableDateTypeColumns()
public function testListTableDateTypeColumns() : void
{
$table = new Table('tbl_date');
$table->addColumn('col_date', 'date');
......
......@@ -34,7 +34,7 @@ class PostgreSqlSchemaManagerTest extends SchemaManagerFunctionalTestCase
/**
* @group DBAL-177
*/
public function testGetSearchPath()
public function testGetSearchPath() : void
{
$params = $this->connection->getParams();
......@@ -45,7 +45,7 @@ class PostgreSqlSchemaManagerTest extends SchemaManagerFunctionalTestCase
/**
* @group DBAL-244
*/
public function testGetSchemaNames()
public function testGetSchemaNames() : void
{
$names = $this->schemaManager->getSchemaNames();
......@@ -57,7 +57,7 @@ class PostgreSqlSchemaManagerTest extends SchemaManagerFunctionalTestCase
/**
* @group DBAL-21
*/
public function testSupportDomainTypeFallback()
public function testSupportDomainTypeFallback() : void
{
$createDomainTypeSQL = 'CREATE DOMAIN MyMoney AS DECIMAL(18,2)';
$this->connection->exec($createDomainTypeSQL);
......@@ -78,7 +78,7 @@ class PostgreSqlSchemaManagerTest extends SchemaManagerFunctionalTestCase
/**
* @group DBAL-37
*/
public function testDetectsAutoIncrement()
public function testDetectsAutoIncrement() : void
{
$autoincTable = new Table('autoinc_table');
$column = $autoincTable->addColumn('id', 'integer');
......@@ -92,7 +92,7 @@ class PostgreSqlSchemaManagerTest extends SchemaManagerFunctionalTestCase
/**
* @group DBAL-37
*/
public function testAlterTableAutoIncrementAdd()
public function testAlterTableAutoIncrementAdd() : void
{
$tableFrom = new Table('autoinc_table_add');
$column = $tableFrom->addColumn('id', 'integer');
......@@ -121,7 +121,7 @@ class PostgreSqlSchemaManagerTest extends SchemaManagerFunctionalTestCase
/**
* @group DBAL-37
*/
public function testAlterTableAutoIncrementDrop()
public function testAlterTableAutoIncrementDrop() : void
{
$tableFrom = new Table('autoinc_table_drop');
$column = $tableFrom->addColumn('id', 'integer');
......@@ -146,7 +146,7 @@ class PostgreSqlSchemaManagerTest extends SchemaManagerFunctionalTestCase
/**
* @group DBAL-75
*/
public function testTableWithSchema()
public function testTableWithSchema() : void
{
$this->connection->exec('CREATE SCHEMA nested');
......@@ -181,7 +181,7 @@ class PostgreSqlSchemaManagerTest extends SchemaManagerFunctionalTestCase
* @group DBAL-91
* @group DBAL-88
*/
public function testReturnQuotedAssets()
public function testReturnQuotedAssets() : void
{
$sql = 'create table dbal91_something ( id integer CONSTRAINT id_something PRIMARY KEY NOT NULL ,"table" integer );';
$this->connection->exec($sql);
......@@ -203,7 +203,7 @@ class PostgreSqlSchemaManagerTest extends SchemaManagerFunctionalTestCase
/**
* @group DBAL-204
*/
public function testFilterSchemaExpression()
public function testFilterSchemaExpression() : void
{
$testTable = new Table('dbal204_test_prefix');
$column = $testTable->addColumn('id', 'integer');
......@@ -221,7 +221,7 @@ class PostgreSqlSchemaManagerTest extends SchemaManagerFunctionalTestCase
self::assertCount(1, $names);
}
public function testListForeignKeys()
public function testListForeignKeys() : void
{
if (! $this->connection->getDatabasePlatform()->supportsForeignKeyConstraints()) {
$this->markTestSkipped('Does not support foreign key constraints.');
......@@ -263,7 +263,7 @@ class PostgreSqlSchemaManagerTest extends SchemaManagerFunctionalTestCase
/**
* @group DBAL-511
*/
public function testDefaultValueCharacterVarying()
public function testDefaultValueCharacterVarying() : void
{
$testTable = new Table('dbal511_default');
$testTable->addColumn('id', 'integer');
......@@ -280,7 +280,7 @@ class PostgreSqlSchemaManagerTest extends SchemaManagerFunctionalTestCase
/**
* @group DDC-2843
*/
public function testBooleanDefault()
public function testBooleanDefault() : void
{
$table = new Table('ddc2843_bools');
$table->addColumn('id', 'integer');
......@@ -296,7 +296,7 @@ class PostgreSqlSchemaManagerTest extends SchemaManagerFunctionalTestCase
self::assertFalse($diff);
}
public function testListTableWithBinary()
public function testListTableWithBinary() : void
{
$tableName = 'test_binary_table';
......@@ -317,7 +317,7 @@ class PostgreSqlSchemaManagerTest extends SchemaManagerFunctionalTestCase
self::assertFalse($table->getColumn('column_binary')->getFixed());
}
public function testListQuotedTable()
public function testListQuotedTable() : void
{
$offlineTable = new Schema\Table('user');
$offlineTable->addColumn('id', 'integer');
......@@ -335,7 +335,7 @@ class PostgreSqlSchemaManagerTest extends SchemaManagerFunctionalTestCase
self::assertFalse($comparator->diffTable($offlineTable, $onlineTable));
}
public function testListTablesExcludesViews()
public function testListTablesExcludesViews() : void
{
$this->createTestTable('list_tables_excludes_views');
......@@ -364,7 +364,7 @@ class PostgreSqlSchemaManagerTest extends SchemaManagerFunctionalTestCase
/**
* @group DBAL-1033
*/
public function testPartialIndexes()
public function testPartialIndexes() : void
{
$offlineTable = new Schema\Table('person');
$offlineTable->addColumn('id', 'integer');
......@@ -419,7 +419,7 @@ class PostgreSqlSchemaManagerTest extends SchemaManagerFunctionalTestCase
/**
* @group DBAL-2427
*/
public function testListNegativeColumnDefaultValue()
public function testListNegativeColumnDefaultValue() : void
{
$table = new Schema\Table('test_default_negative');
$table->addColumn('col_smallint', 'smallint', ['default' => -1]);
......@@ -444,7 +444,7 @@ class PostgreSqlSchemaManagerTest extends SchemaManagerFunctionalTestCase
/**
* @return mixed[][]
*/
public static function serialTypes() : array
public static function serialTypes() : iterable
{
return [
['integer'],
......@@ -518,7 +518,7 @@ class PostgreSqlSchemaManagerTest extends SchemaManagerFunctionalTestCase
/**
* @return mixed[][]
*/
public function autoIncrementTypeMigrations() : array
public static function autoIncrementTypeMigrations() : iterable
{
return [
'int->bigint' => ['integer', 'bigint', 'BIGINT'],
......@@ -529,6 +529,9 @@ class PostgreSqlSchemaManagerTest extends SchemaManagerFunctionalTestCase
class MoneyType extends Type
{
/**
* {@inheritDoc}
*/
public function getName()
{
return 'MyMoney';
......
......@@ -8,7 +8,7 @@ use Doctrine\DBAL\Schema\View;
class SQLAnywhereSchemaManagerTest extends SchemaManagerFunctionalTestCase
{
public function testCreateAndListViews()
public function testCreateAndListViews() : void
{
$this->createTestTable('view_test_table');
......@@ -27,7 +27,7 @@ class SQLAnywhereSchemaManagerTest extends SchemaManagerFunctionalTestCase
self::assertRegExp('/^SELECT \* from "?DBA"?\."?view_test_table"?$/', $views[$name]->getSql());
}
public function testDropAndCreateAdvancedIndex()
public function testDropAndCreateAdvancedIndex() : void
{
$table = $this->getTestTable('test_create_advanced_index');
$this->schemaManager->dropAndCreateTable($table);
......@@ -47,7 +47,7 @@ class SQLAnywhereSchemaManagerTest extends SchemaManagerFunctionalTestCase
self::assertTrue($tableIndexes['test']->hasFlag('for_olap_workload'));
}
public function testListTableColumnsWithFixedStringTypeColumn()
public function testListTableColumnsWithFixedStringTypeColumn() : void
{
$table = new Table('list_table_columns_char');
$table->addColumn('id', 'integer', ['notnull' => true]);
......
......@@ -11,7 +11,7 @@ use function current;
class SQLServerSchemaManagerTest extends SchemaManagerFunctionalTestCase
{
protected function getPlatformName()
protected function getPlatformName() : string
{
return 'mssql';
}
......@@ -19,7 +19,7 @@ class SQLServerSchemaManagerTest extends SchemaManagerFunctionalTestCase
/**
* @group DBAL-255
*/
public function testDropColumnConstraints()
public function testDropColumnConstraints() : void
{
$table = new Table('sqlsrv_drop_column');
$table->addColumn('id', 'integer');
......@@ -34,7 +34,7 @@ class SQLServerSchemaManagerTest extends SchemaManagerFunctionalTestCase
self::assertCount(1, $columns);
}
public function testColumnCollation()
public function testColumnCollation() : void
{
$table = new Table($tableName = 'test_collation');
$column = $table->addColumn($columnName = 'test', 'string');
......@@ -52,7 +52,7 @@ class SQLServerSchemaManagerTest extends SchemaManagerFunctionalTestCase
self::assertEquals($collation, $columns[$columnName]->getPlatformOption('collation'));
}
public function testDefaultConstraints()
public function testDefaultConstraints() : void
{
$table = new Table('sqlsrv_default_constraints');
$table->addColumn('no_default', 'string');
......@@ -157,7 +157,7 @@ class SQLServerSchemaManagerTest extends SchemaManagerFunctionalTestCase
/**
* @group DBAL-543
*/
public function testColumnComments()
public function testColumnComments() : void
{
$table = new Table('sqlsrv_column_comment');
$table->addColumn('id', 'integer', ['autoincrement' => true]);
......@@ -319,7 +319,7 @@ class SQLServerSchemaManagerTest extends SchemaManagerFunctionalTestCase
self::assertEquals('666', $columns['added_commented_type_with_comment']->getComment());
}
public function testPkOrdering()
public function testPkOrdering() : void
{
// SQL Server stores index column information in a system table with two
// columns that almost always have the same value: index_column_id and key_ordinal.
......
......@@ -20,14 +20,14 @@ class SqliteSchemaManagerTest extends SchemaManagerFunctionalTestCase
/**
* SQLITE does not support databases.
*/
public function testListDatabases()
public function testListDatabases() : void
{
$this->expectException(DBALException::class);
$this->schemaManager->listDatabases();
}
public function testCreateAndDropDatabase()
public function testCreateAndDropDatabase() : void
{
$path = dirname(__FILE__) . '/test_create_and_drop_sqlite_database.sqlite';
......@@ -40,7 +40,7 @@ class SqliteSchemaManagerTest extends SchemaManagerFunctionalTestCase
/**
* @group DBAL-1220
*/
public function testDropsDatabaseWithActiveConnections()
public function testDropsDatabaseWithActiveConnections() : void
{
$this->schemaManager->dropAndCreateDatabase('test_drop_database');
......@@ -63,7 +63,7 @@ class SqliteSchemaManagerTest extends SchemaManagerFunctionalTestCase
unset($connection);
}
public function testRenameTable()
public function testRenameTable() : void
{
$this->createTestTable('oldname');
$this->schemaManager->renameTable('oldname', 'newname');
......@@ -73,7 +73,7 @@ class SqliteSchemaManagerTest extends SchemaManagerFunctionalTestCase
self::assertNotContains('oldname', $tables);
}
public function createListTableColumns()
public function createListTableColumns() : Table
{
$table = parent::createListTableColumns();
$table->getColumn('id')->setAutoincrement(true);
......@@ -81,7 +81,7 @@ class SqliteSchemaManagerTest extends SchemaManagerFunctionalTestCase
return $table;
}
public function testListForeignKeysFromExistingDatabase()
public function testListForeignKeysFromExistingDatabase() : void
{
$this->connection->exec(<<<EOS
CREATE TABLE user (
......@@ -121,7 +121,7 @@ EOS
self::assertEquals($expected, $this->schemaManager->listTableForeignKeys('user'));
}
public function testColumnCollation()
public function testColumnCollation() : void
{
$table = new Schema\Table('test_collation');
$table->addColumn('id', 'integer');
......@@ -138,7 +138,7 @@ EOS
self::assertEquals('NOCASE', $columns['bar']->getPlatformOption('collation'));
}
public function testListTableWithBinary()
public function testListTableWithBinary() : void
{
$tableName = 'test_binary_table';
......@@ -159,7 +159,7 @@ EOS
self::assertFalse($table->getColumn('column_binary')->getFixed());
}
public function testNonDefaultPKOrder()
public function testNonDefaultPKOrder() : void
{
if (! extension_loaded('sqlite3')) {
$this->markTestSkipped('This test requires the SQLite3 extension.');
......@@ -189,7 +189,7 @@ EOS
/**
* @group DBAL-1779
*/
public function testListTableColumnsWithWhitespacesInTypeDeclarations()
public function testListTableColumnsWithWhitespacesInTypeDeclarations() : void
{
$sql = <<<SQL
CREATE TABLE dbal_1779 (
......@@ -218,7 +218,7 @@ SQL;
* @dataProvider getDiffListIntegerAutoincrementTableColumnsData
* @group DBAL-924
*/
public function testDiffListIntegerAutoincrementTableColumns($integerType, $unsigned, $expectedComparatorDiff)
public function testDiffListIntegerAutoincrementTableColumns(string $integerType, bool $unsigned, bool $expectedComparatorDiff) : void
{
$tableName = 'test_int_autoincrement_table';
......@@ -242,7 +242,7 @@ SQL;
/**
* @return mixed[][]
*/
public function getDiffListIntegerAutoincrementTableColumnsData()
public static function getDiffListIntegerAutoincrementTableColumnsData() : iterable
{
return [
['smallint', false, true],
......@@ -257,7 +257,7 @@ SQL;
/**
* @group DBAL-2921
*/
public function testPrimaryKeyNoAutoIncrement()
public function testPrimaryKeyNoAutoIncrement() : void
{
$table = new Schema\Table('test_pk_auto_increment');
$table->addColumn('id', 'integer');
......
......@@ -24,7 +24,7 @@ class StatementTest extends DbalFunctionalTestCase
$this->connection->getSchemaManager()->dropAndCreateTable($table);
}
public function testStatementIsReusableAfterClosingCursor()
public function testStatementIsReusableAfterClosingCursor() : void
{
if ($this->connection->getDriver() instanceof PDOOracleDriver) {
$this->markTestIncomplete('See https://bugs.php.net/bug.php?id=77181');
......@@ -49,7 +49,7 @@ class StatementTest extends DbalFunctionalTestCase
self::assertEquals(2, $id);
}
public function testReuseStatementWithLongerResults()
public function testReuseStatementWithLongerResults() : void
{
if ($this->connection->getDriver() instanceof PDOOracleDriver) {
$this->markTestIncomplete('PDO_OCI doesn\'t support fetching blobs via PDOStatement::fetchAll()');
......@@ -86,7 +86,7 @@ class StatementTest extends DbalFunctionalTestCase
], $stmt->fetchAll(FetchMode::NUMERIC));
}
public function testFetchLongBlob()
public function testFetchLongBlob() : void
{
if ($this->connection->getDriver() instanceof PDOOracleDriver) {
// inserting BLOBs as streams on Oracle requires Oracle-specific SQL syntax which is currently not supported
......@@ -134,7 +134,7 @@ EOF
self::assertSame($contents, stream_get_contents($stream));
}
public function testIncompletelyFetchedStatementDoesNotBlockConnection()
public function testIncompletelyFetchedStatementDoesNotBlockConnection() : void
{
$this->connection->insert('stmt_test', ['id' => 1]);
$this->connection->insert('stmt_test', ['id' => 2]);
......@@ -151,7 +151,7 @@ EOF
self::assertEquals(1, $stmt2->fetchColumn());
}
public function testReuseStatementAfterClosingCursor()
public function testReuseStatementAfterClosingCursor() : void
{
if ($this->connection->getDriver() instanceof PDOOracleDriver) {
$this->markTestIncomplete('See https://bugs.php.net/bug.php?id=77181');
......@@ -173,7 +173,7 @@ EOF
self::assertEquals(2, $id);
}
public function testReuseStatementWithParameterBoundByReference()
public function testReuseStatementWithParameterBoundByReference() : void
{
$this->connection->insert('stmt_test', ['id' => 1]);
$this->connection->insert('stmt_test', ['id' => 2]);
......@@ -190,7 +190,7 @@ EOF
self::assertEquals(2, $stmt->fetchColumn());
}
public function testReuseStatementWithReboundValue()
public function testReuseStatementWithReboundValue() : void
{
$this->connection->insert('stmt_test', ['id' => 1]);
$this->connection->insert('stmt_test', ['id' => 2]);
......@@ -206,7 +206,7 @@ EOF
self::assertEquals(2, $stmt->fetchColumn());
}
public function testReuseStatementWithReboundParam()
public function testReuseStatementWithReboundParam() : void
{
$this->connection->insert('stmt_test', ['id' => 1]);
$this->connection->insert('stmt_test', ['id' => 2]);
......@@ -225,26 +225,27 @@ EOF
}
/**
* @param mixed $expected
*
* @dataProvider emptyFetchProvider
*/
public function testFetchFromNonExecutedStatement(callable $fetch, $expected)
public function testFetchFromNonExecutedStatement(callable $fetch, $expected) : void
{
$stmt = $this->connection->prepare('SELECT id FROM stmt_test');
self::assertSame($expected, $fetch($stmt));
}
public function testCloseCursorOnNonExecutedStatement()
public function testCloseCursorOnNonExecutedStatement() : void
{
$stmt = $this->connection->prepare('SELECT id FROM stmt_test');
self::assertTrue($stmt->closeCursor());
}
/**
* @group DBAL-2637
*/
public function testCloseCursorAfterCursorEnd()
public function testCloseCursorAfterCursorEnd() : void
{
$stmt = $this->connection->prepare('SELECT name FROM stmt_test');
......@@ -255,9 +256,11 @@ EOF
}
/**
* @param mixed $expected
*
* @dataProvider emptyFetchProvider
*/
public function testFetchFromNonExecutedStatementWithClosedCursor(callable $fetch, $expected)
public function testFetchFromNonExecutedStatementWithClosedCursor(callable $fetch, $expected) : void
{
$stmt = $this->connection->prepare('SELECT id FROM stmt_test');
$stmt->closeCursor();
......@@ -266,9 +269,11 @@ EOF
}
/**
* @param mixed $expected
*
* @dataProvider emptyFetchProvider
*/
public function testFetchFromExecutedStatementWithClosedCursor(callable $fetch, $expected)
public function testFetchFromExecutedStatementWithClosedCursor(callable $fetch, $expected) : void
{
$this->connection->insert('stmt_test', ['id' => 1]);
......@@ -279,7 +284,10 @@ EOF
self::assertSame($expected, $fetch($stmt));
}
public static function emptyFetchProvider()
/**
* @return mixed[][]
*/
public static function emptyFetchProvider() : iterable
{
return [
'fetch' => [
......
......@@ -38,7 +38,7 @@ class TableGeneratorTest extends DbalFunctionalTestCase
$this->generator = new TableGenerator($this->connection);
}
public function testNextVal()
public function testNextVal() : void
{
$id1 = $this->generator->nextValue('tbl1');
$id2 = $this->generator->nextValue('tbl1');
......@@ -49,7 +49,7 @@ class TableGeneratorTest extends DbalFunctionalTestCase
self::assertEquals($id1, $id3, 'First ids from different tables are equal.');
}
public function testNextValNotAffectedByOuterTransactions()
public function testNextValNotAffectedByOuterTransactions() : void
{
$this->connection->beginTransaction();
$id1 = $this->generator->nextValue('tbl1');
......
......@@ -32,11 +32,9 @@ class TemporaryTableTest extends DbalFunctionalTestCase
}
/**
* @return void
*
* @group DDC-1337
*/
public function testDropTemporaryTableNotAutoCommitTransaction()
public function testDropTemporaryTableNotAutoCommitTransaction() : void
{
if ($this->connection->getDatabasePlatform()->getName() === 'sqlanywhere' ||
$this->connection->getDatabasePlatform()->getName() === 'oracle') {
......@@ -69,11 +67,9 @@ class TemporaryTableTest extends DbalFunctionalTestCase
}
/**
* @return void
*
* @group DDC-1337
*/
public function testCreateTemporaryTableNotAutoCommitTransaction()
public function testCreateTemporaryTableNotAutoCommitTransaction() : void
{
if ($this->connection->getDatabasePlatform()->getName() === 'sqlanywhere' ||
$this->connection->getDatabasePlatform()->getName() === 'oracle') {
......
......@@ -10,7 +10,7 @@ use Doctrine\Tests\DbalFunctionalTestCase;
*/
class DBAL168Test extends DbalFunctionalTestCase
{
public function testDomainsTable()
public function testDomainsTable() : void
{
if ($this->connection->getDatabasePlatform()->getName() !== 'postgresql') {
$this->markTestSkipped('PostgreSQL only test');
......
......@@ -29,7 +29,7 @@ class DBAL202Test extends DbalFunctionalTestCase
}
}
public function testStatementRollback()
public function testStatementRollback() : void
{
$stmt = $this->connection->prepare('INSERT INTO DBAL202 VALUES (8)');
$this->connection->beginTransaction();
......@@ -39,7 +39,7 @@ class DBAL202Test extends DbalFunctionalTestCase
self::assertEquals(0, $this->connection->query('SELECT COUNT(1) FROM DBAL202')->fetchColumn());
}
public function testStatementCommit()
public function testStatementCommit() : void
{
$stmt = $this->connection->prepare('INSERT INTO DBAL202 VALUES (8)');
$this->connection->beginTransaction();
......
......@@ -23,7 +23,7 @@ class DBAL421Test extends DbalFunctionalTestCase
$this->markTestSkipped('Currently restricted to MySQL and SQLite.');
}
public function testGuidShouldMatchPattern()
public function testGuidShouldMatchPattern() : void
{
$guid = $this->connection->query($this->getSelectGuidSql())->fetchColumn();
$pattern = '/[0-9A-F]{8}\-[0-9A-F]{4}\-[0-9A-F]{4}\-[8-9A-B][0-9A-F]{3}\-[0-9A-F]{12}/i';
......@@ -34,7 +34,7 @@ class DBAL421Test extends DbalFunctionalTestCase
* This test does (of course) not proof that all generated GUIDs are
* random, it should however provide some basic confidence.
*/
public function testGuidShouldBeRandom()
public function testGuidShouldBeRandom() : void
{
$statement = $this->connection->prepare($this->getSelectGuidSql());
$guids = [];
......@@ -49,7 +49,7 @@ class DBAL421Test extends DbalFunctionalTestCase
$statement->closeCursor();
}
private function getSelectGuidSql()
private function getSelectGuidSql() : string
{
return 'SELECT ' . $this->connection->getDatabasePlatform()->getGuidExpression();
}
......
......@@ -14,7 +14,7 @@ use ReflectionMethod;
*/
class DBAL461Test extends TestCase
{
public function testIssue()
public function testIssue() : void
{
$conn = $this->createMock(Connection::class);
$platform = $this->getMockForAbstractClass(AbstractPlatform::class);
......
......@@ -22,7 +22,7 @@ class DBAL510Test extends DbalFunctionalTestCase
$this->markTestSkipped('PostgreSQL Only test');
}
public function testSearchPathSchemaChanges()
public function testSearchPathSchemaChanges() : void
{
$table = new Table('dbal510tbl');
$table->addColumn('id', 'integer');
......
......@@ -43,7 +43,7 @@ class DBAL630Test extends DbalFunctionalTestCase
parent::tearDown();
}
public function testBooleanConversionSqlLiteral()
public function testBooleanConversionSqlLiteral() : void
{
$this->connection->executeUpdate('INSERT INTO dbal630 (bool_col) VALUES(false)');
$id = $this->connection->lastInsertId('dbal630_id_seq');
......@@ -54,7 +54,7 @@ class DBAL630Test extends DbalFunctionalTestCase
self::assertFalse($row['bool_col']);
}
public function testBooleanConversionBoolParamRealPrepares()
public function testBooleanConversionBoolParamRealPrepares() : void
{
$this->connection->executeUpdate(
'INSERT INTO dbal630 (bool_col) VALUES(?)',
......@@ -69,7 +69,7 @@ class DBAL630Test extends DbalFunctionalTestCase
self::assertFalse($row['bool_col']);
}
public function testBooleanConversionBoolParamEmulatedPrepares()
public function testBooleanConversionBoolParamEmulatedPrepares() : void
{
$this->connection->getWrappedConnection()->setAttribute(PDO::ATTR_EMULATE_PREPARES, true);
......@@ -92,9 +92,9 @@ class DBAL630Test extends DbalFunctionalTestCase
* @dataProvider booleanTypeConversionWithoutPdoTypeProvider
*/
public function testBooleanConversionNullParamEmulatedPrepares(
$statementValue,
$databaseConvertedValue
) {
?bool $statementValue,
?bool $databaseConvertedValue
) : void {
$this->connection->getWrappedConnection()->setAttribute(PDO::ATTR_EMULATE_PREPARES, true);
$platform = $this->connection->getDatabasePlatform();
......@@ -116,9 +116,9 @@ class DBAL630Test extends DbalFunctionalTestCase
* @dataProvider booleanTypeConversionUsingBooleanTypeProvider
*/
public function testBooleanConversionNullParamEmulatedPreparesWithBooleanTypeInBindValue(
$statementValue,
$databaseConvertedValue
) {
?bool $statementValue,
bool $databaseConvertedValue
) : void {
$this->connection->getWrappedConnection()->setAttribute(PDO::ATTR_EMULATE_PREPARES, true);
$platform = $this->connection->getDatabasePlatform();
......@@ -145,7 +145,7 @@ class DBAL630Test extends DbalFunctionalTestCase
*
* @return mixed[][]
*/
public function booleanTypeConversionUsingBooleanTypeProvider()
public static function booleanTypeConversionUsingBooleanTypeProvider() : iterable
{
return [
// statement value, database converted value result
......@@ -160,7 +160,7 @@ class DBAL630Test extends DbalFunctionalTestCase
*
* @return mixed[][]
*/
public function booleanTypeConversionWithoutPdoTypeProvider()
public static function booleanTypeConversionWithoutPdoTypeProvider() : iterable
{
return [
// statement value, database converted value result
......
......@@ -23,7 +23,7 @@ class DBAL752Test extends DbalFunctionalTestCase
$this->markTestSkipped('Related to SQLite only');
}
public function testUnsignedIntegerDetection()
public function testUnsignedIntegerDetection() : void
{
$this->connection->exec(<<<SQL
CREATE TABLE dbal752_unsigneds (
......
......@@ -43,6 +43,8 @@ class TypeConversionTest extends DbalFunctionalTestCase
}
/**
* @param mixed $originalValue
*
* @dataProvider booleanProvider
*/
public function testIdempotentConversionToBoolean(string $type, $originalValue) : void
......@@ -65,6 +67,8 @@ class TypeConversionTest extends DbalFunctionalTestCase
}
/**
* @param mixed $originalValue
*
* @dataProvider integerProvider
*/
public function testIdempotentConversionToInteger(string $type, $originalValue) : void
......@@ -86,6 +90,8 @@ class TypeConversionTest extends DbalFunctionalTestCase
}
/**
* @param mixed $originalValue
*
* @dataProvider floatProvider
*/
public function testIdempotentConversionToFloat(string $type, $originalValue) : void
......@@ -107,6 +113,8 @@ class TypeConversionTest extends DbalFunctionalTestCase
}
/**
* @param mixed $originalValue
*
* @dataProvider toStringProvider
*/
public function testIdempotentConversionToString(string $type, $originalValue) : void
......@@ -137,6 +145,8 @@ class TypeConversionTest extends DbalFunctionalTestCase
}
/**
* @param mixed $originalValue
*
* @dataProvider toArrayProvider
*/
public function testIdempotentConversionToArray(string $type, $originalValue) : void
......@@ -159,6 +169,8 @@ class TypeConversionTest extends DbalFunctionalTestCase
}
/**
* @param mixed $originalValue
*
* @dataProvider toObjectProvider
*/
public function testIdempotentConversionToObject(string $type, $originalValue) : void
......@@ -218,6 +230,8 @@ class TypeConversionTest extends DbalFunctionalTestCase
/**
* @param mixed $originalValue
*
* @return mixed
*/
private function processValue(string $type, $originalValue)
{
......
......@@ -36,7 +36,7 @@ class BinaryTest extends DbalFunctionalTestCase
$sm->dropAndCreateTable($table);
}
public function testInsertAndSelect()
public function testInsertAndSelect() : void
{
$id1 = random_bytes(16);
$id2 = random_bytes(16);
......@@ -70,6 +70,9 @@ class BinaryTest extends DbalFunctionalTestCase
self::assertSame(1, $result);
}
/**
* @return mixed
*/
private function select(string $id)
{
$value = $this->connection->fetchColumn(
......
......@@ -35,7 +35,7 @@ class WriteTest extends DbalFunctionalTestCase
/**
* @group DBAL-80
*/
public function testExecuteUpdateFirstTypeIsNull()
public function testExecuteUpdateFirstTypeIsNull() : void
{
$sql = 'INSERT INTO write_table (test_string, test_int) VALUES (?, ?)';
$this->connection->executeUpdate($sql, ['text', 1111], [null, ParameterType::INTEGER]);
......@@ -44,7 +44,7 @@ class WriteTest extends DbalFunctionalTestCase
self::assertTrue((bool) $this->connection->fetchColumn($sql, ['text', 1111]));
}
public function testExecuteUpdate()
public function testExecuteUpdate() : void
{
$sql = 'INSERT INTO write_table (test_int) VALUES ( ' . $this->connection->quote(1) . ')';
$affected = $this->connection->executeUpdate($sql);
......@@ -52,7 +52,7 @@ class WriteTest extends DbalFunctionalTestCase
self::assertEquals(1, $affected, 'executeUpdate() should return the number of affected rows!');
}
public function testExecuteUpdateWithTypes()
public function testExecuteUpdateWithTypes() : void
{
$sql = 'INSERT INTO write_table (test_int, test_string) VALUES (?, ?)';
$affected = $this->connection->executeUpdate(
......@@ -64,7 +64,7 @@ class WriteTest extends DbalFunctionalTestCase
self::assertEquals(1, $affected, 'executeUpdate() should return the number of affected rows!');
}
public function testPrepareRowCountReturnsAffectedRows()
public function testPrepareRowCountReturnsAffectedRows() : void
{
$sql = 'INSERT INTO write_table (test_int, test_string) VALUES (?, ?)';
$stmt = $this->connection->prepare($sql);
......@@ -76,7 +76,7 @@ class WriteTest extends DbalFunctionalTestCase
self::assertEquals(1, $stmt->rowCount());
}
public function testPrepareWithPdoTypes()
public function testPrepareWithPdoTypes() : void
{
$sql = 'INSERT INTO write_table (test_int, test_string) VALUES (?, ?)';
$stmt = $this->connection->prepare($sql);
......@@ -88,7 +88,7 @@ class WriteTest extends DbalFunctionalTestCase
self::assertEquals(1, $stmt->rowCount());
}
public function testPrepareWithDbalTypes()
public function testPrepareWithDbalTypes() : void
{
$sql = 'INSERT INTO write_table (test_int, test_string) VALUES (?, ?)';
$stmt = $this->connection->prepare($sql);
......@@ -100,7 +100,7 @@ class WriteTest extends DbalFunctionalTestCase
self::assertEquals(1, $stmt->rowCount());
}
public function testPrepareWithDbalTypeNames()
public function testPrepareWithDbalTypeNames() : void
{
$sql = 'INSERT INTO write_table (test_int, test_string) VALUES (?, ?)';
$stmt = $this->connection->prepare($sql);
......@@ -112,18 +112,18 @@ class WriteTest extends DbalFunctionalTestCase
self::assertEquals(1, $stmt->rowCount());
}
public function insertRows()
public function insertRows() : void
{
self::assertEquals(1, $this->connection->insert('write_table', ['test_int' => 1, 'test_string' => 'foo']));
self::assertEquals(1, $this->connection->insert('write_table', ['test_int' => 2, 'test_string' => 'bar']));
}
public function testInsert()
public function testInsert() : void
{
$this->insertRows();
}
public function testDelete()
public function testDelete() : void
{
$this->insertRows();
......@@ -134,7 +134,7 @@ class WriteTest extends DbalFunctionalTestCase
self::assertCount(0, $this->connection->fetchAll('SELECT * FROM write_table'));
}
public function testUpdate()
public function testUpdate() : void
{
$this->insertRows();
......@@ -143,7 +143,7 @@ class WriteTest extends DbalFunctionalTestCase
self::assertEquals(0, $this->connection->update('write_table', ['test_string' => 'baz'], ['test_string' => 'bar']));
}
public function testLastInsertId()
public function testLastInsertId() : void
{
if (! $this->connection->getDatabasePlatform()->prefersIdentityColumns()) {
$this->markTestSkipped('Test only works on platforms with identity columns.');
......@@ -156,7 +156,7 @@ class WriteTest extends DbalFunctionalTestCase
self::assertGreaterThan(0, $num, 'LastInsertId() should be non-negative number.');
}
public function testLastInsertIdSequence()
public function testLastInsertIdSequence() : void
{
if (! $this->connection->getDatabasePlatform()->supportsSequences()) {
$this->markTestSkipped('Test only works on platforms with sequences.');
......@@ -182,7 +182,7 @@ class WriteTest extends DbalFunctionalTestCase
self::assertEquals($nextSequenceVal, $lastInsertId);
}
public function testLastInsertIdNoSequenceGiven()
public function testLastInsertIdNoSequenceGiven() : void
{
if (! $this->connection->getDatabasePlatform()->supportsSequences() || $this->connection->getDatabasePlatform()->supportsIdentityColumns()) {
$this->markTestSkipped("Test only works consistently on platforms that support sequences and don't support identity columns.");
......@@ -194,7 +194,7 @@ class WriteTest extends DbalFunctionalTestCase
/**
* @group DBAL-445
*/
public function testInsertWithKeyValueTypes()
public function testInsertWithKeyValueTypes() : void
{
$testString = new DateTime('2013-04-14 10:10:10');
......@@ -212,7 +212,7 @@ class WriteTest extends DbalFunctionalTestCase
/**
* @group DBAL-445
*/
public function testUpdateWithKeyValueTypes()
public function testUpdateWithKeyValueTypes() : void
{
$testString = new DateTime('2013-04-14 10:10:10');
......@@ -239,7 +239,7 @@ class WriteTest extends DbalFunctionalTestCase
/**
* @group DBAL-445
*/
public function testDeleteWithKeyValueTypes()
public function testDeleteWithKeyValueTypes() : void
{
$val = new DateTime('2013-04-14 10:10:10');
$this->connection->insert(
......@@ -255,7 +255,7 @@ class WriteTest extends DbalFunctionalTestCase
self::assertFalse($data);
}
public function testEmptyIdentityInsert()
public function testEmptyIdentityInsert() : void
{
$platform = $this->connection->getDatabasePlatform();
......@@ -298,7 +298,7 @@ class WriteTest extends DbalFunctionalTestCase
/**
* @group DBAL-2688
*/
public function testUpdateWhereIsNull()
public function testUpdateWhereIsNull() : void
{
$this->connection->insert(
'write_table',
......@@ -317,7 +317,7 @@ class WriteTest extends DbalFunctionalTestCase
self::assertCount(0, $data);
}
public function testDeleteWhereIsNull()
public function testDeleteWhereIsNull() : void
{
$this->connection->insert(
'write_table',
......@@ -340,7 +340,7 @@ class WriteTest extends DbalFunctionalTestCase
* Returns the ID of the last inserted row or skips the test if the currently used driver
* doesn't support this feature
*
* @return string
* @return string|false
*
* @throws DriverException
*/
......
......@@ -20,7 +20,7 @@ class DebugStackTest extends DbalTestCase
unset($this->logger);
}
public function testLoggedQuery()
public function testLoggedQuery() : void
{
$this->logger->startQuery('SELECT column FROM table');
self::assertEquals(
......@@ -39,7 +39,7 @@ class DebugStackTest extends DbalTestCase
self::assertGreaterThan(0, $this->logger->queries[1]['executionMS']);
}
public function testLoggedQueryDisabled()
public function testLoggedQueryDisabled() : void
{
$this->logger->enabled = false;
$this->logger->startQuery('SELECT column FROM table');
......
......@@ -17,7 +17,7 @@ class TypeConversionPerformanceTest extends DbalPerformanceTestCase
*
* @dataProvider itemCountProvider
*/
public function testDateTimeTypeConversionPerformance($count)
public function testDateTimeTypeConversionPerformance(int $count) : void
{
$value = new DateTime();
$type = Type::getType('datetime');
......@@ -29,7 +29,10 @@ class TypeConversionPerformanceTest extends DbalPerformanceTestCase
$this->stopTiming();
}
public function itemCountProvider()
/**
* @return mixed[][]
*/
public static function itemCountProvider() : iterable
{
return [
'100 items' => [100],
......
......@@ -2,6 +2,7 @@
namespace Doctrine\Tests\DBAL\Platforms;
use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Platforms\MariaDb1027Platform;
use Doctrine\DBAL\Types\Types;
......@@ -10,7 +11,7 @@ class MariaDb1027PlatformTest extends AbstractMySQLPlatformTestCase
/**
* {@inheritdoc}
*/
public function createPlatform() : MariaDb1027Platform
public function createPlatform() : AbstractPlatform
{
return new MariaDb1027Platform();
}
......
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