Avoid mocking inexistent classes

It confuses both Psalm and PHPStan, and involves complicated mocking.
parent b00a2e3a
...@@ -144,9 +144,7 @@ class ConnectionTest extends DbalTestCase ...@@ -144,9 +144,7 @@ class ConnectionTest extends DbalTestCase
public function testConnectDispatchEvent() : void public function testConnectDispatchEvent() : void
{ {
$listenerMock = $this->getMockBuilder($this->getMockClass('ConnectDispatchEventListener')) $listenerMock = $this->createMock(ConnectDispatchEventListener::class);
->addMethods(['postConnect'])
->getMock();
$listenerMock->expects($this->once())->method('postConnect'); $listenerMock->expects($this->once())->method('postConnect');
$eventManager = new EventManager(); $eventManager = new EventManager();
...@@ -948,3 +946,8 @@ class ConnectionTest extends DbalTestCase ...@@ -948,3 +946,8 @@ class ConnectionTest extends DbalTestCase
$connection->executeCacheQuery($query, [], [], $queryCacheProfile); $connection->executeCacheQuery($query, [], [], $queryCacheProfile);
} }
} }
interface ConnectDispatchEventListener
{
public function postConnect() : void;
}
...@@ -369,10 +369,7 @@ abstract class SchemaManagerFunctionalTestCase extends DbalFunctionalTestCase ...@@ -369,10 +369,7 @@ abstract class SchemaManagerFunctionalTestCase extends DbalFunctionalTestCase
$this->schemaManager->dropAndCreateTable($table); $this->schemaManager->dropAndCreateTable($table);
$listenerMock = $this->getMockBuilder($this->getMockClass('ListTableColumnsDispatchEventListener')) $listenerMock = $this->createMock(ListTableColumnsDispatchEventListener::class);
->addMethods(['onSchemaColumnDefinition'])
->getMock();
$listenerMock $listenerMock
->expects($this->exactly(7)) ->expects($this->exactly(7))
->method('onSchemaColumnDefinition'); ->method('onSchemaColumnDefinition');
...@@ -397,9 +394,7 @@ abstract class SchemaManagerFunctionalTestCase extends DbalFunctionalTestCase ...@@ -397,9 +394,7 @@ abstract class SchemaManagerFunctionalTestCase extends DbalFunctionalTestCase
$this->schemaManager->dropAndCreateTable($table); $this->schemaManager->dropAndCreateTable($table);
$listenerMock = $this->getMockBuilder($this->getMockClass('ListTableIndexesDispatchEventListener')) $listenerMock = $this->createMock(ListTableIndexesDispatchEventListener::class);
->addMethods(['onSchemaIndexDefinition'])
->getMock();
$listenerMock $listenerMock
->expects($this->exactly(3)) ->expects($this->exactly(3))
->method('onSchemaIndexDefinition'); ->method('onSchemaIndexDefinition');
...@@ -1653,3 +1648,13 @@ abstract class SchemaManagerFunctionalTestCase extends DbalFunctionalTestCase ...@@ -1653,3 +1648,13 @@ abstract class SchemaManagerFunctionalTestCase extends DbalFunctionalTestCase
} }
} }
} }
interface ListTableColumnsDispatchEventListener
{
public function onSchemaColumnDefinition() : void;
}
interface ListTableIndexesDispatchEventListener
{
public function onSchemaIndexDefinition() : void;
}
...@@ -372,9 +372,7 @@ abstract class AbstractPlatformTestCase extends DbalTestCase ...@@ -372,9 +372,7 @@ abstract class AbstractPlatformTestCase extends DbalTestCase
public function testGetCreateTableSqlDispatchEvent() : void public function testGetCreateTableSqlDispatchEvent() : void
{ {
$listenerMock = $this->getMockBuilder($this->getMockClass('GetCreateTableSqlDispatchEvenListener')) $listenerMock = $this->createMock(GetCreateTableSqlDispatchEventListener::class);
->addMethods(['onSchemaCreateTable', 'onSchemaCreateTableColumn'])
->getMock();
$listenerMock $listenerMock
->expects($this->once()) ->expects($this->once())
->method('onSchemaCreateTable'); ->method('onSchemaCreateTable');
...@@ -396,9 +394,7 @@ abstract class AbstractPlatformTestCase extends DbalTestCase ...@@ -396,9 +394,7 @@ abstract class AbstractPlatformTestCase extends DbalTestCase
public function testGetDropTableSqlDispatchEvent() : void public function testGetDropTableSqlDispatchEvent() : void
{ {
$listenerMock = $this->getMockBuilder($this->getMockClass('GetDropTableSqlDispatchEventListener')) $listenerMock = $this->createMock(GetDropTableSqlDispatchEventListener::class);
->addMethods(['onSchemaDropTable'])
->getMock();
$listenerMock $listenerMock
->expects($this->once()) ->expects($this->once())
->method('onSchemaDropTable'); ->method('onSchemaDropTable');
...@@ -413,17 +409,7 @@ abstract class AbstractPlatformTestCase extends DbalTestCase ...@@ -413,17 +409,7 @@ abstract class AbstractPlatformTestCase extends DbalTestCase
public function testGetAlterTableSqlDispatchEvent() : void public function testGetAlterTableSqlDispatchEvent() : void
{ {
$events = [ $listenerMock = $this->createMock(GetAlterTableSqlDispatchEventListener::class);
'onSchemaAlterTable',
'onSchemaAlterTableAddColumn',
'onSchemaAlterTableRemoveColumn',
'onSchemaAlterTableChangeColumn',
'onSchemaAlterTableRenameColumn',
];
$listenerMock = $this->getMockBuilder($this->getMockClass('GetAlterTableSqlDispatchEvenListener'))
->addMethods($events)
->getMock();
$listenerMock $listenerMock
->expects($this->once()) ->expects($this->once())
->method('onSchemaAlterTable'); ->method('onSchemaAlterTable');
...@@ -1532,3 +1518,28 @@ abstract class AbstractPlatformTestCase extends DbalTestCase ...@@ -1532,3 +1518,28 @@ abstract class AbstractPlatformTestCase extends DbalTestCase
); );
} }
} }
interface GetCreateTableSqlDispatchEventListener
{
public function onSchemaCreateTable() : void;
public function onSchemaCreateTableColumn() : void;
}
interface GetAlterTableSqlDispatchEventListener
{
public function onSchemaAlterTable() : void;
public function onSchemaAlterTableAddColumn() : void;
public function onSchemaAlterTableRemoveColumn() : void;
public function onSchemaAlterTableChangeColumn() : void;
public function onSchemaAlterTableRenameColumn() : void;
}
interface GetDropTableSqlDispatchEventListener
{
public function onSchemaDropTable() : 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