Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed test failures on PHP 7.4 #3642

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions lib/Doctrine/DBAL/Schema/MySqlSchemaManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -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']));

Expand Down
6 changes: 4 additions & 2 deletions lib/Doctrine/DBAL/Schema/Table.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,9 @@ class Table extends AbstractAsset
protected $_fkConstraints = [];

/** @var mixed[] */
protected $_options = [];
protected $_options = [
'create_options' => [],
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As I already said, associative arrays of associative arrays are barely manageable.

];

/** @var SchemaConfig|null */
protected $_schemaConfig = null;
Expand Down Expand Up @@ -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);
}

/**
Expand Down
5 changes: 5 additions & 0 deletions tests/Doctrine/Tests/DBAL/Driver/OCI8/OCI8StatementTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This illustrates one more advantage of using classes for data structures instead of associative arrays. Unlike the array element, a method return value would be automatically mocked.

]);

$shardManager = new PoolingShardManager($conn);
$shardManager->selectGlobal();
Expand Down