diff --git a/tests/Doctrine/Tests/DBAL/ConnectionTest.php b/tests/Doctrine/Tests/DBAL/ConnectionTest.php index 09ee88349ec..fb0157314d6 100644 --- a/tests/Doctrine/Tests/DBAL/ConnectionTest.php +++ b/tests/Doctrine/Tests/DBAL/ConnectionTest.php @@ -67,7 +67,7 @@ private function getExecuteUpdateMockConnection() $platform = $this->getMockForAbstractClass(AbstractPlatform::class); return $this->getMockBuilder(Connection::class) - ->setMethods(['executeUpdate']) + ->onlyMethods(['executeUpdate']) ->setConstructorArgs([['platform' => $platform], $driverMock]) ->getMock(); } @@ -145,8 +145,8 @@ public function testGetEventManager() : void public function testConnectDispatchEvent() : void { - $listenerMock = $this->getMockBuilder('ConnectDispatchEventListener') - ->setMethods(['postConnect']) + $listenerMock = $this->getMockBuilder($this->getMockClass('ConnectDispatchEventListener')) + ->addMethods(['postConnect']) ->getMock(); $listenerMock->expects($this->once())->method('postConnect'); @@ -566,7 +566,7 @@ public function testFetchAssoc() : void /** @var Connection|MockObject $conn */ $conn = $this->getMockBuilder(Connection::class) - ->setMethods(['executeQuery']) + ->onlyMethods(['executeQuery']) ->setConstructorArgs([[], $driverMock]) ->getMock(); @@ -602,7 +602,7 @@ public function testFetchArray() : void /** @var Connection|MockObject $conn */ $conn = $this->getMockBuilder(Connection::class) - ->setMethods(['executeQuery']) + ->onlyMethods(['executeQuery']) ->setConstructorArgs([[], $driverMock]) ->getMock(); @@ -639,7 +639,7 @@ public function testFetchColumn() : void /** @var Connection|MockObject $conn */ $conn = $this->getMockBuilder(Connection::class) - ->setMethods(['executeQuery']) + ->onlyMethods(['executeQuery']) ->setConstructorArgs([[], $driverMock]) ->getMock(); @@ -674,7 +674,7 @@ public function testFetchAll() : void /** @var Connection|MockObject $conn */ $conn = $this->getMockBuilder(Connection::class) - ->setMethods(['executeQuery']) + ->onlyMethods(['executeQuery']) ->setConstructorArgs([[], $driverMock]) ->getMock(); @@ -756,7 +756,7 @@ public function testCallConnectOnce(string $method, array $params) : void $conn = $this->getMockBuilder(Connection::class) ->setConstructorArgs([['pdo' => $pdoMock, 'platform' => $platformMock], $driverMock]) - ->setMethods(['connect']) + ->onlyMethods(['connect']) ->getMock(); $conn->expects($this->once())->method('connect'); diff --git a/tests/Doctrine/Tests/DBAL/Driver/OCI8/OCI8StatementTest.php b/tests/Doctrine/Tests/DBAL/Driver/OCI8/OCI8StatementTest.php index 45d0c45264c..f90f86d6eb3 100644 --- a/tests/Doctrine/Tests/DBAL/Driver/OCI8/OCI8StatementTest.php +++ b/tests/Doctrine/Tests/DBAL/Driver/OCI8/OCI8StatementTest.php @@ -36,7 +36,7 @@ protected function setUp() : void public function testExecute(array $params) : void { $statement = $this->getMockBuilder(OCI8Statement::class) - ->setMethods(['bindValue', 'errorInfo']) + ->onlyMethods(['bindValue', 'errorInfo']) ->disableOriginalConstructor() ->getMock(); @@ -67,7 +67,7 @@ public function testExecute(array $params) : void // 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) - ->setMethods(['getExecuteMode']) + ->onlyMethods(['getExecuteMode']) ->disableOriginalConstructor() ->getMock(); $conn->expects($this->once()) diff --git a/tests/Doctrine/Tests/DBAL/Functional/Schema/SchemaManagerFunctionalTestCase.php b/tests/Doctrine/Tests/DBAL/Functional/Schema/SchemaManagerFunctionalTestCase.php index e8580cba2b4..7b76f802612 100644 --- a/tests/Doctrine/Tests/DBAL/Functional/Schema/SchemaManagerFunctionalTestCase.php +++ b/tests/Doctrine/Tests/DBAL/Functional/Schema/SchemaManagerFunctionalTestCase.php @@ -367,10 +367,10 @@ public function testListTableColumnsDispatchEvent() : void $this->schemaManager->dropAndCreateTable($table); - $listenerMock = $this - ->getMockBuilder('ListTableColumnsDispatchEventListener') - ->setMethods(['onSchemaColumnDefinition']) + $listenerMock = $this->getMockBuilder($this->getMockClass('ListTableColumnsDispatchEventListener')) + ->addMethods(['onSchemaColumnDefinition']) ->getMock(); + $listenerMock ->expects($this->exactly(7)) ->method('onSchemaColumnDefinition'); @@ -395,9 +395,8 @@ public function testListTableIndexesDispatchEvent() : void $this->schemaManager->dropAndCreateTable($table); - $listenerMock = $this - ->getMockBuilder('ListTableIndexesDispatchEventListener') - ->setMethods(['onSchemaIndexDefinition']) + $listenerMock = $this->getMockBuilder($this->getMockClass('ListTableIndexesDispatchEventListener')) + ->addMethods(['onSchemaIndexDefinition']) ->getMock(); $listenerMock ->expects($this->exactly(3)) diff --git a/tests/Doctrine/Tests/DBAL/Platforms/AbstractPlatformTestCase.php b/tests/Doctrine/Tests/DBAL/Platforms/AbstractPlatformTestCase.php index 0c44d42a7b4..1ef4e65e322 100644 --- a/tests/Doctrine/Tests/DBAL/Platforms/AbstractPlatformTestCase.php +++ b/tests/Doctrine/Tests/DBAL/Platforms/AbstractPlatformTestCase.php @@ -380,8 +380,8 @@ public function testGetCustomColumnDeclarationSql() : void public function testGetCreateTableSqlDispatchEvent() : void { - $listenerMock = $this->getMockBuilder('GetCreateTableSqlDispatchEvenListener') - ->setMethods(['onSchemaCreateTable', 'onSchemaCreateTableColumn']) + $listenerMock = $this->getMockBuilder($this->getMockClass('GetCreateTableSqlDispatchEvenListener')) + ->addMethods(['onSchemaCreateTable', 'onSchemaCreateTableColumn']) ->getMock(); $listenerMock ->expects($this->once()) @@ -404,8 +404,8 @@ public function testGetCreateTableSqlDispatchEvent() : void public function testGetDropTableSqlDispatchEvent() : void { - $listenerMock = $this->getMockBuilder('GetDropTableSqlDispatchEventListener') - ->setMethods(['onSchemaDropTable']) + $listenerMock = $this->getMockBuilder($this->getMockClass('GetDropTableSqlDispatchEventListener')) + ->addMethods(['onSchemaDropTable']) ->getMock(); $listenerMock ->expects($this->once()) @@ -429,8 +429,8 @@ public function testGetAlterTableSqlDispatchEvent() : void 'onSchemaAlterTableRenameColumn', ]; - $listenerMock = $this->getMockBuilder('GetAlterTableSqlDispatchEvenListener') - ->setMethods($events) + $listenerMock = $this->getMockBuilder($this->getMockClass('GetAlterTableSqlDispatchEvenListener')) + ->addMethods($events) ->getMock(); $listenerMock ->expects($this->once()) diff --git a/tests/Doctrine/Tests/DBAL/Schema/ComparatorTest.php b/tests/Doctrine/Tests/DBAL/Schema/ComparatorTest.php index fecff1cbcfa..f73d1c6d1f4 100644 --- a/tests/Doctrine/Tests/DBAL/Schema/ComparatorTest.php +++ b/tests/Doctrine/Tests/DBAL/Schema/ComparatorTest.php @@ -1172,10 +1172,10 @@ public function testComparesNamespaces() : void { $comparator = new Comparator(); $fromSchema = $this->getMockBuilder(Schema::class) - ->setMethods(['getNamespaces', 'hasNamespace']) + ->onlyMethods(['getNamespaces', 'hasNamespace']) ->getMock(); $toSchema = $this->getMockBuilder(Schema::class) - ->setMethods(['getNamespaces', 'hasNamespace']) + ->onlyMethods(['getNamespaces', 'hasNamespace']) ->getMock(); $fromSchema->expects($this->once()) diff --git a/tests/Doctrine/Tests/DBAL/Schema/DB2SchemaManagerTest.php b/tests/Doctrine/Tests/DBAL/Schema/DB2SchemaManagerTest.php index b5744fd672d..53f9a41cbda 100644 --- a/tests/Doctrine/Tests/DBAL/Schema/DB2SchemaManagerTest.php +++ b/tests/Doctrine/Tests/DBAL/Schema/DB2SchemaManagerTest.php @@ -30,7 +30,7 @@ protected function setUp() : void $platform = $this->createMock(DB2Platform::class); $this->conn = $this ->getMockBuilder(Connection::class) - ->setMethods(['fetchAll', 'quote']) + ->onlyMethods(['fetchAll', 'quote']) ->setConstructorArgs([['platform' => $platform], $driverMock, new Configuration(), $eventManager]) ->getMock(); $this->manager = new DB2SchemaManager($this->conn); diff --git a/tests/Doctrine/Tests/DBAL/Schema/MySqlSchemaManagerTest.php b/tests/Doctrine/Tests/DBAL/Schema/MySqlSchemaManagerTest.php index 5c8881decb4..934b3e97bef 100644 --- a/tests/Doctrine/Tests/DBAL/Schema/MySqlSchemaManagerTest.php +++ b/tests/Doctrine/Tests/DBAL/Schema/MySqlSchemaManagerTest.php @@ -27,7 +27,7 @@ protected function setUp() : void $driverMock = $this->createMock(Driver::class); $platform = $this->createMock(MySqlPlatform::class); $this->conn = $this->getMockBuilder(Connection::class) - ->setMethods(['fetchAll']) + ->onlyMethods(['fetchAll']) ->setConstructorArgs([['platform' => $platform], $driverMock, new Configuration(), $eventManager]) ->getMock(); $this->manager = new MySqlSchemaManager($this->conn); diff --git a/tests/Doctrine/Tests/DBAL/Schema/Visitor/CreateSchemaSqlCollectorTest.php b/tests/Doctrine/Tests/DBAL/Schema/Visitor/CreateSchemaSqlCollectorTest.php index b70d2193a37..88df92341ce 100644 --- a/tests/Doctrine/Tests/DBAL/Schema/Visitor/CreateSchemaSqlCollectorTest.php +++ b/tests/Doctrine/Tests/DBAL/Schema/Visitor/CreateSchemaSqlCollectorTest.php @@ -26,7 +26,7 @@ protected function setUp() : void parent::setUp(); $this->platformMock = $this->getMockBuilder(AbstractPlatform::class) - ->setMethods( + ->onlyMethods( [ 'getCreateForeignKeySQL', 'getCreateSchemaSQL', diff --git a/tests/Doctrine/Tests/DBAL/Schema/Visitor/DropSchemaSqlCollectorTest.php b/tests/Doctrine/Tests/DBAL/Schema/Visitor/DropSchemaSqlCollectorTest.php index ea265396333..12e3678cbf6 100644 --- a/tests/Doctrine/Tests/DBAL/Schema/Visitor/DropSchemaSqlCollectorTest.php +++ b/tests/Doctrine/Tests/DBAL/Schema/Visitor/DropSchemaSqlCollectorTest.php @@ -23,7 +23,7 @@ public function testGetQueriesUsesAcceptedForeignKeys() : void $keyConstraintTwo = $this->getStubKeyConstraint('second'); $platform = $this->getMockBuilder(AbstractPlatform::class) - ->setMethods(['getDropForeignKeySQL']) + ->onlyMethods(['getDropForeignKeySQL']) ->getMockForAbstractClass(); $collector = new DropSchemaSqlCollector($platform); diff --git a/tests/Doctrine/Tests/DBAL/Schema/Visitor/SchemaSqlCollectorTest.php b/tests/Doctrine/Tests/DBAL/Schema/Visitor/SchemaSqlCollectorTest.php index 34e2896de29..60c7f2a1f5b 100644 --- a/tests/Doctrine/Tests/DBAL/Schema/Visitor/SchemaSqlCollectorTest.php +++ b/tests/Doctrine/Tests/DBAL/Schema/Visitor/SchemaSqlCollectorTest.php @@ -11,7 +11,7 @@ class SchemaSqlCollectorTest extends TestCase public function testCreateSchema() : void { $platformMock = $this->getMockBuilder(MySqlPlatform::class) - ->setMethods(['getCreateTableSql', 'getCreateSequenceSql', 'getCreateForeignKeySql']) + ->onlyMethods(['getCreateTableSql', 'getCreateSequenceSql', 'getCreateForeignKeySql']) ->getMock(); $platformMock->expects($this->exactly(2)) ->method('getCreateTableSql') @@ -33,7 +33,7 @@ public function testCreateSchema() : void public function testDropSchema() : void { $platformMock = $this->getMockBuilder(MySqlPlatform::class) - ->setMethods(['getDropTableSql', 'getDropSequenceSql', 'getDropForeignKeySql']) + ->onlyMethods(['getDropTableSql', 'getDropSequenceSql', 'getDropForeignKeySql']) ->getMock(); $platformMock->expects($this->exactly(2)) ->method('getDropTableSql') diff --git a/tests/Doctrine/Tests/DBAL/Sharding/PoolingShardManagerTest.php b/tests/Doctrine/Tests/DBAL/Sharding/PoolingShardManagerTest.php index 31a308e0393..eafbd69cfcb 100644 --- a/tests/Doctrine/Tests/DBAL/Sharding/PoolingShardManagerTest.php +++ b/tests/Doctrine/Tests/DBAL/Sharding/PoolingShardManagerTest.php @@ -16,7 +16,7 @@ class PoolingShardManagerTest extends TestCase private function createConnectionMock() : PoolingShardConnection { return $this->getMockBuilder(PoolingShardConnection::class) - ->setMethods(['connect', 'getParams', 'fetchAll']) + ->onlyMethods(['connect', 'getParams', 'fetchAll']) ->disableOriginalConstructor() ->getMock(); } diff --git a/tests/Doctrine/Tests/DBAL/Sharding/SQLAzure/SQLAzureShardManagerTest.php b/tests/Doctrine/Tests/DBAL/Sharding/SQLAzure/SQLAzureShardManagerTest.php index 6dcbad5f356..78d6afe593c 100644 --- a/tests/Doctrine/Tests/DBAL/Sharding/SQLAzure/SQLAzureShardManagerTest.php +++ b/tests/Doctrine/Tests/DBAL/Sharding/SQLAzure/SQLAzureShardManagerTest.php @@ -85,7 +85,7 @@ public function testSelectShard() : void private function createConnection(array $params) : Connection { $conn = $this->getMockBuilder(Connection::class) - ->setMethods(['getParams', 'exec', 'isTransactionActive']) + ->onlyMethods(['getParams', 'exec', 'isTransactionActive']) ->disableOriginalConstructor() ->getMock(); $conn->expects($this->at(0))->method('getParams')->will($this->returnValue($params)); diff --git a/tests/Doctrine/Tests/DBAL/Sharding/ShardChoser/MultiTenantShardChoserTest.php b/tests/Doctrine/Tests/DBAL/Sharding/ShardChoser/MultiTenantShardChoserTest.php index aa15f91d3cc..5b65deecc77 100644 --- a/tests/Doctrine/Tests/DBAL/Sharding/ShardChoser/MultiTenantShardChoserTest.php +++ b/tests/Doctrine/Tests/DBAL/Sharding/ShardChoser/MultiTenantShardChoserTest.php @@ -20,7 +20,7 @@ public function testPickShard() : void private function createConnectionMock() : PoolingShardConnection { return $this->getMockBuilder(PoolingShardConnection::class) - ->setMethods(['connect', 'getParams', 'fetchAll']) + ->onlyMethods(['connect', 'getParams', 'fetchAll']) ->disableOriginalConstructor() ->getMock(); } diff --git a/tests/Doctrine/Tests/DBAL/StatementTest.php b/tests/Doctrine/Tests/DBAL/StatementTest.php index 1d76e3aabe3..bb86e9cab3c 100644 --- a/tests/Doctrine/Tests/DBAL/StatementTest.php +++ b/tests/Doctrine/Tests/DBAL/StatementTest.php @@ -28,7 +28,7 @@ class StatementTest extends DbalTestCase protected function setUp() : void { $this->pdoStatement = $this->getMockBuilder(PDOStatement::class) - ->setMethods(['execute', 'bindParam', 'bindValue']) + ->onlyMethods(['execute', 'bindParam', 'bindValue']) ->getMock(); $driverConnection = $this->createMock(DriverConnection::class);