diff --git a/UPGRADE.md b/UPGRADE.md index 27a9f305488..7e9448ce3b5 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -1,5 +1,9 @@ # Upgrade to 3.0 +## BC BREAK `Statement::quote()` only accepts strings. + +`Statement::quote()` and `ExpressionBuilder::literal()` no longer accept arguments of an arbitrary type and and don't implement type-specific handling. Only strings can be quoted. + ## BC BREAK `Statement` and `Connection` methods return `void`. `Connection::connect()`, `Statement::bindParam()`, `::bindValue()`, `::execute()`, `ResultStatement::setFetchMode()` and `::closeCursor()` no longer return a boolean value. They will throw an exception in case of failure. diff --git a/lib/Doctrine/DBAL/Connection.php b/lib/Doctrine/DBAL/Connection.php index a60d457a2bd..27a9cdb1ee3 100644 --- a/lib/Doctrine/DBAL/Connection.php +++ b/lib/Doctrine/DBAL/Connection.php @@ -808,13 +808,9 @@ public function quoteIdentifier($str) /** * {@inheritDoc} */ - public function quote($input, $type = null) + public function quote(string $input) : string { - $connection = $this->getWrappedConnection(); - - [$value, $bindingType] = $this->getBindingInfo($input, $type); - - return $connection->quote($value, $bindingType); + return $this->getWrappedConnection()->quote($input); } /** diff --git a/lib/Doctrine/DBAL/Driver/Connection.php b/lib/Doctrine/DBAL/Driver/Connection.php index a8981548821..14dbb54f31f 100644 --- a/lib/Doctrine/DBAL/Driver/Connection.php +++ b/lib/Doctrine/DBAL/Driver/Connection.php @@ -3,7 +3,6 @@ namespace Doctrine\DBAL\Driver; use Doctrine\DBAL\DBALException; -use Doctrine\DBAL\ParameterType; /** * Connection interface. @@ -27,13 +26,8 @@ public function query(string $sql) : ResultStatement; /** * Quotes a string for use in a query. - * - * @param mixed $input - * @param int $type - * - * @return mixed */ - public function quote($input, $type = ParameterType::STRING); + public function quote(string $input) : string; /** * Executes an SQL statement and return the number of affected rows. diff --git a/lib/Doctrine/DBAL/Driver/IBMDB2/DB2Connection.php b/lib/Doctrine/DBAL/Driver/IBMDB2/DB2Connection.php index 3d48d60b718..4f88decbd69 100644 --- a/lib/Doctrine/DBAL/Driver/IBMDB2/DB2Connection.php +++ b/lib/Doctrine/DBAL/Driver/IBMDB2/DB2Connection.php @@ -6,7 +6,6 @@ use Doctrine\DBAL\Driver\ResultStatement; use Doctrine\DBAL\Driver\ServerInfoAwareConnection; use Doctrine\DBAL\Driver\Statement as DriverStatement; -use Doctrine\DBAL\ParameterType; use stdClass; use const DB2_AUTOCOMMIT_OFF; use const DB2_AUTOCOMMIT_ON; @@ -101,15 +100,9 @@ public function query(string $sql) : ResultStatement /** * {@inheritdoc} */ - public function quote($input, $type = ParameterType::STRING) + public function quote(string $input) : string { - $input = db2_escape_string($input); - - if ($type === ParameterType::INTEGER) { - return $input; - } - - return "'" . $input . "'"; + return "'" . db2_escape_string($input) . "'"; } /** diff --git a/lib/Doctrine/DBAL/Driver/Mysqli/MysqliConnection.php b/lib/Doctrine/DBAL/Driver/Mysqli/MysqliConnection.php index 0a199649454..789b2c8b4ba 100644 --- a/lib/Doctrine/DBAL/Driver/Mysqli/MysqliConnection.php +++ b/lib/Doctrine/DBAL/Driver/Mysqli/MysqliConnection.php @@ -7,7 +7,6 @@ use Doctrine\DBAL\Driver\ResultStatement; use Doctrine\DBAL\Driver\ServerInfoAwareConnection; use Doctrine\DBAL\Driver\Statement as DriverStatement; -use Doctrine\DBAL\ParameterType; use mysqli; use const MYSQLI_INIT_COMMAND; use const MYSQLI_OPT_CONNECT_TIMEOUT; @@ -146,7 +145,7 @@ public function query(string $sql) : ResultStatement /** * {@inheritdoc} */ - public function quote($input, $type = ParameterType::STRING) + public function quote(string $input) : string { return "'" . $this->conn->escape_string($input) . "'"; } diff --git a/lib/Doctrine/DBAL/Driver/OCI8/OCI8Connection.php b/lib/Doctrine/DBAL/Driver/OCI8/OCI8Connection.php index 861facbb03c..20fb9d4b2e6 100644 --- a/lib/Doctrine/DBAL/Driver/OCI8/OCI8Connection.php +++ b/lib/Doctrine/DBAL/Driver/OCI8/OCI8Connection.php @@ -6,14 +6,11 @@ use Doctrine\DBAL\Driver\ResultStatement; use Doctrine\DBAL\Driver\ServerInfoAwareConnection; use Doctrine\DBAL\Driver\Statement as DriverStatement; -use Doctrine\DBAL\ParameterType; use UnexpectedValueException; use const OCI_COMMIT_ON_SUCCESS; use const OCI_DEFAULT; use const OCI_NO_AUTO_COMMIT; use function addcslashes; -use function is_float; -use function is_int; use function oci_commit; use function oci_connect; use function oci_error; @@ -123,14 +120,9 @@ public function query(string $sql) : ResultStatement /** * {@inheritdoc} */ - public function quote($value, $type = ParameterType::STRING) + public function quote(string $input) : string { - if (is_int($value) || is_float($value)) { - return $value; - } - $value = str_replace("'", "''", $value); - - return "'" . addcslashes($value, "\000\n\r\\\032") . "'"; + return "'" . addcslashes(str_replace("'", "''", $input), "\000\n\r\\\032") . "'"; } /** diff --git a/lib/Doctrine/DBAL/Driver/PDOConnection.php b/lib/Doctrine/DBAL/Driver/PDOConnection.php index 171f85118d0..d9cbb681c8c 100644 --- a/lib/Doctrine/DBAL/Driver/PDOConnection.php +++ b/lib/Doctrine/DBAL/Driver/PDOConnection.php @@ -2,7 +2,6 @@ namespace Doctrine\DBAL\Driver; -use Doctrine\DBAL\ParameterType; use PDO; use function assert; @@ -86,9 +85,9 @@ public function query(string $sql) : ResultStatement /** * {@inheritdoc} */ - public function quote($input, $type = ParameterType::STRING) + public function quote(string $input) : string { - return $this->connection->quote($input, $type); + return $this->connection->quote($input); } /** diff --git a/lib/Doctrine/DBAL/Driver/PDOSqlsrv/Connection.php b/lib/Doctrine/DBAL/Driver/PDOSqlsrv/Connection.php index 33331bd0a5a..803ab9e022f 100644 --- a/lib/Doctrine/DBAL/Driver/PDOSqlsrv/Connection.php +++ b/lib/Doctrine/DBAL/Driver/PDOSqlsrv/Connection.php @@ -4,7 +4,6 @@ use Doctrine\DBAL\Driver\PDOConnection; use Doctrine\DBAL\Driver\PDOStatement; -use Doctrine\DBAL\ParameterType; use function strpos; use function substr; @@ -31,9 +30,9 @@ public function lastInsertId($name = null) /** * {@inheritDoc} */ - public function quote($value, $type = ParameterType::STRING) + public function quote(string $input) : string { - $val = parent::quote($value, $type); + $val = parent::quote($input); // Fix for a driver version terminating all values with null byte if (strpos($val, "\0") !== false) { diff --git a/lib/Doctrine/DBAL/Driver/SQLAnywhere/SQLAnywhereConnection.php b/lib/Doctrine/DBAL/Driver/SQLAnywhere/SQLAnywhereConnection.php index 5d6361069ac..1ba572dc6e0 100644 --- a/lib/Doctrine/DBAL/Driver/SQLAnywhere/SQLAnywhereConnection.php +++ b/lib/Doctrine/DBAL/Driver/SQLAnywhere/SQLAnywhereConnection.php @@ -6,10 +6,7 @@ use Doctrine\DBAL\Driver\ResultStatement; use Doctrine\DBAL\Driver\ServerInfoAwareConnection; use Doctrine\DBAL\Driver\Statement as DriverStatement; -use Doctrine\DBAL\ParameterType; use function assert; -use function is_float; -use function is_int; use function is_resource; use function is_string; use function sasql_affected_rows; @@ -159,12 +156,8 @@ public function query(string $sql) : ResultStatement /** * {@inheritdoc} */ - public function quote($input, $type = ParameterType::STRING) + public function quote(string $input) : string { - if (is_int($input) || is_float($input)) { - return $input; - } - return "'" . sasql_escape_string($this->connection, $input) . "'"; } diff --git a/lib/Doctrine/DBAL/Driver/SQLSrv/SQLSrvConnection.php b/lib/Doctrine/DBAL/Driver/SQLSrv/SQLSrvConnection.php index 0f8ee3f5817..7fc1fa0fccc 100644 --- a/lib/Doctrine/DBAL/Driver/SQLSrv/SQLSrvConnection.php +++ b/lib/Doctrine/DBAL/Driver/SQLSrv/SQLSrvConnection.php @@ -6,11 +6,7 @@ use Doctrine\DBAL\Driver\ResultStatement; use Doctrine\DBAL\Driver\ServerInfoAwareConnection; use Doctrine\DBAL\Driver\Statement as DriverStatement; -use Doctrine\DBAL\ParameterType; use const SQLSRV_ERR_ERRORS; -use function is_float; -use function is_int; -use function sprintf; use function sqlsrv_begin_transaction; use function sqlsrv_commit; use function sqlsrv_configure; @@ -95,15 +91,9 @@ public function query(string $sql) : ResultStatement /** * {@inheritDoc} */ - public function quote($value, $type = ParameterType::STRING) + public function quote(string $input) : string { - if (is_int($value)) { - return $value; - } elseif (is_float($value)) { - return sprintf('%F', $value); - } - - return "'" . str_replace("'", "''", $value) . "'"; + return "'" . str_replace("'", "''", $input) . "'"; } /** diff --git a/lib/Doctrine/DBAL/Query/Expression/ExpressionBuilder.php b/lib/Doctrine/DBAL/Query/Expression/ExpressionBuilder.php index dfcc31ec709..93cbd31e95f 100644 --- a/lib/Doctrine/DBAL/Query/Expression/ExpressionBuilder.php +++ b/lib/Doctrine/DBAL/Query/Expression/ExpressionBuilder.php @@ -284,15 +284,10 @@ public function notIn($x, $y) } /** - * Quotes a given input parameter. - * - * @param mixed $input The parameter to be quoted. - * @param int|null $type The type of the parameter. - * - * @return string + * Creates an SQL literal expression from the string. */ - public function literal($input, $type = null) + public function literal(string $input) { - return $this->connection->quote($input, $type); + return $this->connection->quote($input); } } diff --git a/lib/Doctrine/DBAL/Schema/AbstractSchemaManager.php b/lib/Doctrine/DBAL/Schema/AbstractSchemaManager.php index 072f2737f9e..bb0e695a221 100644 --- a/lib/Doctrine/DBAL/Schema/AbstractSchemaManager.php +++ b/lib/Doctrine/DBAL/Schema/AbstractSchemaManager.php @@ -830,12 +830,11 @@ abstract protected function _getPortableTableColumnDefinition($tableColumn); /** * Aggregates and groups the index results according to the required data result. * - * @param mixed[][] $tableIndexRows - * @param string|null $tableName + * @param mixed[][] $tableIndexRows * * @return Index[] */ - protected function _getPortableTableIndexesList($tableIndexRows, $tableName = null) + protected function _getPortableTableIndexesList(array $tableIndexRows, string $tableName) : array { $result = []; foreach ($tableIndexRows as $tableIndex) { diff --git a/lib/Doctrine/DBAL/Schema/DB2SchemaManager.php b/lib/Doctrine/DBAL/Schema/DB2SchemaManager.php index 0307a0d537d..2b26e946ac7 100644 --- a/lib/Doctrine/DBAL/Schema/DB2SchemaManager.php +++ b/lib/Doctrine/DBAL/Schema/DB2SchemaManager.php @@ -5,7 +5,9 @@ use Doctrine\DBAL\Types\Type; use const CASE_LOWER; use function array_change_key_case; +use function assert; use function is_resource; +use function is_string; use function strpos; use function strtolower; use function substr; @@ -22,12 +24,14 @@ class DB2SchemaManager extends AbstractSchemaManager * Apparently creator is the schema not the user who created it: * {@link http://publib.boulder.ibm.com/infocenter/dzichelp/v2r2/index.jsp?topic=/com.ibm.db29.doc.sqlref/db2z_sysibmsystablestable.htm} */ - public function listTableNames() + public function listTableNames() : array { - $sql = $this->_platform->getListTablesSQL(); - $sql .= ' AND CREATOR = UPPER(' . $this->_conn->quote($this->_conn->getUsername()) . ')'; + $username = $this->_conn->getUsername(); + assert(is_string($username)); - $tables = $this->_conn->fetchAll($sql); + $sql = $this->_platform->getListTablesSQL() . ' AND CREATOR = UPPER(?)'; + + $tables = $this->_conn->fetchAll($sql, [$username]); return $this->filterAssetNames($this->_getPortableTablesList($tables)); } @@ -117,7 +121,7 @@ protected function _getPortableTablesList($tables) /** * {@inheritdoc} */ - protected function _getPortableTableIndexesList($tableIndexRows, $tableName = null) + protected function _getPortableTableIndexesList(array $tableIndexRows, string $tableName) : array { foreach ($tableIndexRows as &$tableIndexRow) { $tableIndexRow = array_change_key_case($tableIndexRow, CASE_LOWER); diff --git a/lib/Doctrine/DBAL/Schema/MySqlSchemaManager.php b/lib/Doctrine/DBAL/Schema/MySqlSchemaManager.php index 4cc31a9258a..5898fb4a728 100644 --- a/lib/Doctrine/DBAL/Schema/MySqlSchemaManager.php +++ b/lib/Doctrine/DBAL/Schema/MySqlSchemaManager.php @@ -54,9 +54,9 @@ protected function _getPortableUserDefinition($user) /** * {@inheritdoc} */ - protected function _getPortableTableIndexesList($tableIndexes, $tableName = null) + protected function _getPortableTableIndexesList(array $tableIndexRows, string $tableName) : array { - foreach ($tableIndexes as $k => $v) { + foreach ($tableIndexRows as $k => $v) { $v = array_change_key_case($v, CASE_LOWER); if ($v['key_name'] === 'PRIMARY') { $v['primary'] = true; @@ -70,10 +70,10 @@ protected function _getPortableTableIndexesList($tableIndexes, $tableName = null } $v['length'] = isset($v['sub_part']) ? (int) $v['sub_part'] : null; - $tableIndexes[$k] = $v; + $tableIndexRows[$k] = $v; } - return parent::_getPortableTableIndexesList($tableIndexes, $tableName); + return parent::_getPortableTableIndexesList($tableIndexRows, $tableName); } /** diff --git a/lib/Doctrine/DBAL/Schema/OracleSchemaManager.php b/lib/Doctrine/DBAL/Schema/OracleSchemaManager.php index 0a3e76b1c51..cabc94b1867 100644 --- a/lib/Doctrine/DBAL/Schema/OracleSchemaManager.php +++ b/lib/Doctrine/DBAL/Schema/OracleSchemaManager.php @@ -89,10 +89,10 @@ protected function _getPortableTableDefinition($table) * * @link http://ezcomponents.org/docs/api/trunk/DatabaseSchema/ezcDbSchemaPgsqlReader.html */ - protected function _getPortableTableIndexesList($tableIndexes, $tableName = null) + protected function _getPortableTableIndexesList(array $tableIndexRows, string $tableName) : array { $indexBuffer = []; - foreach ($tableIndexes as $tableIndex) { + foreach ($tableIndexRows as $tableIndex) { $tableIndex = array_change_key_case($tableIndex, CASE_LOWER); $keyName = strtolower($tableIndex['name']); diff --git a/lib/Doctrine/DBAL/Schema/PostgreSqlSchemaManager.php b/lib/Doctrine/DBAL/Schema/PostgreSqlSchemaManager.php index d0f50562785..43a4d27ae35 100644 --- a/lib/Doctrine/DBAL/Schema/PostgreSqlSchemaManager.php +++ b/lib/Doctrine/DBAL/Schema/PostgreSqlSchemaManager.php @@ -209,10 +209,10 @@ protected function _getPortableTableDefinition($table) * * @link http://ezcomponents.org/docs/api/trunk/DatabaseSchema/ezcDbSchemaPgsqlReader.html */ - protected function _getPortableTableIndexesList($tableIndexes, $tableName = null) + protected function _getPortableTableIndexesList(array $tableIndexRows, string $tableName) : array { $buffer = []; - foreach ($tableIndexes as $row) { + foreach ($tableIndexRows as $row) { $colNumbers = array_map('intval', explode(' ', $row['indkey'])); $columnNameSql = sprintf( 'SELECT attnum, attname FROM pg_attribute WHERE attrelid=%d AND attnum IN (%s) ORDER BY attnum ASC', diff --git a/lib/Doctrine/DBAL/Schema/SQLAnywhereSchemaManager.php b/lib/Doctrine/DBAL/Schema/SQLAnywhereSchemaManager.php index c169a6e0708..0d875491167 100644 --- a/lib/Doctrine/DBAL/Schema/SQLAnywhereSchemaManager.php +++ b/lib/Doctrine/DBAL/Schema/SQLAnywhereSchemaManager.php @@ -194,7 +194,7 @@ protected function _getPortableTableForeignKeysList($tableForeignKeys) /** * {@inheritdoc} */ - protected function _getPortableTableIndexesList($tableIndexRows, $tableName = null) + protected function _getPortableTableIndexesList(array $tableIndexRows, string $tableName) : array { foreach ($tableIndexRows as &$tableIndex) { $tableIndex['primary'] = (bool) $tableIndex['primary']; diff --git a/lib/Doctrine/DBAL/Schema/SQLServerSchemaManager.php b/lib/Doctrine/DBAL/Schema/SQLServerSchemaManager.php index bd6b02cb9a0..757136418bd 100644 --- a/lib/Doctrine/DBAL/Schema/SQLServerSchemaManager.php +++ b/lib/Doctrine/DBAL/Schema/SQLServerSchemaManager.php @@ -168,7 +168,7 @@ protected function _getPortableTableForeignKeysList($tableForeignKeys) /** * {@inheritdoc} */ - protected function _getPortableTableIndexesList($tableIndexRows, $tableName = null) + protected function _getPortableTableIndexesList(array $tableIndexRows, string $tableName) : array { foreach ($tableIndexRows as &$tableIndex) { $tableIndex['non_unique'] = (bool) $tableIndex['non_unique']; diff --git a/lib/Doctrine/DBAL/Schema/SqliteSchemaManager.php b/lib/Doctrine/DBAL/Schema/SqliteSchemaManager.php index 9d03552b667..203617f0c8e 100644 --- a/lib/Doctrine/DBAL/Schema/SqliteSchemaManager.php +++ b/lib/Doctrine/DBAL/Schema/SqliteSchemaManager.php @@ -163,7 +163,7 @@ protected function _getPortableTableDefinition($table) * * @link http://ezcomponents.org/docs/api/trunk/DatabaseSchema/ezcDbSchemaPgsqlReader.html */ - protected function _getPortableTableIndexesList($tableIndexes, $tableName = null) + protected function _getPortableTableIndexesList(array $tableIndexRows, string $tableName) : array { $indexBuffer = []; @@ -195,7 +195,7 @@ protected function _getPortableTableIndexesList($tableIndexes, $tableName = null } // fetch regular indexes - foreach ($tableIndexes as $tableIndex) { + foreach ($tableIndexRows as $tableIndex) { // Ignore indexes with reserved names, e.g. autoindexes if (strpos($tableIndex['name'], 'sqlite_') === 0) { continue; diff --git a/lib/Doctrine/DBAL/Sharding/SQLAzure/SQLAzureShardManager.php b/lib/Doctrine/DBAL/Sharding/SQLAzure/SQLAzureShardManager.php index d8178ee07db..11bd965c158 100644 --- a/lib/Doctrine/DBAL/Sharding/SQLAzure/SQLAzureShardManager.php +++ b/lib/Doctrine/DBAL/Sharding/SQLAzure/SQLAzureShardManager.php @@ -202,7 +202,7 @@ public function splitFederation($splitDistributionValue) $sql = 'ALTER FEDERATION ' . $this->getFederationName() . ' ' . 'SPLIT AT (' . $this->getDistributionKey() . ' = ' . - $this->conn->quote($splitDistributionValue, $type->getBindingType()) . ')'; + $this->conn->quote($splitDistributionValue) . ')'; $this->conn->exec($sql); } } diff --git a/tests/Doctrine/Tests/DBAL/Functional/ConnectionTest.php b/tests/Doctrine/Tests/DBAL/Functional/ConnectionTest.php index d3a11b570b0..ad86f9c87d1 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/ConnectionTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/ConnectionTest.php @@ -6,9 +6,7 @@ use Doctrine\DBAL\ConnectionException; use Doctrine\DBAL\Driver\Connection as DriverConnection; use Doctrine\DBAL\DriverManager; -use Doctrine\DBAL\ParameterType; use Doctrine\DBAL\Platforms\AbstractPlatform; -use Doctrine\DBAL\Types\Type; use Doctrine\Tests\DbalFunctionalTestCase; use Error; use Exception; @@ -252,8 +250,8 @@ public function testTransactionalReturnValue() public function testQuote() { self::assertEquals( - $this->connection->quote('foo', Type::STRING), - $this->connection->quote('foo', ParameterType::STRING) + $this->connection->quote('foo'), + $this->connection->quote('foo') ); } diff --git a/tests/Doctrine/Tests/DBAL/Functional/DataAccessTest.php b/tests/Doctrine/Tests/DBAL/Functional/DataAccessTest.php index 8f6123d91a2..196385c4d01 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/DataAccessTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/DataAccessTest.php @@ -177,9 +177,9 @@ public function testPrepareWithQuoted() $paramStr = 'foo'; $stmt = $this->connection->prepare(sprintf( - 'SELECT test_int, test_string FROM %s WHERE test_int = %s AND test_string = %s', + 'SELECT test_int, test_string FROM %s WHERE test_int = %d AND test_string = %s', $this->connection->quoteIdentifier($table), - $this->connection->quote($paramInt), + $paramInt, $this->connection->quote($paramStr) )); self::assertInstanceOf(Statement::class, $stmt); diff --git a/tests/Doctrine/Tests/DBAL/Functional/WriteTest.php b/tests/Doctrine/Tests/DBAL/Functional/WriteTest.php index 52cef4d9fc2..b253fea9e53 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/WriteTest.php +++ b/tests/Doctrine/Tests/DBAL/Functional/WriteTest.php @@ -46,7 +46,7 @@ public function testExecuteUpdateFirstTypeIsNull() public function testExecuteUpdate() { - $sql = 'INSERT INTO write_table (test_int) VALUES ( ' . $this->connection->quote(1) . ')'; + $sql = 'INSERT INTO write_table (test_int) VALUES (1)'; $affected = $this->connection->executeUpdate($sql); self::assertEquals(1, $affected, 'executeUpdate() should return the number of affected rows!'); diff --git a/tests/Doctrine/Tests/DBAL/Schema/DB2SchemaManagerTest.php b/tests/Doctrine/Tests/DBAL/Schema/DB2SchemaManagerTest.php index b3f91149b32..7d11c926750 100644 --- a/tests/Doctrine/Tests/DBAL/Schema/DB2SchemaManagerTest.php +++ b/tests/Doctrine/Tests/DBAL/Schema/DB2SchemaManagerTest.php @@ -25,14 +25,19 @@ final class DB2SchemaManagerTest extends TestCase protected function setUp() : void { - $eventManager = new EventManager(); - $driverMock = $this->createMock(Driver::class); - $platform = $this->createMock(DB2Platform::class); - $this->conn = $this + $eventManager = new EventManager(); + $driverMock = $this->createMock(Driver::class); + $platform = $this->createMock(DB2Platform::class); + $this->conn = $this ->getMockBuilder(Connection::class) - ->setMethods(['fetchAll', 'quote']) + ->setMethods(['fetchAll', 'getUsername']) ->setConstructorArgs([['platform' => $platform], $driverMock, new Configuration(), $eventManager]) ->getMock(); + + $this->conn->expects($this->any()) + ->method('getUsername') + ->willReturn('db2inst1'); + $this->manager = new DB2SchemaManager($this->conn); } @@ -102,7 +107,7 @@ public function testListTableNamesFiltersAssetNamesCorrectlyWithCallable() $this->conn->getConfiguration()->setSchemaAssetsFilter(static function ($assetName) use ($accepted) { return in_array($assetName, $accepted); }); - $this->conn->expects($this->any())->method('quote'); + $this->conn->expects($this->once())->method('fetchAll')->will($this->returnValue([ ['name' => 'FOO'], ['name' => 'T_FOO'], @@ -130,7 +135,7 @@ public function testSettingNullExpressionWillResetCallable() $this->conn->getConfiguration()->setSchemaAssetsFilter(static function ($assetName) use ($accepted) { return in_array($assetName, $accepted); }); - $this->conn->expects($this->any())->method('quote'); + $this->conn->expects($this->atLeastOnce())->method('fetchAll')->will($this->returnValue([ ['name' => 'FOO'], ['name' => 'T_FOO'],