<?php
use PHPUnit\Framework\TestCase;
class ExceptionMockTest extends TestCase
{
public function testMockException() : void
{
$mock = $this->createMock('Fooable');
$mock->expects($this->once())
->method('connect')
->willThrowException(new Exception('Expected Exception was thrown'));
$mock->connect();
}
}
interface Fooable
{
public function connect();
}