CodeExplorer DoctrinePingConnectionMiddleware example
protected function setUp(): void
{ $this->connection =
$this->
createMock(Connection::
class);
$this->entityManager =
$this->
createMock(EntityManagerInterface::
class);
$this->entityManager->
method('getConnection'
)->
willReturn($this->connection
);
$this->managerRegistry =
$this->
createMock(ManagerRegistry::
class);
$this->managerRegistry->
method('getManager'
)->
willReturn($this->entityManager
);
$this->middleware =
new DoctrinePingConnectionMiddleware( $this->managerRegistry,
$this->entityManagerName
);
} public function testMiddlewarePingOk() { $this->connection->
expects($this->
once()) ->
method('getDatabasePlatform'
) ->
will($this->
throwException(new DBALException()));