From 860b90b8b00b8fe556038c9a6c730e0ff58adf4f Mon Sep 17 00:00:00 2001 From: Sergei Morozov Date: Sat, 3 Aug 2019 09:27:57 -0700 Subject: [PATCH] Fixed test failures on PHP 7.4 The failures are caused by the changes in PHP according to https://wiki.php.net/rfc/notice-for-non-valid-array-container. --- lib/Doctrine/DBAL/Schema/MySqlSchemaManager.php | 7 +++++++ lib/Doctrine/DBAL/Schema/Table.php | 6 ++++-- .../Doctrine/Tests/DBAL/Driver/OCI8/OCI8StatementTest.php | 5 +++++ .../Tests/DBAL/Sharding/PoolingShardManagerTest.php | 4 ++++ 4 files changed, 20 insertions(+), 2 deletions(-) diff --git a/lib/Doctrine/DBAL/Schema/MySqlSchemaManager.php b/lib/Doctrine/DBAL/Schema/MySqlSchemaManager.php index 5e0368509f7..9522faf6a73 100644 --- a/lib/Doctrine/DBAL/Schema/MySqlSchemaManager.php +++ b/lib/Doctrine/DBAL/Schema/MySqlSchemaManager.php @@ -309,13 +309,20 @@ public function listTableDetails($tableName) $tableOptions = $this->_conn->fetchAssoc($sql); + if ($tableOptions === false) { + return $table; + } + $table->addOption('engine', $tableOptions['ENGINE']); + if ($tableOptions['TABLE_COLLATION'] !== null) { $table->addOption('collation', $tableOptions['TABLE_COLLATION']); } + if ($tableOptions['AUTO_INCREMENT'] !== null) { $table->addOption('autoincrement', $tableOptions['AUTO_INCREMENT']); } + $table->addOption('comment', $tableOptions['TABLE_COMMENT']); $table->addOption('create_options', $this->parseCreateOptions($tableOptions['CREATE_OPTIONS'])); diff --git a/lib/Doctrine/DBAL/Schema/Table.php b/lib/Doctrine/DBAL/Schema/Table.php index af853c277d5..0abb3f4b863 100644 --- a/lib/Doctrine/DBAL/Schema/Table.php +++ b/lib/Doctrine/DBAL/Schema/Table.php @@ -34,7 +34,9 @@ class Table extends AbstractAsset protected $_fkConstraints = []; /** @var mixed[] */ - protected $_options = []; + protected $_options = [ + 'create_options' => [], + ]; /** @var SchemaConfig|null */ protected $_schemaConfig = null; @@ -69,7 +71,7 @@ public function __construct($tableName, array $columns = [], array $indexes = [] $this->_addForeignKeyConstraint($constraint); } - $this->_options = $options; + $this->_options = array_merge($this->_options, $options); } /** diff --git a/tests/Doctrine/Tests/DBAL/Driver/OCI8/OCI8StatementTest.php b/tests/Doctrine/Tests/DBAL/Driver/OCI8/OCI8StatementTest.php index b28b2d83887..45d0c45264c 100644 --- a/tests/Doctrine/Tests/DBAL/Driver/OCI8/OCI8StatementTest.php +++ b/tests/Doctrine/Tests/DBAL/Driver/OCI8/OCI8StatementTest.php @@ -59,6 +59,11 @@ public function testExecute(array $params) : void $this->equalTo($params[2]) ); + // the return value is irrelevant to the test + // but it has to be compatible with the method signature + $statement->method('errorInfo') + ->willReturn(false); + // can't pass to constructor since we don't have a real database handle, // but execute must check the connection for the executeMode $conn = $this->getMockBuilder(OCI8Connection::class) diff --git a/tests/Doctrine/Tests/DBAL/Sharding/PoolingShardManagerTest.php b/tests/Doctrine/Tests/DBAL/Sharding/PoolingShardManagerTest.php index 01db26773f3..31a308e0393 100644 --- a/tests/Doctrine/Tests/DBAL/Sharding/PoolingShardManagerTest.php +++ b/tests/Doctrine/Tests/DBAL/Sharding/PoolingShardManagerTest.php @@ -47,6 +47,10 @@ public function testSelectGlobal() : void { $conn = $this->createConnectionMock(); $conn->expects($this->once())->method('connect')->with($this->equalTo(0)); + $conn->method('getParams') + ->willReturn([ + 'shardChoser' => $this->createMock(ShardChoser::class), + ]); $shardManager = new PoolingShardManager($conn); $shardManager->selectGlobal();