Avoid mocking inexistent classes

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