Commit 36f7e929 authored by Bas Peeters's avatar Bas Peeters

Replace usage of deprecated MockBuilder setMethods

parent 2c2cdd90
...@@ -67,7 +67,7 @@ class ConnectionTest extends DbalTestCase ...@@ -67,7 +67,7 @@ class ConnectionTest extends DbalTestCase
$platform = $this->getMockForAbstractClass(AbstractPlatform::class); $platform = $this->getMockForAbstractClass(AbstractPlatform::class);
return $this->getMockBuilder(Connection::class) return $this->getMockBuilder(Connection::class)
->setMethods(['executeUpdate']) ->onlyMethods(['executeUpdate'])
->setConstructorArgs([['platform' => $platform], $driverMock]) ->setConstructorArgs([['platform' => $platform], $driverMock])
->getMock(); ->getMock();
} }
...@@ -145,8 +145,8 @@ class ConnectionTest extends DbalTestCase ...@@ -145,8 +145,8 @@ class ConnectionTest extends DbalTestCase
public function testConnectDispatchEvent() : void public function testConnectDispatchEvent() : void
{ {
$listenerMock = $this->getMockBuilder('ConnectDispatchEventListener') $listenerMock = $this->getMockBuilder($this->getMockClass('ConnectDispatchEventListener'))
->setMethods(['postConnect']) ->addMethods(['postConnect'])
->getMock(); ->getMock();
$listenerMock->expects($this->once())->method('postConnect'); $listenerMock->expects($this->once())->method('postConnect');
...@@ -566,7 +566,7 @@ class ConnectionTest extends DbalTestCase ...@@ -566,7 +566,7 @@ class ConnectionTest extends DbalTestCase
/** @var Connection|MockObject $conn */ /** @var Connection|MockObject $conn */
$conn = $this->getMockBuilder(Connection::class) $conn = $this->getMockBuilder(Connection::class)
->setMethods(['executeQuery']) ->onlyMethods(['executeQuery'])
->setConstructorArgs([[], $driverMock]) ->setConstructorArgs([[], $driverMock])
->getMock(); ->getMock();
...@@ -602,7 +602,7 @@ class ConnectionTest extends DbalTestCase ...@@ -602,7 +602,7 @@ class ConnectionTest extends DbalTestCase
/** @var Connection|MockObject $conn */ /** @var Connection|MockObject $conn */
$conn = $this->getMockBuilder(Connection::class) $conn = $this->getMockBuilder(Connection::class)
->setMethods(['executeQuery']) ->onlyMethods(['executeQuery'])
->setConstructorArgs([[], $driverMock]) ->setConstructorArgs([[], $driverMock])
->getMock(); ->getMock();
...@@ -639,7 +639,7 @@ class ConnectionTest extends DbalTestCase ...@@ -639,7 +639,7 @@ class ConnectionTest extends DbalTestCase
/** @var Connection|MockObject $conn */ /** @var Connection|MockObject $conn */
$conn = $this->getMockBuilder(Connection::class) $conn = $this->getMockBuilder(Connection::class)
->setMethods(['executeQuery']) ->onlyMethods(['executeQuery'])
->setConstructorArgs([[], $driverMock]) ->setConstructorArgs([[], $driverMock])
->getMock(); ->getMock();
...@@ -674,7 +674,7 @@ class ConnectionTest extends DbalTestCase ...@@ -674,7 +674,7 @@ class ConnectionTest extends DbalTestCase
/** @var Connection|MockObject $conn */ /** @var Connection|MockObject $conn */
$conn = $this->getMockBuilder(Connection::class) $conn = $this->getMockBuilder(Connection::class)
->setMethods(['executeQuery']) ->onlyMethods(['executeQuery'])
->setConstructorArgs([[], $driverMock]) ->setConstructorArgs([[], $driverMock])
->getMock(); ->getMock();
...@@ -756,7 +756,7 @@ class ConnectionTest extends DbalTestCase ...@@ -756,7 +756,7 @@ class ConnectionTest extends DbalTestCase
$conn = $this->getMockBuilder(Connection::class) $conn = $this->getMockBuilder(Connection::class)
->setConstructorArgs([['pdo' => $pdoMock, 'platform' => $platformMock], $driverMock]) ->setConstructorArgs([['pdo' => $pdoMock, 'platform' => $platformMock], $driverMock])
->setMethods(['connect']) ->onlyMethods(['connect'])
->getMock(); ->getMock();
$conn->expects($this->once())->method('connect'); $conn->expects($this->once())->method('connect');
......
...@@ -36,7 +36,7 @@ class OCI8StatementTest extends DbalTestCase ...@@ -36,7 +36,7 @@ class OCI8StatementTest extends DbalTestCase
public function testExecute(array $params) : void public function testExecute(array $params) : void
{ {
$statement = $this->getMockBuilder(OCI8Statement::class) $statement = $this->getMockBuilder(OCI8Statement::class)
->setMethods(['bindValue', 'errorInfo']) ->onlyMethods(['bindValue', 'errorInfo'])
->disableOriginalConstructor() ->disableOriginalConstructor()
->getMock(); ->getMock();
...@@ -67,7 +67,7 @@ class OCI8StatementTest extends DbalTestCase ...@@ -67,7 +67,7 @@ class OCI8StatementTest extends DbalTestCase
// can't pass to constructor since we don't have a real database handle, // can't pass to constructor since we don't have a real database handle,
// but execute must check the connection for the executeMode // but execute must check the connection for the executeMode
$conn = $this->getMockBuilder(OCI8Connection::class) $conn = $this->getMockBuilder(OCI8Connection::class)
->setMethods(['getExecuteMode']) ->onlyMethods(['getExecuteMode'])
->disableOriginalConstructor() ->disableOriginalConstructor()
->getMock(); ->getMock();
$conn->expects($this->once()) $conn->expects($this->once())
......
...@@ -367,10 +367,10 @@ abstract class SchemaManagerFunctionalTestCase extends DbalFunctionalTestCase ...@@ -367,10 +367,10 @@ abstract class SchemaManagerFunctionalTestCase extends DbalFunctionalTestCase
$this->schemaManager->dropAndCreateTable($table); $this->schemaManager->dropAndCreateTable($table);
$listenerMock = $this $listenerMock = $this->getMockBuilder($this->getMockClass('ListTableColumnsDispatchEventListener'))
->getMockBuilder('ListTableColumnsDispatchEventListener') ->addMethods(['onSchemaColumnDefinition'])
->setMethods(['onSchemaColumnDefinition'])
->getMock(); ->getMock();
$listenerMock $listenerMock
->expects($this->exactly(7)) ->expects($this->exactly(7))
->method('onSchemaColumnDefinition'); ->method('onSchemaColumnDefinition');
...@@ -395,9 +395,8 @@ abstract class SchemaManagerFunctionalTestCase extends DbalFunctionalTestCase ...@@ -395,9 +395,8 @@ abstract class SchemaManagerFunctionalTestCase extends DbalFunctionalTestCase
$this->schemaManager->dropAndCreateTable($table); $this->schemaManager->dropAndCreateTable($table);
$listenerMock = $this $listenerMock = $this->getMockBuilder($this->getMockClass('ListTableIndexesDispatchEventListener'))
->getMockBuilder('ListTableIndexesDispatchEventListener') ->addMethods(['onSchemaIndexDefinition'])
->setMethods(['onSchemaIndexDefinition'])
->getMock(); ->getMock();
$listenerMock $listenerMock
->expects($this->exactly(3)) ->expects($this->exactly(3))
......
...@@ -380,8 +380,8 @@ abstract class AbstractPlatformTestCase extends DbalTestCase ...@@ -380,8 +380,8 @@ abstract class AbstractPlatformTestCase extends DbalTestCase
public function testGetCreateTableSqlDispatchEvent() : void public function testGetCreateTableSqlDispatchEvent() : void
{ {
$listenerMock = $this->getMockBuilder('GetCreateTableSqlDispatchEvenListener') $listenerMock = $this->getMockBuilder($this->getMockClass('GetCreateTableSqlDispatchEvenListener'))
->setMethods(['onSchemaCreateTable', 'onSchemaCreateTableColumn']) ->addMethods(['onSchemaCreateTable', 'onSchemaCreateTableColumn'])
->getMock(); ->getMock();
$listenerMock $listenerMock
->expects($this->once()) ->expects($this->once())
...@@ -404,8 +404,8 @@ abstract class AbstractPlatformTestCase extends DbalTestCase ...@@ -404,8 +404,8 @@ abstract class AbstractPlatformTestCase extends DbalTestCase
public function testGetDropTableSqlDispatchEvent() : void public function testGetDropTableSqlDispatchEvent() : void
{ {
$listenerMock = $this->getMockBuilder('GetDropTableSqlDispatchEventListener') $listenerMock = $this->getMockBuilder($this->getMockClass('GetDropTableSqlDispatchEventListener'))
->setMethods(['onSchemaDropTable']) ->addMethods(['onSchemaDropTable'])
->getMock(); ->getMock();
$listenerMock $listenerMock
->expects($this->once()) ->expects($this->once())
...@@ -429,8 +429,8 @@ abstract class AbstractPlatformTestCase extends DbalTestCase ...@@ -429,8 +429,8 @@ abstract class AbstractPlatformTestCase extends DbalTestCase
'onSchemaAlterTableRenameColumn', 'onSchemaAlterTableRenameColumn',
]; ];
$listenerMock = $this->getMockBuilder('GetAlterTableSqlDispatchEvenListener') $listenerMock = $this->getMockBuilder($this->getMockClass('GetAlterTableSqlDispatchEvenListener'))
->setMethods($events) ->addMethods($events)
->getMock(); ->getMock();
$listenerMock $listenerMock
->expects($this->once()) ->expects($this->once())
......
...@@ -1172,10 +1172,10 @@ class ComparatorTest extends TestCase ...@@ -1172,10 +1172,10 @@ class ComparatorTest extends TestCase
{ {
$comparator = new Comparator(); $comparator = new Comparator();
$fromSchema = $this->getMockBuilder(Schema::class) $fromSchema = $this->getMockBuilder(Schema::class)
->setMethods(['getNamespaces', 'hasNamespace']) ->onlyMethods(['getNamespaces', 'hasNamespace'])
->getMock(); ->getMock();
$toSchema = $this->getMockBuilder(Schema::class) $toSchema = $this->getMockBuilder(Schema::class)
->setMethods(['getNamespaces', 'hasNamespace']) ->onlyMethods(['getNamespaces', 'hasNamespace'])
->getMock(); ->getMock();
$fromSchema->expects($this->once()) $fromSchema->expects($this->once())
......
...@@ -30,7 +30,7 @@ final class DB2SchemaManagerTest extends TestCase ...@@ -30,7 +30,7 @@ final class DB2SchemaManagerTest extends TestCase
$platform = $this->createMock(DB2Platform::class); $platform = $this->createMock(DB2Platform::class);
$this->conn = $this $this->conn = $this
->getMockBuilder(Connection::class) ->getMockBuilder(Connection::class)
->setMethods(['fetchAll', 'quote']) ->onlyMethods(['fetchAll', 'quote'])
->setConstructorArgs([['platform' => $platform], $driverMock, new Configuration(), $eventManager]) ->setConstructorArgs([['platform' => $platform], $driverMock, new Configuration(), $eventManager])
->getMock(); ->getMock();
$this->manager = new DB2SchemaManager($this->conn); $this->manager = new DB2SchemaManager($this->conn);
......
...@@ -27,7 +27,7 @@ class MySqlSchemaManagerTest extends TestCase ...@@ -27,7 +27,7 @@ class MySqlSchemaManagerTest extends TestCase
$driverMock = $this->createMock(Driver::class); $driverMock = $this->createMock(Driver::class);
$platform = $this->createMock(MySqlPlatform::class); $platform = $this->createMock(MySqlPlatform::class);
$this->conn = $this->getMockBuilder(Connection::class) $this->conn = $this->getMockBuilder(Connection::class)
->setMethods(['fetchAll']) ->onlyMethods(['fetchAll'])
->setConstructorArgs([['platform' => $platform], $driverMock, new Configuration(), $eventManager]) ->setConstructorArgs([['platform' => $platform], $driverMock, new Configuration(), $eventManager])
->getMock(); ->getMock();
$this->manager = new MySqlSchemaManager($this->conn); $this->manager = new MySqlSchemaManager($this->conn);
......
...@@ -26,7 +26,7 @@ class CreateSchemaSqlCollectorTest extends TestCase ...@@ -26,7 +26,7 @@ class CreateSchemaSqlCollectorTest extends TestCase
parent::setUp(); parent::setUp();
$this->platformMock = $this->getMockBuilder(AbstractPlatform::class) $this->platformMock = $this->getMockBuilder(AbstractPlatform::class)
->setMethods( ->onlyMethods(
[ [
'getCreateForeignKeySQL', 'getCreateForeignKeySQL',
'getCreateSchemaSQL', 'getCreateSchemaSQL',
......
...@@ -23,7 +23,7 @@ class DropSchemaSqlCollectorTest extends TestCase ...@@ -23,7 +23,7 @@ class DropSchemaSqlCollectorTest extends TestCase
$keyConstraintTwo = $this->getStubKeyConstraint('second'); $keyConstraintTwo = $this->getStubKeyConstraint('second');
$platform = $this->getMockBuilder(AbstractPlatform::class) $platform = $this->getMockBuilder(AbstractPlatform::class)
->setMethods(['getDropForeignKeySQL']) ->onlyMethods(['getDropForeignKeySQL'])
->getMockForAbstractClass(); ->getMockForAbstractClass();
$collector = new DropSchemaSqlCollector($platform); $collector = new DropSchemaSqlCollector($platform);
......
...@@ -11,7 +11,7 @@ class SchemaSqlCollectorTest extends TestCase ...@@ -11,7 +11,7 @@ class SchemaSqlCollectorTest extends TestCase
public function testCreateSchema() : void public function testCreateSchema() : void
{ {
$platformMock = $this->getMockBuilder(MySqlPlatform::class) $platformMock = $this->getMockBuilder(MySqlPlatform::class)
->setMethods(['getCreateTableSql', 'getCreateSequenceSql', 'getCreateForeignKeySql']) ->onlyMethods(['getCreateTableSql', 'getCreateSequenceSql', 'getCreateForeignKeySql'])
->getMock(); ->getMock();
$platformMock->expects($this->exactly(2)) $platformMock->expects($this->exactly(2))
->method('getCreateTableSql') ->method('getCreateTableSql')
...@@ -33,7 +33,7 @@ class SchemaSqlCollectorTest extends TestCase ...@@ -33,7 +33,7 @@ class SchemaSqlCollectorTest extends TestCase
public function testDropSchema() : void public function testDropSchema() : void
{ {
$platformMock = $this->getMockBuilder(MySqlPlatform::class) $platformMock = $this->getMockBuilder(MySqlPlatform::class)
->setMethods(['getDropTableSql', 'getDropSequenceSql', 'getDropForeignKeySql']) ->onlyMethods(['getDropTableSql', 'getDropSequenceSql', 'getDropForeignKeySql'])
->getMock(); ->getMock();
$platformMock->expects($this->exactly(2)) $platformMock->expects($this->exactly(2))
->method('getDropTableSql') ->method('getDropTableSql')
......
...@@ -16,7 +16,7 @@ class PoolingShardManagerTest extends TestCase ...@@ -16,7 +16,7 @@ class PoolingShardManagerTest extends TestCase
private function createConnectionMock() : PoolingShardConnection private function createConnectionMock() : PoolingShardConnection
{ {
return $this->getMockBuilder(PoolingShardConnection::class) return $this->getMockBuilder(PoolingShardConnection::class)
->setMethods(['connect', 'getParams', 'fetchAll']) ->onlyMethods(['connect', 'getParams', 'fetchAll'])
->disableOriginalConstructor() ->disableOriginalConstructor()
->getMock(); ->getMock();
} }
......
...@@ -85,7 +85,7 @@ class SQLAzureShardManagerTest extends TestCase ...@@ -85,7 +85,7 @@ class SQLAzureShardManagerTest extends TestCase
private function createConnection(array $params) : Connection private function createConnection(array $params) : Connection
{ {
$conn = $this->getMockBuilder(Connection::class) $conn = $this->getMockBuilder(Connection::class)
->setMethods(['getParams', 'exec', 'isTransactionActive']) ->onlyMethods(['getParams', 'exec', 'isTransactionActive'])
->disableOriginalConstructor() ->disableOriginalConstructor()
->getMock(); ->getMock();
$conn->expects($this->at(0))->method('getParams')->will($this->returnValue($params)); $conn->expects($this->at(0))->method('getParams')->will($this->returnValue($params));
......
...@@ -20,7 +20,7 @@ class MultiTenantShardChoserTest extends TestCase ...@@ -20,7 +20,7 @@ class MultiTenantShardChoserTest extends TestCase
private function createConnectionMock() : PoolingShardConnection private function createConnectionMock() : PoolingShardConnection
{ {
return $this->getMockBuilder(PoolingShardConnection::class) return $this->getMockBuilder(PoolingShardConnection::class)
->setMethods(['connect', 'getParams', 'fetchAll']) ->onlyMethods(['connect', 'getParams', 'fetchAll'])
->disableOriginalConstructor() ->disableOriginalConstructor()
->getMock(); ->getMock();
} }
......
...@@ -28,7 +28,7 @@ class StatementTest extends DbalTestCase ...@@ -28,7 +28,7 @@ class StatementTest extends DbalTestCase
protected function setUp() : void protected function setUp() : void
{ {
$this->pdoStatement = $this->getMockBuilder(PDOStatement::class) $this->pdoStatement = $this->getMockBuilder(PDOStatement::class)
->setMethods(['execute', 'bindParam', 'bindValue']) ->onlyMethods(['execute', 'bindParam', 'bindValue'])
->getMock(); ->getMock();
$driverConnection = $this->createMock(DriverConnection::class); $driverConnection = $this->createMock(DriverConnection::class);
......
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