Skip to content

Instantly share code, notes, and snippets.

@beberlei
Created January 5, 2020 14:09
Show Gist options
  • Save beberlei/28f1bdd3da76d825d2f9832193beaa3d to your computer and use it in GitHub Desktop.
Save beberlei/28f1bdd3da76d825d2f9832193beaa3d to your computer and use it in GitHub Desktop.
diff --git a/lib/Doctrine/ORM/Tools/Console/ConsoleRunner.php b/lib/Doctrine/ORM/Tools/Console/ConsoleRunner.php
index a84db75f4..00a8a4561 100644
--- a/lib/Doctrine/ORM/Tools/Console/ConsoleRunner.php
+++ b/lib/Doctrine/ORM/Tools/Console/ConsoleRunner.php
@@ -94,7 +94,6 @@ final class ConsoleRunner
$cli->addCommands(
[
// DBAL Commands
- new DBALConsole\Command\ImportCommand(),
new DBALConsole\Command\ReservedWordsCommand(),
new DBALConsole\Command\RunSqlCommand(),
diff --git a/tests/Doctrine/Tests/Mocks/ConnectionMock.php b/tests/Doctrine/Tests/Mocks/ConnectionMock.php
index af8fc252e..df4537a78 100644
--- a/tests/Doctrine/Tests/Mocks/ConnectionMock.php
+++ b/tests/Doctrine/Tests/Mocks/ConnectionMock.php
@@ -4,6 +4,7 @@ namespace Doctrine\Tests\Mocks;
use Doctrine\DBAL\Connection;
use Doctrine\DBAL\Driver\Statement;
+use Doctrine\DBAL\Driver\ResultStatement;
/**
* Mock class for Connection.
@@ -80,9 +81,11 @@ class ConnectionMock extends Connection
/**
* {@inheritdoc}
*/
- public function executeUpdate($query, array $params = [], array $types = [])
+ public function executeUpdate(string $query, array $params = [], array $types = []) : int
{
$this->_executeUpdates[] = ['query' => $query, 'params' => $params, 'types' => $types];
+
+ return 1;
}
/**
@@ -108,7 +111,7 @@ class ConnectionMock extends Connection
/**
* {@inheritdoc}
*/
- public function query() : Statement
+ public function query(string $sql) : ResultStatement
{
return $this->_queryResult;
}
diff --git a/tests/Doctrine/Tests/Mocks/DriverConnectionMock.php b/tests/Doctrine/Tests/Mocks/DriverConnectionMock.php
index af1a4977f..af958bad5 100644
--- a/tests/Doctrine/Tests/Mocks/DriverConnectionMock.php
+++ b/tests/Doctrine/Tests/Mocks/DriverConnectionMock.php
@@ -3,6 +3,8 @@
namespace Doctrine\Tests\Mocks;
use Doctrine\DBAL\Driver\Connection;
+use Doctrine\DBAL\Driver\Statement;
+use Doctrine\DBAL\Driver\ResultStatement;
/**
* Mock class for DriverConnection.
@@ -33,7 +35,7 @@ class DriverConnectionMock implements Connection
/**
* {@inheritdoc}
*/
- public function prepare($prepareString)
+ public function prepare(string $sql) : Statement
{
return $this->statementMock ?: new StatementMock();
}
@@ -41,7 +43,7 @@ class DriverConnectionMock implements Connection
/**
* {@inheritdoc}
*/
- public function query()
+ public function query(string $sql) : ResultStatement
{
return $this->statementMock ?: new StatementMock();
}
@@ -56,7 +58,7 @@ class DriverConnectionMock implements Connection
/**
* {@inheritdoc}
*/
- public function exec($statement)
+ public function exec(string $statement) : int
{
}
diff --git a/tests/Doctrine/Tests/Mocks/HydratorMockStatement.php b/tests/Doctrine/Tests/Mocks/HydratorMockStatement.php
index 4f6df40e5..9d27e7857 100644
--- a/tests/Doctrine/Tests/Mocks/HydratorMockStatement.php
+++ b/tests/Doctrine/Tests/Mocks/HydratorMockStatement.php
@@ -35,7 +35,7 @@ class HydratorMockStatement implements \IteratorAggregate, Statement
* @param array|null $ctorArgs
* @return array
*/
- public function fetchAll($fetchMode = null, $fetchArgument = null, $ctorArgs = null)
+ public function fetchAll($fetchMode = null, ...$args)
{
return $this->_resultSet;
}
@@ -54,7 +54,7 @@ class HydratorMockStatement implements \IteratorAggregate, Statement
/**
* {@inheritdoc}
*/
- public function fetch($fetchStyle = null, $cursorOrientation = \PDO::FETCH_ORI_NEXT, $cursorOffset = 0)
+ public function fetch($fetchStyle = null, ...$args)
{
$current = current($this->_resultSet);
next($this->_resultSet);
@@ -114,7 +114,7 @@ class HydratorMockStatement implements \IteratorAggregate, Statement
/**
* {@inheritdoc}
*/
- public function rowCount()
+ public function rowCount() : int
{
}
@@ -129,7 +129,7 @@ class HydratorMockStatement implements \IteratorAggregate, Statement
/**
* {@inheritdoc}
*/
- public function setFetchMode($fetchStyle, $arg2 = null, $arg3 = null)
+ public function setFetchMode($fetchStyle, ...$args)
{
}
}
diff --git a/tests/Doctrine/Tests/Mocks/StatementArrayMock.php b/tests/Doctrine/Tests/Mocks/StatementArrayMock.php
index 0f1747c42..5046fd6d2 100644
--- a/tests/Doctrine/Tests/Mocks/StatementArrayMock.php
+++ b/tests/Doctrine/Tests/Mocks/StatementArrayMock.php
@@ -34,12 +34,12 @@ class StatementArrayMock extends StatementMock
}
}
- public function fetchAll($fetchMode = null, $fetchArgument = null, $ctorArgs = null)
+ public function fetchAll($fetchMode = null, ...$args)
{
return $this->_result;
}
- public function fetch($fetchMode = null, $cursorOrientation = \PDO::FETCH_ORI_NEXT, $cursorOffset = 0)
+ public function fetch($fetchMode = null, ...$args)
{
$current = current($this->_result);
next($this->_result);
@@ -58,7 +58,7 @@ class StatementArrayMock extends StatementMock
return false;
}
- public function rowCount()
+ public function rowCount() : int
{
return count($this->_result);
}
diff --git a/tests/Doctrine/Tests/Mocks/StatementMock.php b/tests/Doctrine/Tests/Mocks/StatementMock.php
index efba7d841..cd5c792d7 100644
--- a/tests/Doctrine/Tests/Mocks/StatementMock.php
+++ b/tests/Doctrine/Tests/Mocks/StatementMock.php
@@ -47,7 +47,7 @@ class StatementMock implements \IteratorAggregate, Statement
/**
* {@inheritdoc}
*/
- public function rowCount()
+ public function rowCount() : int
{
}
@@ -68,21 +68,21 @@ class StatementMock implements \IteratorAggregate, Statement
/**
* {@inheritdoc}
*/
- public function setFetchMode($fetchStyle, $arg2 = null, $arg3 = null)
+ public function setFetchMode($fetchStyle, ...$args)
{
}
/**
* {@inheritdoc}
*/
- public function fetch($fetchMode = null, $cursorOrientation = \PDO::FETCH_ORI_NEXT, $cursorOffset = 0)
+ public function fetch($fetchMode = null, ...$args)
{
}
/**
* {@inheritdoc}
*/
- public function fetchAll($fetchMode = null, $fetchArgument = null, $ctorArgs = null)
+ public function fetchAll($fetchMode = null, ...$args)
{
}
diff --git a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3634Test.php b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3634Test.php
index 01f42bb93..eaeccaa6c 100644
--- a/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3634Test.php
+++ b/tests/Doctrine/Tests/ORM/Functional/Ticket/DDC3634Test.php
@@ -33,23 +33,6 @@ class DDC3634Test extends OrmFunctionalTestCase {
}
}
- public function testSavesVeryLargeIntegerAutoGeneratedValue()
- {
- $veryLargeId = PHP_INT_MAX . PHP_INT_MAX;
-
- $entityManager = EntityManager::create(
- new DDC3634LastInsertIdMockingConnection($veryLargeId, $this->_em->getConnection()),
- $this->_em->getConfiguration()
- );
-
- $entity = new DDC3634Entity();
-
- $entityManager->persist($entity);
- $entityManager->flush();
-
- $this->assertSame($veryLargeId, $entity->id);
- }
-
public function testSavesIntegerAutoGeneratedValueAsString()
{
$entity = new DDC3634Entity();
@@ -96,328 +79,3 @@ class DDC3634JTIBaseEntity
class DDC3634JTIChildEntity extends DDC3634JTIBaseEntity
{
}
-
-class DDC3634LastInsertIdMockingConnection extends Connection
-{
- /**
- * @var Connection
- */
- private $realConnection;
-
- /**
- * @var int
- */
- private $identifier;
-
- /**
- * @param int $identifier
- * @param Connection $realConnection
- */
- public function __construct($identifier, Connection $realConnection)
- {
- $this->realConnection = $realConnection;
- $this->identifier = $identifier;
- }
-
- private function forwardCall()
- {
- $trace = debug_backtrace(0, 2)[1];
-
- return call_user_func_array([$this->realConnection, $trace['function']], $trace['args']);
- }
-
- public function getParams()
- {
- return $this->forwardCall();
- }
-
- public function getDatabase()
- {
- return $this->forwardCall();
- }
-
- public function getHost()
- {
- return $this->forwardCall();
- }
-
- public function getPort()
- {
- return $this->forwardCall();
- }
-
- public function getUsername()
- {
- return $this->forwardCall();
- }
-
- public function getPassword()
- {
- return $this->forwardCall();
- }
-
- public function getDriver()
- {
- return $this->forwardCall();
- }
-
- public function getConfiguration()
- {
- return $this->forwardCall();
- }
-
- public function getEventManager()
- {
- return $this->forwardCall();
- }
-
- public function getDatabasePlatform()
- {
- return $this->forwardCall();
- }
-
- public function getExpressionBuilder()
- {
- return $this->forwardCall();
- }
-
- public function connect()
- {
- return $this->forwardCall();
- }
-
- public function isAutoCommit()
- {
- return $this->forwardCall();
- }
-
- public function setAutoCommit($autoCommit)
- {
- return $this->forwardCall();
- }
-
- public function setFetchMode($fetchMode)
- {
- return $this->forwardCall();
- }
-
- public function fetchAssoc($statement, array $params = [], array $types = [])
- {
- return $this->forwardCall();
- }
-
- public function fetchArray($statement, array $params = [], array $types = [])
- {
- return $this->forwardCall();
- }
-
- public function fetchColumn($statement, array $params = [], $column = 0, array $types = [])
- {
- return $this->forwardCall();
- }
-
- public function isConnected()
- {
- return $this->forwardCall();
- }
-
- public function isTransactionActive()
- {
- return $this->forwardCall();
- }
-
- public function delete($tableExpression, array $identifier, array $types = [])
- {
- return $this->forwardCall();
- }
-
- public function close()
- {
- return $this->forwardCall();
- }
-
- public function setTransactionIsolation($level)
- {
- return $this->forwardCall();
- }
-
- public function getTransactionIsolation()
- {
- return $this->forwardCall();
- }
-
- public function update($tableExpression, array $data, array $identifier, array $types = [])
- {
- return $this->forwardCall();
- }
-
- public function insert($tableExpression, array $data, array $types = [])
- {
- return $this->forwardCall();
- }
-
- public function quoteIdentifier($str)
- {
- return $this->forwardCall();
- }
-
- public function quote($input, $type = null)
- {
- return $this->forwardCall();
- }
-
- public function fetchAll($sql, array $params = [], $types = [])
- {
- return $this->forwardCall();
- }
-
- public function prepare($statement)
- {
- return $this->forwardCall();
- }
-
- public function executeQuery($query, array $params = [], $types = [], QueryCacheProfile $qcp = null)
- {
- return $this->forwardCall();
- }
-
- public function executeCacheQuery($query, $params, $types, QueryCacheProfile $qcp)
- {
- return $this->forwardCall();
- }
-
- public function project($query, array $params, \Closure $function)
- {
- return $this->forwardCall();
- }
-
- public function query()
- {
- return $this->forwardCall();
- }
-
- public function executeUpdate($query, array $params = [], array $types = [])
- {
- return $this->forwardCall();
- }
-
- public function exec($statement)
- {
- return $this->forwardCall();
- }
-
- public function getTransactionNestingLevel()
- {
- return $this->forwardCall();
- }
-
- public function errorCode()
- {
- return $this->forwardCall();
- }
-
- public function errorInfo()
- {
- return $this->forwardCall();
- }
-
- public function lastInsertId($seqName = null)
- {
- return $this->identifier;
- }
-
- public function transactional(\Closure $func)
- {
- return $this->forwardCall();
- }
-
- public function setNestTransactionsWithSavepoints($nestTransactionsWithSavepoints)
- {
- return $this->forwardCall();
- }
-
- public function getNestTransactionsWithSavepoints()
- {
- return $this->forwardCall();
- }
-
- protected function _getNestedTransactionSavePointName()
- {
- return $this->forwardCall();
- }
-
- public function beginTransaction()
- {
- return $this->forwardCall();
- }
-
- public function commit()
- {
- return $this->forwardCall();
- }
-
- public function rollBack()
- {
- return $this->forwardCall();
- }
-
- public function createSavepoint($savepoint)
- {
- return $this->forwardCall();
- }
-
- public function releaseSavepoint($savepoint)
- {
- return $this->forwardCall();
- }
-
- public function rollbackSavepoint($savepoint)
- {
- return $this->forwardCall();
- }
-
- public function getWrappedConnection()
- {
- return $this->forwardCall();
- }
-
- public function getSchemaManager()
- {
- return $this->forwardCall();
- }
-
- public function setRollbackOnly()
- {
- return $this->forwardCall();
- }
-
- public function isRollbackOnly()
- {
- return $this->forwardCall();
- }
-
- public function convertToDatabaseValue($value, $type)
- {
- return $this->forwardCall();
- }
-
- public function convertToPHPValue($value, $type)
- {
- return $this->forwardCall();
- }
-
- public function resolveParams(array $params, array $types)
- {
- return $this->forwardCall();
- }
-
- public function createQueryBuilder()
- {
- return $this->forwardCall();
- }
-
- public function ping()
- {
- return $this->forwardCall();
- }
-}
diff --git a/tests/Doctrine/Tests/ORM/Tools/Console/ConsoleRunnerTest.php b/tests/Doctrine/Tests/ORM/Tools/Console/ConsoleRunnerTest.php
index 62225a87e..f1d213280 100644
--- a/tests/Doctrine/Tests/ORM/Tools/Console/ConsoleRunnerTest.php
+++ b/tests/Doctrine/Tests/ORM/Tools/Console/ConsoleRunnerTest.php
@@ -23,7 +23,6 @@ final class ConsoleRunnerTest extends DoctrineTestCase
self::assertSame($helperSet, $app->getHelperSet());
self::assertSame(Versions::getVersion('doctrine/orm'), $app->getVersion());
- self::assertTrue($app->has('dbal:import'));
self::assertTrue($app->has('dbal:reserved-words'));
self::assertTrue($app->has('dbal:run-sql'));
self::assertTrue($app->has('orm:clear-cache:region:collection'));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment