Deprecate executeUpdate() in favor of executeStatement()

parent cedf3a28
# Upgrade to 2.11
## Deprecations in the wrapper `Connection` class
1. The `executeUpdate()` method has been deprecated in favor of `executeStatement()`.
## PDO-related classes outside of the PDO namespace are deprecated
The following outside of the PDO namespace have been deprecated in favor of their counterparts in the PDO namespace:
......
......@@ -142,7 +142,7 @@ use prepared statements:
SQL query, bind the given params with their binding types and execute the query.
This method returns the executed prepared statement for iteration and is useful
for SELECT statements.
- ``executeUpdate($sql, $params, $types)`` - Create a prepared statement for the passed
- ``executeStatement($sql, $params, $types)`` - Create a prepared statement for the passed
SQL query, bind the given params with their binding types and execute the query.
This method returns the number of affected rows by the executed query and is useful
for UPDATE, DELETE and INSERT statements.
......@@ -170,7 +170,7 @@ of this query using the fetch API of a statement:
The fetch API of a prepared statement obviously works only for ``SELECT`` queries.
If you find it tedious to write all the prepared statement code you can alternatively use
the ``Doctrine\DBAL\Connection#executeQuery()`` and ``Doctrine\DBAL\Connection#executeUpdate()``
the ``Doctrine\DBAL\Connection#executeQuery()`` and ``Doctrine\DBAL\Connection#executeStatement()``
methods. See the API section below on details how to use them.
Additionally there are lots of convenience methods for data-retrieval and manipulation
......@@ -208,7 +208,7 @@ which means this code works independent of the database you are using.
.. note::
Be aware this type conversion only works with ``Statement#bindValue()``,
``Connection#executeQuery()`` and ``Connection#executeUpdate()``. It
``Connection#executeQuery()`` and ``Connection#executeStatement()``. It
is not supported to pass a doctrine type name to ``Statement#bindParam()``,
because this would not work with binding by reference.
......@@ -286,7 +286,7 @@ This is much more complicated and is ugly to write generically.
.. note::
The parameter list support only works with ``Doctrine\DBAL\Connection::executeQuery()``
and ``Doctrine\DBAL\Connection::executeUpdate()``, NOT with the binding methods of
and ``Doctrine\DBAL\Connection::executeStatement()``, NOT with the binding methods of
a prepared statement.
API
......@@ -319,7 +319,7 @@ Prepare a given SQL statement and return the
)
*/
executeUpdate()
executeStatement()
~~~~~~~~~~~~~~~
Executes a prepared statement with the given SQL and parameters and
......@@ -328,7 +328,7 @@ returns the affected rows count:
.. code-block:: php
<?php
$count = $conn->executeUpdate('UPDATE user SET username = ? WHERE id = ?', array('jwage', 1));
$count = $conn->executeStatement('UPDATE user SET username = ? WHERE id = ?', array('jwage', 1));
echo $count; // 1
The ``$types`` variable contains the PDO or Doctrine Type constants
......
......@@ -135,7 +135,7 @@ are using just the DBAL there are also helper methods which simplify the usage q
$sql = "SELECT * FROM users WHERE username = ?";
$stmt = $connection->executeQuery($sql, array($_GET['username']));
There is also ``executeUpdate`` which does not return a statement but the number of affected rows.
There is also ``executeStatement`` which does not return a statement but the number of affected rows.
Besides binding parameters you can also pass the type of the variable. This allows Doctrine or the underlying
vendor to not only escape but also cast the value to the correct type. See the docs on querying and DQL in the
......
......@@ -263,7 +263,7 @@ operation for us:
'LastName' => 'Brehm',
));
$conn->executeUpdate("DECLARE @orderId INT
$conn->executeStatement("DECLARE @orderId INT
DECLARE @customerId INT
......
......@@ -90,7 +90,7 @@ $conn->insert("Customers", array(
'LastName' => 'Brehm',
));
$conn->executeUpdate("
$conn->executeStatement("
DECLARE @orderId INT
DECLARE @customerId INT
......
......@@ -749,7 +749,7 @@ class Connection implements DriverConnection
$this->addIdentifierCondition($identifier, $columns, $values, $conditions);
return $this->executeUpdate(
return $this->executeStatement(
'DELETE FROM ' . $tableExpression . ' WHERE ' . implode(' AND ', $conditions),
$values,
is_string(key($types)) ? $this->extractTypeValues($columns, $types) : $types
......@@ -777,7 +777,7 @@ class Connection implements DriverConnection
{
$this->transactionIsolationLevel = $level;
return $this->executeUpdate($this->getDatabasePlatform()->getSetTransactionIsolationSQL($level));
return $this->executeStatement($this->getDatabasePlatform()->getSetTransactionIsolationSQL($level));
}
/**
......@@ -827,7 +827,7 @@ class Connection implements DriverConnection
$sql = 'UPDATE ' . $tableExpression . ' SET ' . implode(', ', $set)
. ' WHERE ' . implode(' AND ', $conditions);
return $this->executeUpdate($sql, $values, $types);
return $this->executeStatement($sql, $values, $types);
}
/**
......@@ -846,7 +846,7 @@ class Connection implements DriverConnection
public function insert($tableExpression, array $data, array $types = [])
{
if (empty($data)) {
return $this->executeUpdate('INSERT INTO ' . $tableExpression . ' () VALUES ()');
return $this->executeStatement('INSERT INTO ' . $tableExpression . ' () VALUES ()');
}
$columns = [];
......@@ -859,7 +859,7 @@ class Connection implements DriverConnection
$set[] = '?';
}
return $this->executeUpdate(
return $this->executeStatement(
'INSERT INTO ' . $tableExpression . ' (' . implode(', ', $columns) . ')' .
' VALUES (' . implode(', ', $set) . ')',
$values,
......@@ -1285,6 +1285,8 @@ class Connection implements DriverConnection
*
* This method supports PDO binding types as well as DBAL mapping types.
*
* @deprecated Use {@link executeStatement()} instead.
*
* @param string $query The SQL query.
* @param array<mixed> $params The query parameters.
* @param array<int|string|null> $types The parameter types.
......@@ -1294,19 +1296,44 @@ class Connection implements DriverConnection
* @throws DBALException
*/
public function executeUpdate($query, array $params = [], array $types = [])
{
return $this->executeStatement($query, $params, $types);
}
/**
* Executes an SQL statement with the given parameters and returns the number of affected rows.
*
* Could be used for:
* - DML statements: INSERT, UPDATE, DELETE, etc.
* - DDL statements: CREATE, DROP, ALTER, etc.
* - DCL statements: GRANT, REVOKE, etc.
* - Session control statements: ALTER SESSION, SET, DECLARE, etc.
* - Other statements that don't yield a row set.
*
* This method supports PDO binding types as well as DBAL mapping types.
*
* @param string $sql The statement SQL
* @param array<mixed> $params The query parameters
* @param array<int|string|null> $types The parameter types
*
* @return int The number of affected rows.
*
* @throws DBALException
*/
public function executeStatement($sql, array $params = [], array $types = [])
{
$connection = $this->getWrappedConnection();
$logger = $this->_config->getSQLLogger();
if ($logger) {
$logger->startQuery($query, $params, $types);
$logger->startQuery($sql, $params, $types);
}
try {
if ($params) {
[$query, $params, $types] = SQLParserUtils::expandListParameters($query, $params, $types);
[$sql, $params, $types] = SQLParserUtils::expandListParameters($sql, $params, $types);
$stmt = $connection->prepare($query);
$stmt = $connection->prepare($sql);
if ($types) {
$this->_bindTypedValues($stmt, $params, $types);
......@@ -1317,10 +1344,10 @@ class Connection implements DriverConnection
$result = $stmt->rowCount();
} else {
$result = $connection->exec($query);
$result = $connection->exec($sql);
}
} catch (Throwable $e) {
$this->handleExceptionDuringQuery($e, $query, $params, $types);
$this->handleExceptionDuringQuery($e, $sql, $params, $types);
}
if ($logger) {
......
......@@ -26,7 +26,7 @@ use function func_get_args;
*
* 1. Replica if primary was never picked before and ONLY if 'getWrappedConnection'
* or 'executeQuery' is used.
* 2. Primary picked when 'exec', 'executeUpdate', 'insert', 'delete', 'update', 'createSavepoint',
* 2. Primary picked when 'exec', 'executeUpdate', 'executeStatement', 'insert', 'delete', 'update', 'createSavepoint',
* 'releaseSavepoint', 'beginTransaction', 'rollback', 'commit', 'query' or
* 'prepare' is called.
* 3. If Primary was picked once during the lifetime of the connection it will always get picked afterwards.
......@@ -41,7 +41,7 @@ use function func_get_args;
* Be aware that Connection#executeQuery is a method specifically for READ
* operations only.
*
* Use Connection#executeUpdate for any SQL statement that changes/updates
* Use Connection#executeStatement for any SQL statement that changes/updates
* state in the database (UPDATE, INSERT, DELETE or DDL statements).
*
* This connection is limited to replica operations using the
......@@ -256,6 +256,8 @@ class PrimaryReadReplicaConnection extends Connection
/**
* {@inheritDoc}
*
* @deprecated Use {@link executeStatement()} instead.
*/
public function executeUpdate($query, array $params = [], array $types = [])
{
......@@ -264,6 +266,16 @@ class PrimaryReadReplicaConnection extends Connection
return parent::executeUpdate($query, $params, $types);
}
/**
* {@inheritDoc}
*/
public function executeStatement($query, array $params = [], array $types = [])
{
$this->ensureConnectedToPrimary();
return parent::executeStatement($query, $params, $types);
}
/**
* {@inheritDoc}
*/
......
......@@ -45,7 +45,7 @@ class MysqlSessionInit implements EventSubscriber
public function postConnect(ConnectionEventArgs $args)
{
$collation = $this->collation ? ' COLLATE ' . $this->collation : '';
$args->getConnection()->executeUpdate('SET NAMES ' . $this->charset . $collation);
$args->getConnection()->executeStatement('SET NAMES ' . $this->charset . $collation);
}
/**
......
......@@ -61,7 +61,7 @@ class OracleSessionInit implements EventSubscriber
}
$sql = 'ALTER SESSION SET ' . implode(' ', $vars);
$args->getConnection()->executeUpdate($sql);
$args->getConnection()->executeStatement($sql);
}
/**
......
......@@ -131,7 +131,7 @@ class TableGenerator
$sql = 'UPDATE ' . $this->generatorTableName . ' ' .
'SET sequence_value = sequence_value + sequence_increment_by ' .
'WHERE sequence_name = ? AND sequence_value = ?';
$rows = $this->conn->executeUpdate($sql, [$sequenceName, $row['sequence_value']]);
$rows = $this->conn->executeStatement($sql, [$sequenceName, $row['sequence_value']]);
if ($rows !== 1) {
throw new DBALException('Race-condition detected while updating sequence. Aborting generation');
......
......@@ -196,9 +196,6 @@ class QueryBuilder
/**
* Executes this query using the bound parameters and their types.
*
* Uses {@see Connection::executeQuery} for select statements and {@see Connection::executeUpdate}
* for insert, update and delete statements.
*
* @return ResultStatement|int
*/
public function execute()
......@@ -207,7 +204,7 @@ class QueryBuilder
return $this->connection->executeQuery($this->getSQL(), $this->params, $this->paramTypes);
}
return $this->connection->executeUpdate($this->getSQL(), $this->params, $this->paramTypes);
return $this->connection->executeStatement($this->getSQL(), $this->params, $this->paramTypes);
}
/**
......
......@@ -1033,7 +1033,7 @@ abstract class AbstractSchemaManager
protected function _execSql($sql)
{
foreach ((array) $sql as $query) {
$this->_conn->executeUpdate($query);
$this->_conn->executeStatement($query);
}
}
......
......@@ -307,10 +307,10 @@ class OracleSchemaManager extends AbstractSchemaManager
$password = $params['password'];
$query = 'CREATE USER ' . $username . ' IDENTIFIED BY ' . $password;
$this->_conn->executeUpdate($query);
$this->_conn->executeStatement($query);
$query = 'GRANT DBA TO ' . $username;
$this->_conn->executeUpdate($query);
$this->_conn->executeStatement($query);
}
/**
......@@ -324,7 +324,7 @@ class OracleSchemaManager extends AbstractSchemaManager
$sql = $this->_platform->getDropAutoincrementSql($table);
foreach ($sql as $query) {
$this->_conn->executeUpdate($query);
$this->_conn->executeStatement($query);
}
return true;
......
......@@ -87,7 +87,7 @@ EOT
if (stripos($sql, 'select') === 0 || $input->getOption('force-fetch')) {
$resultSet = $conn->fetchAllAssociative($sql);
} else {
$resultSet = $conn->executeUpdate($sql);
$resultSet = $conn->executeStatement($sql);
}
$output->write(Dumper::dump($resultSet, (int) $depth));
......
......@@ -22,13 +22,13 @@ final class LoggingTest extends TestCase
->executeQuery('SELECT * FROM table');
}
public function testLogExecuteUpdate(): void
public function testLogExecuteStatement(): void
{
$this->createConnection(
$this->createStub(DriverConnection::class),
'UPDATE table SET foo = ?'
)
->executeUpdate('UPDATE table SET foo = ?');
->executeStatement('UPDATE table SET foo = ?');
}
public function testLogPrepareExecute(): void
......
......@@ -54,7 +54,7 @@ class ConnectionTest extends DbalTestCase
/**
* @return Connection|MockObject
*/
private function getExecuteUpdateMockConnection()
private function getExecuteStatementMockConnection()
{
$driverMock = $this->createMock(Driver::class);
......@@ -67,7 +67,7 @@ class ConnectionTest extends DbalTestCase
$platform = $this->getMockForAbstractClass(AbstractPlatform::class);
return $this->getMockBuilder(Connection::class)
->onlyMethods(['executeUpdate'])
->onlyMethods(['executeStatement'])
->setConstructorArgs([['platform' => $platform], $driverMock])
->getMock();
}
......@@ -203,7 +203,7 @@ class ConnectionTest extends DbalTestCase
['exec'],
['query'],
['executeQuery'],
['executeUpdate'],
['executeStatement'],
['prepare'],
];
}
......@@ -372,10 +372,10 @@ class ConnectionTest extends DbalTestCase
public function testEmptyInsert(): void
{
$conn = $this->getExecuteUpdateMockConnection();
$conn = $this->getExecuteStatementMockConnection();
$conn->expects($this->once())
->method('executeUpdate')
->method('executeStatement')
->with('INSERT INTO footable () VALUES ()');
$conn->insert('footable', []);
......@@ -386,10 +386,10 @@ class ConnectionTest extends DbalTestCase
*/
public function testUpdateWithDifferentColumnsInDataAndIdentifiers(): void
{
$conn = $this->getExecuteUpdateMockConnection();
$conn = $this->getExecuteStatementMockConnection();
$conn->expects($this->once())
->method('executeUpdate')
->method('executeStatement')
->with(
'UPDATE TestTable SET text = ?, is_edited = ? WHERE id = ? AND name = ?',
[
......@@ -430,10 +430,10 @@ class ConnectionTest extends DbalTestCase
*/
public function testUpdateWithSameColumnInDataAndIdentifiers(): void
{
$conn = $this->getExecuteUpdateMockConnection();
$conn = $this->getExecuteStatementMockConnection();
$conn->expects($this->once())
->method('executeUpdate')
->method('executeStatement')
->with(
'UPDATE TestTable SET text = ?, is_edited = ? WHERE id = ? AND is_edited = ?',
[
......@@ -473,10 +473,10 @@ class ConnectionTest extends DbalTestCase
*/
public function testUpdateWithIsNull(): void
{
$conn = $this->getExecuteUpdateMockConnection();
$conn = $this->getExecuteStatementMockConnection();
$conn->expects($this->once())
->method('executeUpdate')
->method('executeStatement')
->with(
'UPDATE TestTable SET text = ?, is_edited = ? WHERE id IS NULL AND name = ?',
[
......@@ -515,10 +515,10 @@ class ConnectionTest extends DbalTestCase
*/
public function testDeleteWithIsNull(): void
{
$conn = $this->getExecuteUpdateMockConnection();
$conn = $this->getExecuteStatementMockConnection();
$conn->expects($this->once())
->method('executeUpdate')
->method('executeStatement')
->with(
'DELETE FROM TestTable WHERE id IS NULL AND name = ?',
['foo'],
......@@ -725,7 +725,7 @@ class ConnectionTest extends DbalTestCase
['insert', ['tbl', ['data' => 'foo']]],
['update', ['tbl', ['data' => 'bar'], ['id' => 12345]]],
['prepare', ['select * from dual']],
['executeUpdate', ['insert into tbl (id) values (?)'], [123]],
['executeStatement', ['insert into tbl (id) values (?)'], [123]],
];
}
......
......@@ -14,7 +14,7 @@ class MysqlSessionInitTest extends DbalTestCase
{
$connectionMock = $this->createMock(Connection::class);
$connectionMock->expects($this->once())
->method('executeUpdate')
->method('executeStatement')
->with($this->equalTo('SET NAMES foo COLLATE bar'));
$eventArgs = new ConnectionEventArgs($connectionMock);
......
......@@ -16,7 +16,7 @@ class OracleSessionInitTest extends DbalTestCase
{
$connectionMock = $this->createMock(Connection::class);
$connectionMock->expects($this->once())
->method('executeUpdate')
->method('executeStatement')
->with($this->isType('string'));
$eventArgs = new ConnectionEventArgs($connectionMock);
......@@ -35,7 +35,7 @@ class OracleSessionInitTest extends DbalTestCase
->disableOriginalConstructor()
->getMock();
$connectionMock->expects($this->once())
->method('executeUpdate')
->method('executeStatement')
->with($this->stringContains(sprintf('%s = %s', $name, $value)));
$eventArgs = new ConnectionEventArgs($connectionMock);
......
......@@ -437,12 +437,12 @@ class DataAccessTest extends DbalFunctionalTestCase
/**
* @group DDC-697
*/
public function testExecuteUpdateBindDateTimeType(): void
public function testExecuteStatementBindDateTimeType(): void
{
$datetime = new DateTime('2010-02-02 20:20:20');
$sql = 'INSERT INTO fetch_table (test_int, test_string, test_datetime) VALUES (?, ?, ?)';
$affectedRows = $this->connection->executeUpdate($sql, [
$affectedRows = $this->connection->executeStatement($sql, [
1 => 50,
2 => 'foo',
3 => $datetime,
......@@ -800,7 +800,7 @@ class DataAccessTest extends DbalFunctionalTestCase
public function testFetchAllStyleColumn(): void
{
$sql = 'DELETE FROM fetch_table';
$this->connection->executeUpdate($sql);
$this->connection->executeStatement($sql);
$this->connection->insert('fetch_table', ['test_int' => 1, 'test_string' => 'foo']);
$this->connection->insert('fetch_table', ['test_int' => 10, 'test_string' => 'foo']);
......@@ -903,7 +903,7 @@ class DataAccessTest extends DbalFunctionalTestCase
*/
public function testFetchColumnNullValue(): void
{
$this->connection->executeUpdate(
$this->connection->executeStatement(
'INSERT INTO fetch_table (test_int, test_string) VALUES (?, ?)',
[2, 'foo']
);
......
......@@ -40,7 +40,7 @@ class ConnectionTest extends DbalFunctionalTestCase
$schemaManager->dropAndCreateTable($table);
$this->connection->executeUpdate('INSERT INTO DBAL2595 (foo) VALUES (1)');
$this->connection->executeStatement('INSERT INTO DBAL2595 (foo) VALUES (1)');
$schema = $this->connection->getDatabase();
$sequence = $platform->getIdentitySequenceName($schema . '.DBAL2595', 'id');
......
......@@ -201,7 +201,7 @@ class ExceptionTest extends DbalFunctionalTestCase
$this->expectException(Exception\ForeignKeyConstraintViolationException::class);
try {
$this->connection->executeUpdate($platform->getTruncateTableSQL('constraint_error_table'));
$this->connection->executeStatement($platform->getTruncateTableSQL('constraint_error_table'));
} catch (Exception\ForeignKeyConstraintViolationException $exception) {
$this->tearDownForeignKeyConstraintViolationExceptionTest();
......
......@@ -43,7 +43,7 @@ class MasterSlaveConnectionTest extends DbalFunctionalTestCase
} catch (Throwable $e) {
}
$this->connection->executeUpdate('DELETE FROM master_slave_table');
$this->connection->executeStatement('DELETE FROM master_slave_table');
$this->connection->insert('master_slave_table', ['test_int' => 1]);
}
......
......@@ -43,7 +43,7 @@ class PrimaryReadReplicaConnectionTest extends DbalFunctionalTestCase
} catch (Throwable $e) {
}
$this->connection->executeUpdate('DELETE FROM primary_replica_table');
$this->connection->executeStatement('DELETE FROM primary_replica_table');
$this->connection->insert('primary_replica_table', ['test_int' => 1]);
}
......
......@@ -458,7 +458,7 @@ class MySqlSchemaManagerTest extends SchemaManagerFunctionalTestCase
$this->schemaManager->dropAndCreateTable($table);
$this->connection->executeUpdate(
$this->connection->executeStatement(
'INSERT INTO test_column_defaults_are_valid () VALUES()'
);
......
......@@ -224,7 +224,7 @@ abstract class SchemaManagerFunctionalTestCase extends DbalFunctionalTestCase
$namespaces = array_map('strtolower', $namespaces);
if (! in_array('test_create_schema', $namespaces)) {
$this->connection->executeUpdate($this->schemaManager->getDatabasePlatform()->getCreateSchemaSQL('test_create_schema'));
$this->connection->executeStatement($this->schemaManager->getDatabasePlatform()->getCreateSchemaSQL('test_create_schema'));
$namespaces = $this->schemaManager->listNamespaceNames();
$namespaces = array_map('strtolower', $namespaces);
......
......@@ -49,7 +49,7 @@ class TemporaryTableTest extends DbalFunctionalTestCase
$createTempTableSQL = $platform->getCreateTemporaryTableSnippetSQL() . ' ' . $tempTable . ' ('
. $platform->getColumnDeclarationListSQL($columnDefinitions) . ')';
$this->connection->executeUpdate($createTempTableSQL);
$this->connection->executeStatement($createTempTableSQL);
$table = new Table('nontemporary');
$table->addColumn('id', 'integer');
......
......@@ -48,7 +48,7 @@ class DBAL630Test extends DbalFunctionalTestCase
public function testBooleanConversionSqlLiteral(): void
{
$this->connection->executeUpdate('INSERT INTO dbal630 (bool_col) VALUES(false)');
$this->connection->executeStatement('INSERT INTO dbal630 (bool_col) VALUES(false)');
$id = $this->connection->lastInsertId('dbal630_id_seq');
self::assertNotEmpty($id);
......@@ -59,7 +59,7 @@ class DBAL630Test extends DbalFunctionalTestCase
public function testBooleanConversionBoolParamRealPrepares(): void
{
$this->connection->executeUpdate(
$this->connection->executeStatement(
'INSERT INTO dbal630 (bool_col) VALUES(?)',
['false'],
[ParameterType::BOOLEAN]
......
......@@ -32,39 +32,39 @@ class WriteTest extends DbalFunctionalTestCase
} catch (Throwable $e) {
}
$this->connection->executeUpdate('DELETE FROM write_table');
$this->connection->executeStatement('DELETE FROM write_table');
}
/**
* @group DBAL-80
*/
public function testExecuteUpdateFirstTypeIsNull(): void
public function testExecuteStatementFirstTypeIsNull(): void
{
$sql = 'INSERT INTO write_table (test_string, test_int) VALUES (?, ?)';
$this->connection->executeUpdate($sql, ['text', 1111], [null, ParameterType::INTEGER]);
$this->connection->executeStatement($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
public function testExecuteStatement(): void
{
$sql = 'INSERT INTO write_table (test_int) VALUES ( ' . $this->connection->quote(1) . ')';
$affected = $this->connection->executeUpdate($sql);
$affected = $this->connection->executeStatement($sql);
self::assertEquals(1, $affected, 'executeUpdate() should return the number of affected rows!');
self::assertEquals(1, $affected, 'executeStatement() should return the number of affected rows!');
}
public function testExecuteUpdateWithTypes(): void
public function testExecuteStatementWithTypes(): void
{
$sql = 'INSERT INTO write_table (test_int, test_string) VALUES (?, ?)';
$affected = $this->connection->executeUpdate(
$affected = $this->connection->executeStatement(
$sql,
[1, 'foo'],
[ParameterType::INTEGER, ParameterType::STRING]
);
self::assertEquals(1, $affected, 'executeUpdate() should return the number of affected rows!');
self::assertEquals(1, $affected, 'executeStatement() should return the number of affected rows!');
}
public function testPrepareRowCountReturnsAffectedRows(): void
......
......@@ -79,7 +79,7 @@ class RunSqlCommandTest extends TestCase
public function testUpdateStatementsPrintsAffectedLines(): void
{
$this->expectConnectionExecuteUpdate();
$this->expectConnectionExecuteStatement();
$this->commandTester->execute([
'command' => $this->command->getName(),
......@@ -90,11 +90,11 @@ class RunSqlCommandTest extends TestCase
self::assertDoesNotMatchRegularExpression('@array.*1.*@', $this->commandTester->getDisplay());
}
private function expectConnectionExecuteUpdate(): void
private function expectConnectionExecuteStatement(): void
{
$this->connectionMock
->expects($this->once())
->method('executeUpdate')
->method('executeStatement')
->willReturn(42);
$this->connectionMock
......@@ -111,7 +111,7 @@ class RunSqlCommandTest extends TestCase
$this->connectionMock
->expects($this->never())
->method('executeUpdate');
->method('executeStatement');
}
public function testStatementsWithFetchResultPrintsResult(): 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