public function testCodeAndMessage() { $test = function () { throw new Exception('My message.', 110); }; AssertException::assertException($test, null, 110, 'My message.'); }
public function testInterface() { $test = function () { throw new MyExceptionImplementsInterface(); }; AssertException::assertException($test, MyExceptionInterface::class); }
public function testBadMessageOfClass() { $this->setExpectedException(PHPUnit_Framework_Exception::class, sprintf('Failed asserting the message of thrown %s.', MyException::class)); $test = function () { throw new MyException('Wrong message.'); }; AssertException::assertException($test, null, null, 'Right message.'); }
public function testNotInstanceOfWithCodeAndMessage() { $this->setExpectedException(PHPUnit_Framework_Exception::class, 'Failed asserting the class of an exception (code was 110, message was "My message.").'); $test = function () { throw new MyException('My message.', 110); }; AssertException::assertException($test, MyExceptionSubclass::class); }