Unverified Commit f9b3e790 authored by Michael Moravec's avatar Michael Moravec Committed by Sergei Morozov

Enable PHPStan in tests

parent be458b5d
......@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "c80faa771bd92a02a1deef849df31e83",
"content-hash": "b8d34165a2e5fbd1c74f7a5125e7d9f1",
"packages": [
{
"name": "doctrine/cache",
......@@ -1582,6 +1582,63 @@
"description": "PHPStan - PHP Static Analysis Tool",
"time": "2019-08-18T20:51:53+00:00"
},
{
"name": "phpstan/phpstan-phpunit",
"version": "0.11.2",
"source": {
"type": "git",
"url": "https://github.com/phpstan/phpstan-phpunit.git",
"reference": "fbf2ad56c3b13189d29655e226c9b1da47c2fad9"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/phpstan/phpstan-phpunit/zipball/fbf2ad56c3b13189d29655e226c9b1da47c2fad9",
"reference": "fbf2ad56c3b13189d29655e226c9b1da47c2fad9",
"shasum": ""
},
"require": {
"nikic/php-parser": "^4.0",
"php": "~7.1",
"phpstan/phpdoc-parser": "^0.3",
"phpstan/phpstan": "^0.11.4"
},
"conflict": {
"phpunit/phpunit": "<7.0"
},
"require-dev": {
"consistence/coding-standard": "^3.0.1",
"dealerdirect/phpcodesniffer-composer-installer": "^0.4.4",
"jakub-onderka/php-parallel-lint": "^1.0",
"phing/phing": "^2.16.0",
"phpstan/phpstan-strict-rules": "^0.11",
"phpunit/phpunit": "^7.0",
"satooshi/php-coveralls": "^1.0",
"slevomat/coding-standard": "^4.5.2"
},
"type": "phpstan-extension",
"extra": {
"branch-alias": {
"dev-master": "0.11-dev"
},
"phpstan": {
"includes": [
"extension.neon",
"rules.neon"
]
}
},
"autoload": {
"psr-4": {
"PHPStan\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"description": "PHPUnit extensions and rules for PHPStan",
"time": "2019-05-17T17:50:16+00:00"
},
{
"name": "phpunit/php-code-coverage",
"version": "7.0.8",
......
......@@ -2,6 +2,7 @@ parameters:
level: 7
paths:
- %currentWorkingDirectory%/lib
- %currentWorkingDirectory%/tests
autoload_files:
- %currentWorkingDirectory%/tests/phpstan-polyfill.php
reportUnmatchedIgnoredErrors: false
......@@ -63,3 +64,26 @@ parameters:
-
message: '~^Strict comparison using === between string|false and null will always evaluate to false\.~'
path: %currentWorkingDirectory%/lib/Doctrine/DBAL/Driver/PDOStatement.php
# impossible inference for covariance
- '~^Property Doctrine\\Tests\\DBAL\\Types\\\S+Test::\$type \(Doctrine\\DBAL\\Types\\\S+Type\) does not accept Doctrine\\DBAL\\Types\\Type\.\z~'
- '~^Property Doctrine\\Tests\\DBAL\\Tools\\Console\\RunSqlCommandTest::\$command \(Doctrine\\DBAL\\Tools\\Console\\Command\\RunSqlCommand\) does not accept Symfony\\Component\\Console\\Command\\Command\.\z~'
# https://github.com/phpstan/phpstan-phpunit/pull/28
-
message: '~Call to method expects\(\) on an unknown class \S+~'
path: %currentWorkingDirectory%/tests/Doctrine/Tests/DBAL/Platforms/AbstractPlatformTestCase.php
-
message: '~Call to method expects\(\) on an unknown class \S+~'
path: %currentWorkingDirectory%/tests/Doctrine/Tests/DBAL/ConnectionTest.php
-
message: '~Call to method expects\(\) on an unknown class \S+~'
path: %currentWorkingDirectory%/tests/Doctrine/Tests/DBAL/Functional/Schema/SchemaManagerFunctionalTestCase.php
# https://github.com/doctrine/dbal/pull/3582/files#r290847062
-
message: '~Parameter #3 \$type of method Doctrine\\DBAL\\Driver\\Statement::bindValue\(\) expects int, string given\.~'
path: %currentWorkingDirectory%/tests/Doctrine/Tests/DBAL/Functional/DataAccessTest.php
includes:
- vendor/phpstan/phpstan-phpunit/extension.neon
- vendor/phpstan/phpstan-phpunit/rules.neon
......@@ -136,8 +136,8 @@ class ArrayStatementTest extends TestCase
$statement = $this->createTestArrayStatement();
self::assertSame(true, $statement->fetchColumn(1));
self::assertSame(false, $statement->fetchColumn(1));
self::assertTrue($statement->fetchColumn(1));
self::assertFalse($statement->fetchColumn(1));
}
private function createTestArrayStatement() : ArrayStatement
......
......@@ -23,7 +23,7 @@ class QueryCacheProfileTest extends DbalTestCase
/** @var int[] */
private $params = [666];
/** @var string[] */
/** @var int[] */
private $types = [ParameterType::INTEGER];
/** @var string[] */
......
......@@ -198,6 +198,9 @@ abstract class AbstractDriverTest extends DbalTestCase
*/
abstract protected function createSchemaManager(Connection $connection) : AbstractSchemaManager;
/**
* @return Connection|MockObject
*/
protected function getConnectionMock() : Connection
{
return $this->getMockBuilder(Connection::class)
......
......@@ -58,7 +58,7 @@ class MysqliConnectionTest extends DbalFunctionalTestCase
// Do nothing
}
self::assertSame($handler, set_error_handler($default_handler), 'Restoring error handler failed.');
self::assertSame($handler, set_error_handler($handler), 'Restoring error handler failed.');
restore_error_handler();
restore_error_handler();
}
......
......@@ -6,7 +6,6 @@ namespace Doctrine\Tests\DBAL\Driver;
use Doctrine\DBAL\Driver\PDOException;
use Doctrine\Tests\DbalTestCase;
use PHPUnit\Framework\MockObject\MockObject;
/**
* @requires extension pdo
......@@ -29,7 +28,7 @@ class PDOExceptionTest extends DbalTestCase
/**
* The wrapped PDO exception mock.
*
* @var \PDOException|MockObject
* @var \PDOException
*/
private $wrappedException;
......
......@@ -15,8 +15,9 @@ use Doctrine\DBAL\Portability\Statement as PortabilityStatement;
use Doctrine\Tests\DbalTestCase;
use IteratorAggregate;
use PHPUnit\Framework\MockObject\MockObject;
use Traversable;
use function assert;
use function extension_loaded;
use function is_iterable;
class StatementIteratorTest extends DbalTestCase
{
......@@ -43,7 +44,9 @@ class StatementIteratorTest extends DbalTestCase
$stmtIterator = new StatementIterator($stmt);
$this->assertIterationCallsFetchOncePerStep($stmtIterator, $calls);
foreach ($stmtIterator as $i => $_) {
$this->assertEquals($i + 1, $calls);
}
}
/**
......@@ -52,10 +55,14 @@ class StatementIteratorTest extends DbalTestCase
public function testStatementIterationCallsFetchOncePerStep(string $class) : void
{
$stmt = $this->createPartialMock($class, ['fetch']);
assert(is_iterable($stmt));
$calls = 0;
$this->configureStatement($stmt, $calls);
$this->assertIterationCallsFetchOncePerStep($stmt, $calls);
foreach ($stmt as $i => $_) {
$this->assertEquals($i + 1, $calls);
}
}
private function configureStatement(MockObject $stmt, int &$calls) : void
......@@ -73,13 +80,6 @@ class StatementIteratorTest extends DbalTestCase
});
}
private function assertIterationCallsFetchOncePerStep(Traversable $iterator, int &$calls) : void
{
foreach ($iterator as $i => $_) {
$this->assertEquals($i + 1, $calls);
}
}
/**
* @return string[][]
*/
......
......@@ -196,7 +196,7 @@ class DriverManagerTest extends DbalTestCase
}
/**
* @return array<string, array<int, mixed>>
* @return array<string, mixed>
*/
public function databaseUrls() : iterable
{
......
......@@ -28,9 +28,11 @@ use const PHP_EOL;
use function array_change_key_case;
use function array_filter;
use function array_keys;
use function assert;
use function count;
use function date;
use function implode;
use function is_array;
use function is_numeric;
use function json_encode;
use function property_exists;
......@@ -521,6 +523,8 @@ class DataAccessTest extends DbalFunctionalTestCase
'FROM fetch_table';
$row = $this->connection->fetchAssoc($sql);
self::assertIsArray($row);
$row = array_change_key_case($row, CASE_LOWER);
self::assertEquals($expectedResult, $row['trimmed']);
......@@ -931,6 +935,8 @@ class DataAccessTest extends DbalFunctionalTestCase
$sql .= 'FROM fetch_table';
$row = $this->connection->fetchAssoc($sql);
assert(is_array($row));
$row = array_change_key_case($row, CASE_LOWER);
self::assertEquals(2, $row['locate1']);
......
......@@ -5,8 +5,10 @@ declare(strict_types=1);
namespace Doctrine\Tests\DBAL\Functional\Driver\IBMDB2;
use Doctrine\DBAL\Driver\IBMDB2\DB2Driver;
use Doctrine\DBAL\Statement;
use Doctrine\Tests\DbalFunctionalTestCase;
use PHPUnit\Framework\Error\Notice;
use function assert;
use function extension_loaded;
class DB2StatementTest extends DbalFunctionalTestCase
......@@ -29,6 +31,7 @@ class DB2StatementTest extends DbalFunctionalTestCase
public function testExecutionErrorsAreNotSuppressed() : void
{
$stmt = $this->connection->prepare('SELECT * FROM SYSIBM.SYSDUMMY1 WHERE \'foo\' = ?');
assert($stmt instanceof Statement);
// unwrap the statement to prevent the wrapper from handling the PHPUnit-originated exception
$wrappedStmt = $stmt->getWrappedStatement();
......
......@@ -8,6 +8,7 @@ use Doctrine\DBAL\Driver\OCI8\Driver;
use Doctrine\DBAL\Driver\OCI8\OCI8Connection;
use Doctrine\DBAL\Schema\Table;
use Doctrine\Tests\DbalFunctionalTestCase;
use function assert;
use function extension_loaded;
class OCI8ConnectionTest extends DbalFunctionalTestCase
......@@ -27,7 +28,10 @@ class OCI8ConnectionTest extends DbalFunctionalTestCase
$this->markTestSkipped('oci8 only test.');
}
$this->driverConnection = $this->connection->getWrappedConnection();
$wrappedConnection = $this->connection->getWrappedConnection();
assert($wrappedConnection instanceof OCI8Connection);
$this->driverConnection = $wrappedConnection;
}
/**
......
......@@ -30,13 +30,13 @@ class PDOConnectionTest extends DbalFunctionalTestCase
{
parent::setUp();
$this->driverConnection = $this->connection->getWrappedConnection();
$wrappedConnection = $this->connection->getWrappedConnection();
if ($this->driverConnection instanceof PDOConnection) {
return;
if (! $wrappedConnection instanceof PDOConnection) {
$this->markTestSkipped('PDO connection only test.');
}
$this->markTestSkipped('PDO connection only test.');
$this->driverConnection = $wrappedConnection;
}
protected function tearDown() : void
......
......@@ -38,7 +38,7 @@ class StatementTest extends DbalFunctionalTestCase
self::assertTrue($conn->isConnected(), 'No SQLAnywhere-Connection established');
$prepStmt = $conn->prepare('SELECT 1');
self::assertTrue($prepStmt->execute(), ' Statement non-persistent failed');
$prepStmt->execute();
}
public function testPersistentStatement() : void
......@@ -53,6 +53,6 @@ class StatementTest extends DbalFunctionalTestCase
self::assertTrue($conn->isConnected(), 'No SQLAnywhere-Connection established');
$prepStmt = $conn->prepare('SELECT 1');
self::assertTrue($prepStmt->execute(), ' Statement persistent failed');
$prepStmt->execute();
}
}
......@@ -12,6 +12,7 @@ use Doctrine\Tests\DbalFunctionalTestCase;
use Throwable;
use const CASE_LOWER;
use function array_change_key_case;
use function assert;
use function sprintf;
use function strlen;
use function strtolower;
......@@ -49,7 +50,10 @@ class MasterSlaveConnectionTest extends DbalFunctionalTestCase
private function createMasterSlaveConnection(bool $keepSlave = false) : MasterSlaveConnection
{
return DriverManager::getConnection($this->createMasterSlaveConnectionParams($keepSlave));
$connection = DriverManager::getConnection($this->createMasterSlaveConnectionParams($keepSlave));
assert($connection instanceof MasterSlaveConnection);
return $connection;
}
/**
......
......@@ -21,11 +21,16 @@ class PortabilityTest extends DbalFunctionalTestCase
/** @var Connection */
private $portableConnection;
protected function setUp() : void
{
parent::setUp();
$this->portableConnection = $this->getPortableConnection();
}
protected function tearDown() : void
{
if ($this->portableConnection) {
$this->portableConnection->close();
}
$this->portableConnection->close();
parent::tearDown();
}
......@@ -34,64 +39,62 @@ class PortabilityTest extends DbalFunctionalTestCase
int $portabilityMode = ConnectionPortability::PORTABILITY_ALL,
int $case = ColumnCase::LOWER
) : Connection {
if (! $this->portableConnection) {
$params = $this->connection->getParams();
$params['wrapperClass'] = ConnectionPortability::class;
$params['portability'] = $portabilityMode;
$params['fetch_case'] = $case;
$this->portableConnection = DriverManager::getConnection($params, $this->connection->getConfiguration(), $this->connection->getEventManager());
$table = new Table('portability_table');
$table->addColumn('Test_Int', 'integer');
$table->addColumn('Test_String', 'string', [
'length' => 8,
'fixed' => true,
]);
$table->addColumn('Test_Null', 'string', [
'length' => 1,
'notnull' => false,
]);
$table->setPrimaryKey(['Test_Int']);
$sm = $this->portableConnection->getSchemaManager();
$sm->dropAndCreateTable($table);
$this->portableConnection->insert('portability_table', [
'Test_Int' => 1,
'Test_String' => 'foo',
'Test_Null' => '',
]);
$this->portableConnection->insert('portability_table', [
'Test_Int' => 2,
'Test_String' => 'foo ',
'Test_Null' => null,
]);
}
return $this->portableConnection;
$params = $this->connection->getParams();
$params['wrapperClass'] = ConnectionPortability::class;
$params['portability'] = $portabilityMode;
$params['fetch_case'] = $case;
$portableConnection = DriverManager::getConnection($params, $this->connection->getConfiguration(), $this->connection->getEventManager());
$table = new Table('portability_table');
$table->addColumn('Test_Int', 'integer');
$table->addColumn('Test_String', 'string', [
'length' => 8,
'fixed' => true,
]);
$table->addColumn('Test_Null', 'string', [
'length' => 1,
'notnull' => false,
]);
$table->setPrimaryKey(['Test_Int']);
$sm = $portableConnection->getSchemaManager();
$sm->dropAndCreateTable($table);
$portableConnection->insert('portability_table', [
'Test_Int' => 1,
'Test_String' => 'foo',
'Test_Null' => '',
]);
$portableConnection->insert('portability_table', [
'Test_Int' => 2,
'Test_String' => 'foo ',
'Test_Null' => null,
]);
return $portableConnection;
}
public function testFullFetchMode() : void
{
$rows = $this->getPortableConnection()->fetchAll('SELECT * FROM portability_table');
$rows = $this->portableConnection->fetchAll('SELECT * FROM portability_table');
$this->assertFetchResultRows($rows);
$stmt = $this->getPortableConnection()->query('SELECT * FROM portability_table');
$stmt = $this->portableConnection->query('SELECT * FROM portability_table');
$stmt->setFetchMode(FetchMode::ASSOCIATIVE);
foreach ($stmt as $row) {
$this->assertFetchResultRow($row);
}
$stmt = $this->getPortableConnection()->query('SELECT * FROM portability_table');
$stmt = $this->portableConnection->query('SELECT * FROM portability_table');
while (($row = $stmt->fetch(FetchMode::ASSOCIATIVE))) {
$this->assertFetchResultRow($row);
}
$stmt = $this->getPortableConnection()->prepare('SELECT * FROM portability_table');
$stmt = $this->portableConnection->prepare('SELECT * FROM portability_table');
$stmt->execute();
while (($row = $stmt->fetch(FetchMode::ASSOCIATIVE))) {
......@@ -101,23 +104,22 @@ class PortabilityTest extends DbalFunctionalTestCase
public function testConnFetchMode() : void
{
$conn = $this->getPortableConnection();
$conn->setFetchMode(FetchMode::ASSOCIATIVE);
$this->portableConnection->setFetchMode(FetchMode::ASSOCIATIVE);
$rows = $conn->fetchAll('SELECT * FROM portability_table');
$rows = $this->portableConnection->fetchAll('SELECT * FROM portability_table');
$this->assertFetchResultRows($rows);
$stmt = $conn->query('SELECT * FROM portability_table');
$stmt = $this->portableConnection->query('SELECT * FROM portability_table');
foreach ($stmt as $row) {
$this->assertFetchResultRow($row);
}
$stmt = $conn->query('SELECT * FROM portability_table');
$stmt = $this->portableConnection->query('SELECT * FROM portability_table');
while (($row = $stmt->fetch())) {
$this->assertFetchResultRow($row);
}
$stmt = $conn->prepare('SELECT * FROM portability_table');
$stmt = $this->portableConnection->prepare('SELECT * FROM portability_table');
$stmt->execute();
while (($row = $stmt->fetch())) {
$this->assertFetchResultRow($row);
......@@ -154,8 +156,7 @@ class PortabilityTest extends DbalFunctionalTestCase
*/
public function testFetchAllColumn(string $field, array $expected) : void
{
$conn = $this->getPortableConnection();
$stmt = $conn->query('SELECT ' . $field . ' FROM portability_table');
$stmt = $this->portableConnection->query('SELECT ' . $field . ' FROM portability_table');
$column = $stmt->fetchAll(FetchMode::COLUMN);
self::assertEquals($expected, $column);
......@@ -180,8 +181,7 @@ class PortabilityTest extends DbalFunctionalTestCase
public function testFetchAllNullColumn() : void
{
$conn = $this->getPortableConnection();
$stmt = $conn->query('SELECT Test_Null FROM portability_table');
$stmt = $this->portableConnection->query('SELECT Test_Null FROM portability_table');
$column = $stmt->fetchAll(FetchMode::COLUMN);
self::assertSame([null, null], $column);
......
......@@ -23,7 +23,7 @@ use function is_array;
*/
class ResultCacheTest extends DbalFunctionalTestCase
{
/** @var array<int, array<int, int|string>> */
/** @var array<int, array<string, int|string>> */
private $expectedResult = [['test_int' => 100, 'test_string' => 'foo'], ['test_int' => 200, 'test_string' => 'bar'], ['test_int' => 300, 'test_string' => 'baz']];
/** @var DebugStack */
......@@ -192,7 +192,7 @@ class ResultCacheTest extends DbalFunctionalTestCase
}
/**
* @param array<int, array<int, int|string>> $expectedResult
* @param array<int, mixed> $expectedResult
*/
private function assertCacheNonCacheSelectSameFetchModeAreEqual(array $expectedResult, int $fetchMode) : void
{
......
......@@ -45,7 +45,12 @@ class MySqlSchemaManagerTest extends SchemaManagerFunctionalTestCase
$tableNew->setPrimaryKey(['bar_id', 'foo_id']);
$comparator = new Comparator();
$this->schemaManager->alterTable($comparator->diffTable($tableFetched, $tableNew));
$diff = $comparator->diffTable($tableFetched, $tableNew);
self::assertNotNull($diff);
$this->schemaManager->alterTable($diff);
$table = $this->schemaManager->listTableDetails('switch_primary_key_columns');
$primaryKey = $table->getPrimaryKeyColumns();
......@@ -120,7 +125,11 @@ class MySqlSchemaManagerTest extends SchemaManagerFunctionalTestCase
$diffTable->dropIndex('idx_id');
$diffTable->setPrimaryKey(['id']);
$this->schemaManager->alterTable($comparator->diffTable($table, $diffTable));
$diff = $comparator->diffTable($table, $diffTable);
self::assertNotNull($diff);
$this->schemaManager->alterTable($diff);
$table = $this->schemaManager->listTableDetails('alter_table_add_pk');
......@@ -146,7 +155,11 @@ class MySqlSchemaManagerTest extends SchemaManagerFunctionalTestCase
$comparator = new Comparator();
$this->schemaManager->alterTable($comparator->diffTable($table, $diffTable));
$diff = $comparator->diffTable($table, $diffTable);
self::assertNotNull($diff);
$this->schemaManager->alterTable($diff);
$table = $this->schemaManager->listTableDetails('drop_primary_key');
......@@ -184,7 +197,11 @@ class MySqlSchemaManagerTest extends SchemaManagerFunctionalTestCase
$comparator = new Comparator();
$this->schemaManager->alterTable($comparator->diffTable($table, $onlineTable));
$diff = $comparator->diffTable($table, $onlineTable);
self::assertNotNull($diff);
$this->schemaManager->alterTable($diff);
$onlineTable = $this->schemaManager->listTableDetails('text_blob_default_value');
......@@ -227,7 +244,11 @@ class MySqlSchemaManagerTest extends SchemaManagerFunctionalTestCase
$comparator = new Comparator();
$this->schemaManager->alterTable($comparator->diffTable($table, $diffTable));
$diff = $comparator->diffTable($table, $diffTable);
self::assertNotNull($diff);
$this->schemaManager->alterTable($diff);
$table = $this->schemaManager->listTableDetails($tableName);
......
......@@ -44,7 +44,7 @@ class OracleSchemaManagerTest extends SchemaManagerFunctionalTestCase
$tables = $this->schemaManager->listTables();
self::assertHasTable($tables, 'list_tables_test_new_name');
self::assertHasTable($tables);
}
public function testListTableWithBinary() : void
......@@ -98,7 +98,11 @@ class OracleSchemaManagerTest extends SchemaManagerFunctionalTestCase
$diffTable->changeColumn('foo', ['notnull' => false]);
$diffTable->changeColumn('bar', ['length' => 1024]);
$this->schemaManager->alterTable($comparator->diffTable($table, $diffTable));
$diff = $comparator->diffTable($table, $diffTable);
self::assertNotNull($diff);
$this->schemaManager->alterTable($diff);
$columns = $this->schemaManager->listTableColumns($tableName);
......
......@@ -9,6 +9,7 @@ use Doctrine\DBAL\Platforms\PostgreSQL94Platform;
use Doctrine\DBAL\Schema;
use Doctrine\DBAL\Schema\Comparator;
use Doctrine\DBAL\Schema\ForeignKeyConstraint;
use Doctrine\DBAL\Schema\PostgreSqlSchemaManager;
use Doctrine\DBAL\Schema\Table;
use Doctrine\DBAL\Schema\TableDiff;
use Doctrine\DBAL\Types\BlobType;
......@@ -23,14 +24,13 @@ use function strtolower;
class PostgreSqlSchemaManagerTest extends SchemaManagerFunctionalTestCase
{
/** @var PostgreSqlSchemaManager */
protected $schemaManager;
protected function tearDown() : void
{
parent::tearDown();
if (! $this->connection) {
return;
}
$this->connection->getConfiguration()->setSchemaAssetsFilter(null);
}
......@@ -109,7 +109,10 @@ class PostgreSqlSchemaManagerTest extends SchemaManagerFunctionalTestCase
$c = new Comparator();
$diff = $c->diffTable($tableFrom, $tableTo);
$sql = $this->connection->getDatabasePlatform()->getAlterTableSQL($diff);
self::assertNotNull($diff);
$sql = $this->connection->getDatabasePlatform()->getAlterTableSQL($diff);
self::assertEquals([
'CREATE SEQUENCE autoinc_table_add_id_seq',
"SELECT setval('autoinc_table_add_id_seq', (SELECT MAX(id) FROM autoinc_table_add))",
......@@ -138,6 +141,9 @@ class PostgreSqlSchemaManagerTest extends SchemaManagerFunctionalTestCase
$c = new Comparator();
$diff = $c->diffTable($tableFrom, $tableTo);
self::assertNotNull($diff);
self::assertInstanceOf(TableDiff::class, $diff, 'There should be a difference and not false being returned from the table comparison');
self::assertEquals(['ALTER TABLE autoinc_table_drop ALTER id DROP DEFAULT'], $this->connection->getDatabasePlatform()->getAlterTableSQL($diff));
......
......@@ -29,7 +29,7 @@ class SQLServerSchemaManagerTest extends SchemaManagerFunctionalTestCase
$this->schemaManager->createTable($table);
$diff = new TableDiff('sqlsrv_drop_column', [], [], [new Column('todrop', Type::getType('decimal'))]);
$diff = new TableDiff('sqlsrv_drop_column', [], [], ['todrop' => new Column('todrop', Type::getType('decimal'))]);
$this->schemaManager->alterTable($diff);
$columns = $this->schemaManager->listTableColumns('sqlsrv_drop_column');
......
......@@ -7,6 +7,7 @@ namespace Doctrine\Tests\DBAL\Functional\Schema;
use Doctrine\Common\EventManager;
use Doctrine\DBAL\DBALException;
use Doctrine\DBAL\Driver\Connection;
use Doctrine\DBAL\Driver\Statement;
use Doctrine\DBAL\Events;
use Doctrine\DBAL\Platforms\OraclePlatform;
use Doctrine\DBAL\Schema\AbstractAsset;
......@@ -38,11 +39,13 @@ use function array_keys;
use function array_map;
use function array_search;
use function array_values;
use function assert;
use function count;
use function current;
use function end;
use function explode;
use function in_array;
use function is_string;
use function sprintf;
use function str_replace;
use function strcasecmp;
......@@ -60,8 +63,9 @@ abstract class SchemaManagerFunctionalTestCase extends DbalFunctionalTestCase
$class = static::class;
$e = explode('\\', $class);
$testClass = end($e);
assert(is_string($testClass));
return strtolower(str_replace('SchemaManagerTest', null, $testClass));
return strtolower(str_replace('SchemaManagerTest', '', $testClass));
}
protected function setUp() : void
......@@ -379,6 +383,7 @@ abstract class SchemaManagerFunctionalTestCase extends DbalFunctionalTestCase
->method('onSchemaColumnDefinition');
$oldEventManager = $this->schemaManager->getDatabasePlatform()->getEventManager();
assert($oldEventManager instanceof EventManager);
$eventManager = new EventManager();
$eventManager->addEventListener([Events::onSchemaColumnDefinition], $listenerMock);
......@@ -406,6 +411,7 @@ abstract class SchemaManagerFunctionalTestCase extends DbalFunctionalTestCase
->method('onSchemaIndexDefinition');
$oldEventManager = $this->schemaManager->getDatabasePlatform()->getEventManager();
assert($oldEventManager instanceof EventManager);
$eventManager = new EventManager();
$eventManager->addEventListener([Events::onSchemaIndexDefinition], $listenerMock);
......@@ -580,9 +586,9 @@ abstract class SchemaManagerFunctionalTestCase extends DbalFunctionalTestCase
self::assertFalse($table->hasColumn('test'));
self::assertTrue($table->hasColumn('foo'));
$tableDiff = new TableDiff('alter_table');
$tableDiff->fromTable = $table;
$tableDiff->addedIndexes[] = new Index('foo_idx', ['foo']);
$tableDiff = new TableDiff('alter_table');
$tableDiff->fromTable = $table;
$tableDiff->addedIndexes['foo_idx'] = new Index('foo_idx', ['foo']);
$this->schemaManager->alterTable($tableDiff);
......@@ -593,9 +599,9 @@ abstract class SchemaManagerFunctionalTestCase extends DbalFunctionalTestCase
self::assertFalse($table->getIndex('foo_idx')->isPrimary());
self::assertFalse($table->getIndex('foo_idx')->isUnique());
$tableDiff = new TableDiff('alter_table');
$tableDiff->fromTable = $table;
$tableDiff->changedIndexes[] = new Index('foo_idx', ['foo', 'foreign_key_test']);
$tableDiff = new TableDiff('alter_table');
$tableDiff->fromTable = $table;
$tableDiff->changedIndexes['foo_idx'] = new Index('foo_idx', ['foo', 'foreign_key_test']);
$this->schemaManager->alterTable($tableDiff);
......@@ -618,11 +624,11 @@ abstract class SchemaManagerFunctionalTestCase extends DbalFunctionalTestCase
self::assertFalse($table->getIndex('bar_idx')->isPrimary());
self::assertFalse($table->getIndex('bar_idx')->isUnique());
$tableDiff = new TableDiff('alter_table');
$tableDiff->fromTable = $table;
$tableDiff->removedIndexes[] = new Index('bar_idx', ['foo', 'foreign_key_test']);
$fk = new ForeignKeyConstraint(['foreign_key_test'], 'alter_table_foreign', ['id']);
$tableDiff->addedForeignKeys[] = $fk;
$tableDiff = new TableDiff('alter_table');
$tableDiff->fromTable = $table;
$tableDiff->removedIndexes['bar_idx'] = new Index('bar_idx', ['foo', 'foreign_key_test']);
$fk = new ForeignKeyConstraint(['foreign_key_test'], 'alter_table_foreign', ['id']);
$tableDiff->addedForeignKeys[] = $fk;
$this->schemaManager->alterTable($tableDiff);
$table = $this->schemaManager->listTableDetails('alter_table');
......@@ -649,8 +655,8 @@ abstract class SchemaManagerFunctionalTestCase extends DbalFunctionalTestCase
}
//create schema
$diff = new SchemaDiff();
$diff->newNamespaces[] = 'testschema';
$diff = new SchemaDiff();
$diff->newNamespaces['testschema'] = 'testschema';
foreach ($diff->toSql($this->schemaManager->getDatabasePlatform()) as $sql) {
$this->connection->exec($sql);
......@@ -759,6 +765,8 @@ abstract class SchemaManagerFunctionalTestCase extends DbalFunctionalTestCase
$c = new Comparator();
$tableDiff = $c->diffTable($tableFK, $tableFKNew);
self::assertNotNull($tableDiff);
$this->schemaManager->alterTable($tableDiff);
$table = $this->schemaManager->listTableDetails('test_fk_rename');
......@@ -801,7 +809,11 @@ abstract class SchemaManagerFunctionalTestCase extends DbalFunctionalTestCase
$comparator = new Comparator();
$this->schemaManager->alterTable($comparator->diffTable($foreignTable, $foreignTable2));
$diff = $comparator->diffTable($foreignTable, $foreignTable2);
self::assertNotNull($diff);
$this->schemaManager->alterTable($diff);
$foreignTable = $this->schemaManager->listTableDetails('test_rename_index_foreign');
......@@ -1108,7 +1120,11 @@ abstract class SchemaManagerFunctionalTestCase extends DbalFunctionalTestCase
$comparator = new Comparator();
$this->schemaManager->alterTable($comparator->diffTable($table, $diffTable));
$diff = $comparator->diffTable($table, $diffTable);
self::assertNotNull($diff);
$this->schemaManager->alterTable($diff);
$columns = $this->schemaManager->listTableColumns('col_def_lifecycle');
......@@ -1452,6 +1468,8 @@ abstract class SchemaManagerFunctionalTestCase extends DbalFunctionalTestCase
$this->connection->insert('test_pk_auto_increment', ['text' => '1']);
$query = $this->connection->query('SELECT id FROM test_pk_auto_increment WHERE text = \'1\'');
assert($query instanceof Statement);
$query->execute();
$lastUsedIdBeforeDelete = (int) $query->fetchColumn();
......@@ -1460,6 +1478,8 @@ abstract class SchemaManagerFunctionalTestCase extends DbalFunctionalTestCase
$this->connection->insert('test_pk_auto_increment', ['text' => '2']);
$query = $this->connection->query('SELECT id FROM test_pk_auto_increment WHERE text = \'2\'');
assert($query instanceof Statement);
$query->execute();
$lastUsedIdAfterDelete = (int) $query->fetchColumn();
......
......@@ -6,6 +6,7 @@ namespace Doctrine\Tests\DBAL\Functional\Schema;
use Doctrine\DBAL\DBALException;
use Doctrine\DBAL\Driver\Connection;
use Doctrine\DBAL\Driver\Statement;
use Doctrine\DBAL\Schema;
use Doctrine\DBAL\Schema\Table;
use Doctrine\DBAL\Types\BlobType;
......@@ -13,6 +14,7 @@ use Doctrine\DBAL\Types\Type;
use Doctrine\DBAL\Types\Types;
use SQLite3;
use function array_map;
use function assert;
use function dirname;
use function extension_loaded;
use function version_compare;
......@@ -235,6 +237,8 @@ SQL;
$diff = $comparator->diffTable($offlineTable, $onlineTable);
if ($expectedComparatorDiff) {
self::assertNotNull($diff);
self::assertEmpty($this->schemaManager->getDatabasePlatform()->getAlterTableSQL($diff));
} else {
self::assertNull($diff);
......@@ -274,6 +278,8 @@ SQL;
$this->connection->insert('test_pk_auto_increment', ['text' => '2']);
$query = $this->connection->query('SELECT id FROM test_pk_auto_increment WHERE text = "2"');
assert($query instanceof Statement);
$query->execute();
$lastUsedIdAfterDelete = (int) $query->fetchColumn();
......
......@@ -22,12 +22,10 @@ class TemporaryTableTest extends DbalFunctionalTestCase
protected function tearDown() : void
{
if ($this->connection) {
try {
$tempTable = $this->connection->getDatabasePlatform()->getTemporaryTableName('my_temporary');
$this->connection->exec($this->connection->getDatabasePlatform()->getDropTemporaryTableSQL($tempTable));
} catch (Throwable $e) {
}
try {
$tempTable = $this->connection->getDatabasePlatform()->getTemporaryTableName('my_temporary');
$this->connection->exec($this->connection->getDatabasePlatform()->getDropTemporaryTableSQL($tempTable));
} catch (Throwable $e) {
}
parent::tearDown();
......
......@@ -8,6 +8,7 @@ use Doctrine\DBAL\DBALException;
use Doctrine\DBAL\ParameterType;
use Doctrine\Tests\DbalFunctionalTestCase;
use PDO;
use function assert;
use function in_array;
/**
......@@ -39,9 +40,10 @@ class DBAL630Test extends DbalFunctionalTestCase
protected function tearDown() : void
{
if ($this->running) {
$this->connection->getWrappedConnection()
->getWrappedConnection()
->setAttribute(PDO::ATTR_EMULATE_PREPARES, false);
$wrappedConnection = $this->connection->getWrappedConnection();
assert($wrappedConnection instanceof PDO);
$wrappedConnection->setAttribute(PDO::ATTR_EMULATE_PREPARES, false);
}
parent::tearDown();
......@@ -75,9 +77,10 @@ class DBAL630Test extends DbalFunctionalTestCase
public function testBooleanConversionBoolParamEmulatedPrepares() : void
{
$this->connection->getWrappedConnection()
->getWrappedConnection()
->setAttribute(PDO::ATTR_EMULATE_PREPARES, true);
$wrappedConnection = $this->connection->getWrappedConnection();
assert($wrappedConnection instanceof PDO);
$wrappedConnection->setAttribute(PDO::ATTR_EMULATE_PREPARES, true);
$platform = $this->connection->getDatabasePlatform();
......@@ -101,9 +104,10 @@ class DBAL630Test extends DbalFunctionalTestCase
?bool $statementValue,
?bool $databaseConvertedValue
) : void {
$this->connection->getWrappedConnection()
->getWrappedConnection()
->setAttribute(PDO::ATTR_EMULATE_PREPARES, true);
$wrappedConnection = $this->connection->getWrappedConnection();
assert($wrappedConnection instanceof PDO);
$wrappedConnection->setAttribute(PDO::ATTR_EMULATE_PREPARES, true);
$platform = $this->connection->getDatabasePlatform();
......@@ -127,9 +131,10 @@ class DBAL630Test extends DbalFunctionalTestCase
?bool $statementValue,
bool $databaseConvertedValue
) : void {
$this->connection->getWrappedConnection()
->getWrappedConnection()
->setAttribute(PDO::ATTR_EMULATE_PREPARES, true);
$wrappedConnection = $this->connection->getWrappedConnection();
assert($wrappedConnection instanceof PDO);
$wrappedConnection->setAttribute(PDO::ATTR_EMULATE_PREPARES, true);
$platform = $this->connection->getDatabasePlatform();
......
......@@ -9,7 +9,6 @@ use Doctrine\DBAL\Driver\DriverException;
use Doctrine\DBAL\ParameterType;
use Doctrine\DBAL\Schema\Sequence;
use Doctrine\DBAL\Schema\Table;
use Doctrine\DBAL\Types\Type;
use Doctrine\Tests\DbalFunctionalTestCase;
use Throwable;
use function array_filter;
......@@ -35,18 +34,6 @@ class WriteTest extends DbalFunctionalTestCase
$this->connection->executeUpdate('DELETE FROM write_table');
}
/**
* @group DBAL-80
*/
public function testExecuteUpdateFirstTypeIsNull() : void
{
$sql = 'INSERT INTO write_table (test_string, test_int) VALUES (?, ?)';
$this->connection->executeUpdate($sql, ['text', 1111], [null, ParameterType::INTEGER]);
$sql = 'SELECT * FROM write_table WHERE test_string = ? AND test_int = ?';
self::assertTrue((bool) $this->connection->fetchColumn($sql, ['text', 1111]));
}
public function testExecuteUpdate() : void
{
$sql = 'INSERT INTO write_table (test_int) VALUES (1)';
......@@ -96,8 +83,8 @@ class WriteTest extends DbalFunctionalTestCase
$sql = 'INSERT INTO write_table (test_int, test_string) VALUES (?, ?)';
$stmt = $this->connection->prepare($sql);
$stmt->bindValue(1, 1, Type::getType('integer'));
$stmt->bindValue(2, 'foo', Type::getType('string'));
$stmt->bindValue(1, 1, ParameterType::INTEGER);
$stmt->bindValue(2, 'foo', ParameterType::STRING);
$stmt->execute();
self::assertEquals(1, $stmt->rowCount());
......@@ -108,8 +95,8 @@ class WriteTest extends DbalFunctionalTestCase
$sql = 'INSERT INTO write_table (test_int, test_string) VALUES (?, ?)';
$stmt = $this->connection->prepare($sql);
$stmt->bindValue(1, 1, 'integer');
$stmt->bindValue(2, 'foo', 'string');
$stmt->bindValue(1, 1, ParameterType::INTEGER);
$stmt->bindValue(2, 'foo', ParameterType::STRING);
$stmt->execute();
self::assertEquals(1, $stmt->rowCount());
......
......@@ -6,6 +6,7 @@ namespace Doctrine\Tests\DBAL\Platforms;
use Doctrine\DBAL\Exception\ColumnLengthRequired;
use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Platforms\MySqlPlatform;
use Doctrine\DBAL\Schema\Comparator;
use Doctrine\DBAL\Schema\ForeignKeyConstraint;
use Doctrine\DBAL\Schema\Index;
......@@ -157,6 +158,8 @@ abstract class AbstractMySQLPlatformTestCase extends AbstractPlatformTestCase
$c = new Comparator();
$diff = $c->diffTable($oldTable, $keyTable);
self::assertNotNull($diff);
$sql = $this->platform->getAlterTableSQL($diff);
self::assertEquals([
......@@ -219,11 +222,11 @@ abstract class AbstractMySQLPlatformTestCase extends AbstractPlatformTestCase
$index = new Index('idx', ['col'], false);
$unique = new Index('uniq', ['col'], true);
$diff = new TableDiff('test', [], [], [], [$unique], [], [$index]);
$diff = new TableDiff('test', [], [], [], ['uniq' => $unique], [], ['idx' => $index]);
$sql = $this->platform->getAlterTableSQL($diff);
self::assertEquals(['ALTER TABLE test DROP INDEX idx, ADD UNIQUE INDEX uniq (col)'], $sql);
$diff = new TableDiff('test', [], [], [], [$index], [], [$unique]);
$diff = new TableDiff('test', [], [], [], ['idx' => $index], [], ['unique' => $unique]);
$sql = $this->platform->getAlterTableSQL($diff);
self::assertEquals(['ALTER TABLE test DROP INDEX uniq, ADD INDEX idx (col)'], $sql);
}
......@@ -333,9 +336,13 @@ abstract class AbstractMySQLPlatformTestCase extends AbstractPlatformTestCase
$diffTable->dropIndex('idx_id');
$diffTable->setPrimaryKey(['id']);
$diff = $comparator->diffTable($table, $diffTable);
self::assertNotNull($diff);
self::assertEquals(
['DROP INDEX idx_id ON alter_table_add_pk', 'ALTER TABLE alter_table_add_pk ADD PRIMARY KEY (id)'],
$this->platform->getAlterTableSQL($comparator->diffTable($table, $diffTable))
$this->platform->getAlterTableSQL($diff)
);
}
......@@ -355,13 +362,17 @@ abstract class AbstractMySQLPlatformTestCase extends AbstractPlatformTestCase
$diffTable->dropPrimaryKey();
$diffTable->setPrimaryKey(['foo']);
$diff = $comparator->diffTable($table, $diffTable);
self::assertNotNull($diff);
self::assertEquals(
[
'ALTER TABLE alter_primary_key MODIFY id INT NOT NULL',
'ALTER TABLE alter_primary_key DROP PRIMARY KEY',
'ALTER TABLE alter_primary_key ADD PRIMARY KEY (foo)',
],
$this->platform->getAlterTableSQL($comparator->diffTable($table, $diffTable))
$this->platform->getAlterTableSQL($diff)
);
}
......@@ -381,12 +392,16 @@ abstract class AbstractMySQLPlatformTestCase extends AbstractPlatformTestCase
$diffTable->dropPrimaryKey();
$diff = $comparator->diffTable($table, $diffTable);
self::assertNotNull($diff);
self::assertEquals(
[
'ALTER TABLE drop_primary_key MODIFY id INT NOT NULL',
'ALTER TABLE drop_primary_key DROP PRIMARY KEY',
],
$this->platform->getAlterTableSQL($comparator->diffTable($table, $diffTable))
$this->platform->getAlterTableSQL($diff)
);
}
......@@ -407,13 +422,17 @@ abstract class AbstractMySQLPlatformTestCase extends AbstractPlatformTestCase
$diffTable->dropPrimaryKey();
$diffTable->setPrimaryKey(['id']);
$diff = $comparator->diffTable($table, $diffTable);
self::assertNotNull($diff);
self::assertSame(
[
'ALTER TABLE tbl MODIFY id INT NOT NULL',
'ALTER TABLE tbl DROP PRIMARY KEY',
'ALTER TABLE tbl ADD PRIMARY KEY (id)',
],
$this->platform->getAlterTableSQL($comparator->diffTable($table, $diffTable))
$this->platform->getAlterTableSQL($diff)
);
}
......@@ -434,13 +453,17 @@ abstract class AbstractMySQLPlatformTestCase extends AbstractPlatformTestCase
$diffTable->dropPrimaryKey();
$diffTable->setPrimaryKey(['id', 'foo']);
$diff = $comparator->diffTable($table, $diffTable);
self::assertNotNull($diff);
self::assertSame(
[
'ALTER TABLE tbl MODIFY id INT NOT NULL',
'ALTER TABLE tbl DROP PRIMARY KEY',
'ALTER TABLE tbl ADD PRIMARY KEY (id, foo)',
],
$this->platform->getAlterTableSQL($comparator->diffTable($table, $diffTable))
$this->platform->getAlterTableSQL($diff)
);
}
......@@ -460,6 +483,8 @@ abstract class AbstractMySQLPlatformTestCase extends AbstractPlatformTestCase
$c = new Comparator();
$diff = $c->diffTable($oldTable, $keyTable);
self::assertNotNull($diff);
$sql = $this->platform->getAlterTableSQL($diff);
self::assertEquals(['ALTER TABLE foo ADD id INT AUTO_INCREMENT NOT NULL, ADD PRIMARY KEY (id)'], $sql);
......@@ -492,13 +517,17 @@ abstract class AbstractMySQLPlatformTestCase extends AbstractPlatformTestCase
$diffTable->dropPrimaryKey();
$diffTable->setPrimaryKey(['pkc1', 'pkc2']);
$diff = $comparator->diffTable($table, $diffTable);
self::assertNotNull($diff);
self::assertSame(
[
'ALTER TABLE yolo DROP PRIMARY KEY',
'ALTER TABLE yolo ADD pkc2 INT NOT NULL',
'ALTER TABLE yolo ADD PRIMARY KEY (pkc1, pkc2)',
],
$this->platform->getAlterTableSQL($comparator->diffTable($table, $diffTable))
$this->platform->getAlterTableSQL($diff)
);
}
......@@ -684,7 +713,11 @@ abstract class AbstractMySQLPlatformTestCase extends AbstractPlatformTestCase
$comparator = new Comparator();
self::assertEmpty($this->platform->getAlterTableSQL($comparator->diffTable($table, $diffTable)));
$diff = $comparator->diffTable($table, $diffTable);
self::assertNotNull($diff);
self::assertEmpty($this->platform->getAlterTableSQL($diff));
}
/**
......
......@@ -1070,9 +1070,13 @@ abstract class AbstractPlatformTestCase extends DbalTestCase
$comparator = new Comparator();
$diff = $comparator->diffTable($fromTable, $toTable);
self::assertNotNull($diff);
self::assertEquals(
$this->getQuotedAlterTableRenameColumnSQL(),
$this->platform->getAlterTableSQL($comparator->diffTable($fromTable, $toTable))
$this->platform->getAlterTableSQL($diff)
);
}
......@@ -1112,9 +1116,13 @@ abstract class AbstractPlatformTestCase extends DbalTestCase
$comparator = new Comparator();
$diff = $comparator->diffTable($fromTable, $toTable);
self::assertNotNull($diff);
self::assertEquals(
$this->getQuotedAlterTableChangeColumnLengthSQL(),
$this->platform->getAlterTableSQL($comparator->diffTable($fromTable, $toTable))
$this->platform->getAlterTableSQL($diff)
);
}
......
......@@ -4,6 +4,7 @@ declare(strict_types=1);
namespace Doctrine\Tests\DBAL\Platforms;
use Doctrine\DBAL\Platforms\PostgreSqlPlatform;
use Doctrine\DBAL\Schema\Column;
use Doctrine\DBAL\Schema\ColumnDiff;
use Doctrine\DBAL\Schema\Comparator;
......@@ -14,10 +15,14 @@ use Doctrine\DBAL\Schema\TableDiff;
use Doctrine\DBAL\TransactionIsolationLevel;
use Doctrine\DBAL\Types\Type;
use UnexpectedValueException;
use function assert;
use function sprintf;
abstract class AbstractPostgreSqlPlatformTestCase extends AbstractPlatformTestCase
{
/** @var PostgreSqlPlatform */
protected $platform;
public function getGenerateTableSql() : string
{
return 'CREATE TABLE test (id SERIAL NOT NULL, test VARCHAR(255) DEFAULT NULL, PRIMARY KEY(id))';
......@@ -415,9 +420,7 @@ abstract class AbstractPostgreSqlPlatformTestCase extends AbstractPlatformTestCa
int $integerValue,
bool $booleanValue
) : void {
$platform = $this->createPlatform();
self::assertEquals($preparedStatementValue, $platform->convertBooleans($databaseValue));
self::assertEquals($preparedStatementValue, $this->platform->convertBooleans($databaseValue));
}
/**
......@@ -425,14 +428,13 @@ abstract class AbstractPostgreSqlPlatformTestCase extends AbstractPlatformTestCa
*/
public function testConvertBooleanAsLiteralIntegers() : void
{
$platform = $this->createPlatform();
$platform->setUseBooleanTrueFalseStrings(false);
$this->platform->setUseBooleanTrueFalseStrings(false);
self::assertEquals(1, $platform->convertBooleans(true));
self::assertEquals(1, $platform->convertBooleans('1'));
self::assertEquals(1, $this->platform->convertBooleans(true));
self::assertEquals(1, $this->platform->convertBooleans('1'));
self::assertEquals(0, $platform->convertBooleans(false));
self::assertEquals(0, $platform->convertBooleans('0'));
self::assertEquals(0, $this->platform->convertBooleans(false));
self::assertEquals(0, $this->platform->convertBooleans('0'));
}
/**
......@@ -445,9 +447,7 @@ abstract class AbstractPostgreSqlPlatformTestCase extends AbstractPlatformTestCa
int $integerValue,
bool $booleanValue
) : void {
$platform = $this->createPlatform();
self::assertSame($integerValue, $platform->convertBooleansToDatabaseValue($booleanValue));
self::assertSame($integerValue, $this->platform->convertBooleansToDatabaseValue($booleanValue));
}
/**
......@@ -455,11 +455,10 @@ abstract class AbstractPostgreSqlPlatformTestCase extends AbstractPlatformTestCa
*/
public function testConvertBooleanAsDatabaseValueIntegers() : void
{
$platform = $this->createPlatform();
$platform->setUseBooleanTrueFalseStrings(false);
$this->platform->setUseBooleanTrueFalseStrings(false);
self::assertSame(1, $platform->convertBooleansToDatabaseValue(true));
self::assertSame(0, $platform->convertBooleansToDatabaseValue(false));
self::assertSame(1, $this->platform->convertBooleansToDatabaseValue(true));
self::assertSame(0, $this->platform->convertBooleansToDatabaseValue(false));
}
/**
......@@ -467,19 +466,15 @@ abstract class AbstractPostgreSqlPlatformTestCase extends AbstractPlatformTestCa
*/
public function testConvertFromBoolean(string $databaseValue, string $prepareStatementValue, int $integerValue, bool $booleanValue) : void
{
$platform = $this->createPlatform();
self::assertSame($booleanValue, $platform->convertFromBoolean($databaseValue));
self::assertSame($booleanValue, $this->platform->convertFromBoolean($databaseValue));
}
public function testThrowsExceptionWithInvalidBooleanLiteral() : void
{
$platform = $this->createPlatform();
$this->expectException(UnexpectedValueException::class);
$this->expectExceptionMessage('Unrecognized boolean literal, my-bool given.');
$platform->convertBooleansToDatabaseValue('my-bool');
$this->platform->convertBooleansToDatabaseValue('my-bool');
}
public function testGetCreateSchemaSQL() : void
......@@ -564,6 +559,8 @@ abstract class AbstractPostgreSqlPlatformTestCase extends AbstractPlatformTestCa
$comparator = new Comparator();
$tableDiff = $comparator->diffTable($oldTable, $newTable);
self::assertNotNull($tableDiff);
$sql = $this->platform->getAlterTableSQL($tableDiff);
$expectedSql = [
......@@ -645,30 +642,42 @@ abstract class AbstractPostgreSqlPlatformTestCase extends AbstractPlatformTestCa
$comparator = new Comparator();
$diff = $comparator->diffTable($table1, $table2);
self::assertNotNull($diff);
// VARBINARY -> BINARY
// BINARY -> VARBINARY
// BLOB -> VARBINARY
self::assertEmpty($this->platform->getAlterTableSQL($comparator->diffTable($table1, $table2)));
self::assertEmpty($this->platform->getAlterTableSQL($diff));
$table2 = new Table('mytable');
$table2->addColumn('column_varbinary', 'binary', ['length' => 42]);
$table2->addColumn('column_binary', 'blob');
$table2->addColumn('column_blob', 'binary', ['length' => 11, 'fixed' => true]);
$diff = $comparator->diffTable($table1, $table2);
self::assertNotNull($diff);
// VARBINARY -> VARBINARY with changed length
// BINARY -> BLOB
// BLOB -> BINARY
self::assertEmpty($this->platform->getAlterTableSQL($comparator->diffTable($table1, $table2)));
self::assertEmpty($this->platform->getAlterTableSQL($diff));
$table2 = new Table('mytable');
$table2->addColumn('column_varbinary', 'blob');
$table2->addColumn('column_binary', 'binary', ['length' => 42, 'fixed' => true]);
$table2->addColumn('column_blob', 'blob');
$diff = $comparator->diffTable($table1, $table2);
self::assertNotNull($diff);
// VARBINARY -> BLOB
// BINARY -> BINARY with changed length
// BLOB -> BLOB
self::assertEmpty($this->platform->getAlterTableSQL($comparator->diffTable($table1, $table2)));
self::assertEmpty($this->platform->getAlterTableSQL($diff));
}
/**
......@@ -924,6 +933,8 @@ abstract class AbstractPostgreSqlPlatformTestCase extends AbstractPlatformTestCa
*/
public function testReturnsDisallowDatabaseConnectionsSQL() : void
{
assert($this->platform instanceof PostgreSqlPlatform);
self::assertSame(
"UPDATE pg_database SET datallowconn = 'false' WHERE datname = 'foo'",
$this->platform->getDisallowDatabaseConnectionsSQL('foo')
......@@ -935,6 +946,8 @@ abstract class AbstractPostgreSqlPlatformTestCase extends AbstractPlatformTestCa
*/
public function testReturnsCloseActiveDatabaseConnectionsSQL() : void
{
assert($this->platform instanceof PostgreSqlPlatform);
self::assertSame(
"SELECT pg_terminate_backend(procpid) FROM pg_stat_activity WHERE datname = 'foo'",
$this->platform->getCloseActiveDatabaseConnectionsSQL('foo')
......@@ -1023,6 +1036,8 @@ abstract class AbstractPostgreSqlPlatformTestCase extends AbstractPlatformTestCa
*/
public function testQuotesDatabaseNameInCloseActiveDatabaseConnectionsSQL() : void
{
assert($this->platform instanceof PostgreSqlPlatform);
self::assertStringContainsStringIgnoringCase(
"'Foo''Bar\\'",
$this->platform->getCloseActiveDatabaseConnectionsSQL("Foo'Bar\\")
......
......@@ -6,6 +6,7 @@ namespace Doctrine\Tests\DBAL\Platforms;
use Doctrine\DBAL\DBALException;
use Doctrine\DBAL\Exception\ColumnLengthRequired;
use Doctrine\DBAL\Platforms\SQLServerPlatform;
use Doctrine\DBAL\Schema\Column;
use Doctrine\DBAL\Schema\ColumnDiff;
use Doctrine\DBAL\Schema\Index;
......@@ -13,6 +14,7 @@ use Doctrine\DBAL\Schema\Table;
use Doctrine\DBAL\Schema\TableDiff;
use Doctrine\DBAL\TransactionIsolationLevel;
use Doctrine\DBAL\Types\Type;
use function assert;
use function sprintf;
abstract class AbstractSQLServerPlatformTestCase extends AbstractPlatformTestCase
......@@ -1122,6 +1124,7 @@ abstract class AbstractSQLServerPlatformTestCase extends AbstractPlatformTestCas
*/
public function testGeneratesIdentifierNamesInDefaultConstraintDeclarationSQL(string $table, array $column, string $expectedSql) : void
{
assert($this->platform instanceof SQLServerPlatform);
self::assertSame($expectedSql, $this->platform->getDefaultConstraintDeclarationSQL($table, $column));
}
......@@ -1236,7 +1239,7 @@ abstract class AbstractSQLServerPlatformTestCase extends AbstractPlatformTestCas
new TableDiff(
'mytable',
[
new Column('addcolumn', Type::getType('string'), [
'addcolumn' => new Column('addcolumn', Type::getType('string'), [
'length' => 255,
'default' => 'foo',
]),
......@@ -1256,7 +1259,7 @@ abstract class AbstractSQLServerPlatformTestCase extends AbstractPlatformTestCas
),
],
[
new Column('removecolumn', Type::getType('string'), [
'removecolumn' => new Column('removecolumn', Type::getType('string'), [
'length' => 255,
'default' => 'foo',
]),
......@@ -1276,7 +1279,7 @@ abstract class AbstractSQLServerPlatformTestCase extends AbstractPlatformTestCas
new TableDiff(
'`mytable`',
[
new Column('`addcolumn`', Type::getType('string'), [
'addcolumn' => new Column('`addcolumn`', Type::getType('string'), [
'length' => 255,
'default' => 'foo',
]),
......@@ -1296,7 +1299,7 @@ abstract class AbstractSQLServerPlatformTestCase extends AbstractPlatformTestCas
),
],
[
new Column('`removecolumn`', Type::getType('string'), [
'removecolumn' => new Column('`removecolumn`', Type::getType('string'), [
'length' => 255,
'default' => 'foo',
]),
......@@ -1316,7 +1319,7 @@ abstract class AbstractSQLServerPlatformTestCase extends AbstractPlatformTestCas
new TableDiff(
'table',
[
new Column('add', Type::getType('string'), [
'add' => new Column('add', Type::getType('string'), [
'length' => 255,
'default' => 'foo',
]),
......@@ -1336,7 +1339,7 @@ abstract class AbstractSQLServerPlatformTestCase extends AbstractPlatformTestCas
),
],
[
new Column('drop', Type::getType('string'), [
'drop' => new Column('drop', Type::getType('string'), [
'length' => 255,
'default' => 'foo',
]),
......@@ -1356,7 +1359,7 @@ abstract class AbstractSQLServerPlatformTestCase extends AbstractPlatformTestCas
new TableDiff(
'`table`',
[
new Column('`add`', Type::getType('string'), [
'add' => new Column('`add`', Type::getType('string'), [
'length' => 255,
'default' => 'foo',
]),
......@@ -1376,7 +1379,7 @@ abstract class AbstractSQLServerPlatformTestCase extends AbstractPlatformTestCas
),
],
[
new Column('`drop`', Type::getType('string'), [
'drop' => new Column('`drop`', Type::getType('string'), [
'length' => 255,
'default' => 'foo',
]),
......
......@@ -304,13 +304,17 @@ class DB2PlatformTest extends AbstractPlatformTestCase
/**
* {@inheritDoc}
*/
public function getIsCommentedDoctrineType() : array
public function getIsCommentedDoctrineType() : iterable
{
$data = parent::getIsCommentedDoctrineType();
$types = [];
$data[Types::BOOLEAN] = [Type::getType(Types::BOOLEAN), true];
foreach (parent::getIsCommentedDoctrineType() as $key => $value) {
$types[$key] = $value;
}
$types[Types::BOOLEAN] = [Type::getType(Types::BOOLEAN), true];
return $data;
return $types;
}
public function testGeneratesDDLSnippets() : void
......
......@@ -18,6 +18,7 @@ use Doctrine\DBAL\Schema\TableDiff;
use Doctrine\DBAL\TransactionIsolationLevel;
use Doctrine\DBAL\Types\Type;
use function array_walk;
use function assert;
use function preg_replace;
use function sprintf;
use function strtoupper;
......@@ -48,8 +49,7 @@ class OraclePlatformTest extends AbstractPlatformTestCase
*/
public function testValidIdentifiers(string $identifier) : void
{
$platform = $this->createPlatform();
$platform->assertValidIdentifier($identifier);
OraclePlatform::assertValidIdentifier($identifier);
$this->addToAssertionCount(1);
}
......@@ -75,8 +75,7 @@ class OraclePlatformTest extends AbstractPlatformTestCase
{
$this->expectException(DBALException::class);
$platform = $this->createPlatform();
$platform->assertValidIdentifier($identifier);
OraclePlatform::assertValidIdentifier($identifier);
}
public function createPlatform() : AbstractPlatform
......@@ -547,9 +546,13 @@ class OraclePlatformTest extends AbstractPlatformTestCase
$comparator = new Comparator();
$diff = $comparator->diffTable($table1, $table2);
self::assertNotNull($diff);
// VARBINARY -> BINARY
// BINARY -> VARBINARY
self::assertEmpty($this->platform->getAlterTableSQL($comparator->diffTable($table1, $table2)));
self::assertEmpty($this->platform->getAlterTableSQL($diff));
}
/**
......@@ -695,6 +698,8 @@ class OraclePlatformTest extends AbstractPlatformTestCase
*/
public function testReturnsDropAutoincrementSQL(string $table, array $expectedSql) : void
{
assert($this->platform instanceof OraclePlatform);
self::assertSame($expectedSql, $this->platform->getDropAutoincrementSql($table));
}
......
......@@ -8,6 +8,7 @@ use Doctrine\DBAL\Platforms\AbstractPlatform;
use Doctrine\DBAL\Platforms\PostgreSqlPlatform;
use Doctrine\DBAL\Schema\Table;
use Doctrine\DBAL\Types\Type;
use function assert;
class PostgreSqlPlatformTest extends AbstractPostgreSqlPlatformTestCase
{
......@@ -92,6 +93,8 @@ class PostgreSqlPlatformTest extends AbstractPostgreSqlPlatformTestCase
*/
public function testReturnsCloseActiveDatabaseConnectionsSQL() : void
{
assert($this->platform instanceof PostgreSqlPlatform);
self::assertSame(
"SELECT pg_terminate_backend(pid) FROM pg_stat_activity WHERE datname = 'foo'",
$this->platform->getCloseActiveDatabaseConnectionsSQL('foo')
......
......@@ -1155,7 +1155,7 @@ class SQLAnywherePlatformTest extends AbstractPlatformTestCase
*/
public function testQuotesTableNameInListTableConstraintsSQL() : void
{
self::assertStringContainsStringIgnoringCase("'Foo''Bar\\'", $this->platform->getListTableConstraintsSQL("Foo'Bar\\"), '', true);
self::assertStringContainsStringIgnoringCase("'Foo''Bar\\'", $this->platform->getListTableConstraintsSQL("Foo'Bar\\"), '');
}
/**
......
......@@ -12,6 +12,7 @@ use Doctrine\DBAL\Schema\Table;
use Doctrine\DBAL\Schema\TableDiff;
use Doctrine\DBAL\TransactionIsolationLevel;
use Doctrine\DBAL\Types\Type;
use function assert;
class SqlitePlatformTest extends AbstractPlatformTestCase
{
......@@ -82,6 +83,8 @@ class SqlitePlatformTest extends AbstractPlatformTestCase
*/
public function testGeneratesTypeDeclarationForTinyIntegers() : void
{
assert($this->platform instanceof SqlitePlatform);
self::assertEquals(
'TINYINT',
$this->platform->getTinyIntTypeDeclarationSQL([])
......@@ -112,6 +115,8 @@ class SqlitePlatformTest extends AbstractPlatformTestCase
*/
public function testGeneratesTypeDeclarationForSmallIntegers() : void
{
assert($this->platform instanceof SqlitePlatform);
self::assertEquals(
'SMALLINT',
$this->platform->getSmallIntTypeDeclarationSQL([])
......@@ -146,6 +151,8 @@ class SqlitePlatformTest extends AbstractPlatformTestCase
*/
public function testGeneratesTypeDeclarationForMediumIntegers() : void
{
assert($this->platform instanceof SqlitePlatform);
self::assertEquals(
'MEDIUMINT',
$this->platform->getMediumIntTypeDeclarationSQL([])
......
......@@ -37,10 +37,6 @@ class CompositeExpressionTest extends DbalTestCase
self::assertCount(2, $expr);
$expr->add(null);
self::assertCount(2, $expr);
$expr->add('u.user_id = 1');
self::assertCount(3, $expr);
......
......@@ -217,7 +217,7 @@ class ExpressionBuilderTest extends DbalTestCase
public function testIn() : void
{
self::assertEquals('u.groups IN (1, 3, 4, 7)', $this->expr->in('u.groups', [1, 3, 4, 7]));
self::assertEquals('u.groups IN (1, 3, 4, 7)', $this->expr->in('u.groups', ['1', '3', '4', '7']));
}
public function testInWithPlaceholder() : void
......@@ -227,7 +227,7 @@ class ExpressionBuilderTest extends DbalTestCase
public function testNotIn() : void
{
self::assertEquals('u.groups NOT IN (1, 3, 4, 7)', $this->expr->notIn('u.groups', [1, 3, 4, 7]));
self::assertEquals('u.groups NOT IN (1, 3, 4, 7)', $this->expr->notIn('u.groups', ['1', '3', '4', '7']));
}
public function testNotInWithPlaceholder() : void
......
......@@ -12,6 +12,7 @@ use Doctrine\DBAL\Platforms\MySqlPlatform;
use Doctrine\DBAL\Schema\AbstractSchemaManager;
use Doctrine\DBAL\Schema\ForeignKeyConstraint;
use Doctrine\DBAL\Schema\MySqlSchemaManager;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;
use function array_map;
......@@ -20,7 +21,7 @@ class MySqlSchemaManagerTest extends TestCase
/** @var AbstractSchemaManager */
private $manager;
/** @var Connection */
/** @var Connection|MockObject */
private $conn;
protected function setUp() : void
......
......@@ -35,7 +35,10 @@ class MySQLSchemaTest extends TestCase
$tableNew->setPrimaryKey(['bar_id', 'foo_id']);
$diff = $this->comparator->diffTable($tableOld, $tableNew);
$sql = $this->platform->getAlterTableSQL($diff);
self::assertNotNull($diff);
$sql = $this->platform->getAlterTableSQL($diff);
self::assertEquals(
[
......@@ -76,7 +79,10 @@ class MySQLSchemaTest extends TestCase
$tableNew->setPrimaryKey(['id']);
$diff = $this->comparator->diffTable($tableOld, $tableNew);
$sql = $this->platform->getAlterTableSQL($diff);
self::assertNotNull($diff);
$sql = $this->platform->getAlterTableSQL($diff);
self::assertEquals(
['ALTER TABLE test ADD PRIMARY KEY (id)'],
......
......@@ -109,9 +109,9 @@ class SchemaDiffTest extends TestCase
$diff = new SchemaDiff();
$diff->newNamespaces['foo_ns'] = 'foo_ns';
$diff->removedNamespaces['bar_ns'] = 'bar_ns';
$diff->changedSequences['foo_seq'] = new Sequence('foo_seq');
$diff->newSequences['bar_seq'] = new Sequence('bar_seq');
$diff->removedSequences['baz_seq'] = new Sequence('baz_seq');
$diff->changedSequences[] = new Sequence('foo_seq');
$diff->newSequences[] = new Sequence('bar_seq');
$diff->removedSequences[] = new Sequence('baz_seq');
$diff->newTables['foo_table'] = new Table('foo_table');
$diff->removedTables['bar_table'] = new Table('bar_table');
$diff->changedTables['baz_table'] = new TableDiff('baz_table');
......
......@@ -401,7 +401,7 @@ class SchemaTest extends TestCase
$visitor->expects($this->exactly(2))
->method('acceptSequence');
self::assertNull($schema->visit($visitor));
$schema->visit($visitor);
}
/**
......@@ -462,6 +462,8 @@ class SchemaTest extends TestCase
$visitor->expects($this->exactly(2))
->method('acceptSequence');
self::assertNull($schema->visit($visitor));
$schema->visit($visitor);
self::doesNotPerformAssertions(); // FIXME
}
}
......@@ -12,6 +12,7 @@ use InvalidArgumentException;
use PHPUnit\Framework\TestCase;
use stdClass;
use function array_merge;
use function assert;
/**
* @requires extension pdo_sqlite
......@@ -30,6 +31,8 @@ class PoolingShardConnectionTest extends TestCase
'shardChoser' => MultiTenantShardChoser::class,
]);
assert($conn instanceof PoolingShardConnection);
self::assertFalse($conn->isConnected(0));
$conn->connect(0);
self::assertEquals(1, $conn->fetchColumn('SELECT 1'));
......@@ -166,6 +169,8 @@ class PoolingShardConnectionTest extends TestCase
'shardChoser' => MultiTenantShardChoser::class,
]);
assert($conn instanceof PoolingShardConnection);
$conn->beginTransaction();
$this->expectException(ShardingException::class);
......@@ -184,6 +189,8 @@ class PoolingShardConnectionTest extends TestCase
'shardChoser' => MultiTenantShardChoser::class,
]);
assert($conn instanceof PoolingShardConnection);
self::assertNull($conn->getActiveShardId());
$conn->connect(0);
......@@ -207,6 +214,8 @@ class PoolingShardConnectionTest extends TestCase
'shardChoser' => MultiTenantShardChoser::class,
]);
assert($conn instanceof PoolingShardConnection);
self::assertEquals([
'wrapperClass' => PoolingShardConnection::class,
'driver' => 'pdo_sqlite',
......@@ -239,9 +248,13 @@ class PoolingShardConnectionTest extends TestCase
*/
private function createConnection(array $parameters) : PoolingShardConnection
{
return DriverManager::getConnection(array_merge(
$connection = DriverManager::getConnection(array_merge(
['wrapperClass' => PoolingShardConnection::class],
$parameters
));
self::assertInstanceOf(PoolingShardConnection::class, $connection);
return $connection;
}
}
......@@ -7,6 +7,7 @@ namespace Doctrine\Tests\DBAL\Sharding\SQLAzure;
use Doctrine\DBAL\Connection;
use Doctrine\DBAL\Sharding\ShardingException;
use Doctrine\DBAL\Sharding\SQLAzure\SQLAzureShardManager;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;
class SQLAzureShardManagerTest extends TestCase
......@@ -83,6 +84,8 @@ class SQLAzureShardManagerTest extends TestCase
/**
* @param mixed[] $params
*
* @return Connection|MockObject
*/
private function createConnection(array $params) : Connection
{
......
......@@ -15,17 +15,17 @@ use Doctrine\DBAL\ParameterType;
use Doctrine\DBAL\Statement;
use Doctrine\Tests\DbalTestCase;
use Exception;
use PDOStatement;
use PHPUnit\Framework\MockObject\MockObject;
class StatementTest extends DbalTestCase
{
/** @var Connection */
/** @var Connection|MockObject */
private $conn;
/** @var Configuration */
/** @var Configuration|MockObject */
private $configuration;
/** @var PDOStatement */
/** @var DriverStatement|MockObject */
private $driverStatement;
protected function setUp() : void
......
......@@ -8,6 +8,7 @@ use Doctrine\DBAL\Connection;
use Doctrine\DBAL\Tools\Console\Command\RunSqlCommand;
use Doctrine\DBAL\Tools\Console\ConsoleRunner;
use LogicException;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;
use RuntimeException;
use Symfony\Component\Console\Application;
......@@ -20,7 +21,7 @@ class RunSqlCommandTest extends TestCase
/** @var RunSqlCommand */
private $command;
/** @var Connection */
/** @var Connection|MockObject */
private $connectionMock;
protected function setUp() : void
......
......@@ -100,8 +100,8 @@ class DumperTest extends DbalTestCase
$print_r_class = print_r($class, true);
$print_r_expected = print_r($expected, true);
$print_r_class = substr($print_r_class, strpos($print_r_class, '('));
$print_r_expected = substr($print_r_expected, strpos($print_r_expected, '('));
$print_r_class = substr($print_r_class, (int) strpos($print_r_class, '('));
$print_r_expected = substr($print_r_expected, (int) strpos($print_r_expected, '('));
self::assertSame($print_r_class, $print_r_expected);
......
......@@ -14,7 +14,6 @@ use Doctrine\Tests\DbalTestCase;
use PHPUnit\Framework\MockObject\MockObject;
use function base64_encode;
use function fopen;
use function json_encode;
class JsonTest extends DbalTestCase
{
......@@ -64,9 +63,11 @@ class JsonTest extends DbalTestCase
public function testJsonStringConvertsToPHPValue() : void
{
$value = ['foo' => 'bar', 'bar' => 'foo'];
$databaseValue = json_encode($value);
$phpValue = $this->type->convertToPHPValue($databaseValue, $this->platform);
$value = ['foo' => 'bar', 'bar' => 'foo'];
$databaseValue = '{"foo":"bar","bar":"foo"}';
$phpValue = $this->type->convertToPHPValue($databaseValue, $this->platform);
self::assertEquals($value, $phpValue);
}
......@@ -88,8 +89,11 @@ class JsonTest extends DbalTestCase
public function testJsonResourceConvertsToPHPValue() : void
{
$value = ['foo' => 'bar', 'bar' => 'foo'];
$databaseValue = fopen('data://text/plain;base64,' . base64_encode(json_encode($value)), 'r');
$value = ['foo' => 'bar', 'bar' => 'foo'];
$json = '{"foo":"bar","bar":"foo"}';
$databaseValue = fopen('data://text/plain;base64,' . base64_encode($json), 'r');
$phpValue = $this->type->convertToPHPValue($databaseValue, $this->platform);
self::assertSame($value, $phpValue);
......
......@@ -25,7 +25,7 @@ abstract class DbalFunctionalTestCase extends DbalTestCase
/**
* Shared connection when a TestCase is run alone (outside of it's functional suite)
*
* @var Connection
* @var Connection|null
*/
private static $sharedConnection;
......@@ -37,7 +37,7 @@ abstract class DbalFunctionalTestCase extends DbalTestCase
protected function resetSharedConn() : void
{
if (! self::$sharedConnection) {
if (self::$sharedConnection === null) {
return;
}
......
......@@ -6,6 +6,7 @@ namespace Doctrine\Tests;
use Doctrine\DBAL\Connection;
use Doctrine\DBAL\DriverManager;
use InvalidArgumentException;
use PHPUnit\Framework\Assert;
use function explode;
use function extension_loaded;
......@@ -101,6 +102,12 @@ class TestUtil
$dbname = $realConn->getDatabase();
$realConn->close();
if ($dbname === null) {
throw new InvalidArgumentException(
'You must have a database configured in your connection.'
);
}
$tmpConn->getSchemaManager()->dropAndCreateDatabase($dbname);
$tmpConn->close();
......
......@@ -20,6 +20,8 @@ use Doctrine\DBAL\DriverManager;
return;
}
assert(is_int($pos));
$file = $_SERVER['argv'][$pos + 1];
register_shutdown_function(static function () use ($file) : void {
......
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