コード例 #1
0
 public function testCodeAndMessage()
 {
     $test = function () {
         throw new Exception('My message.', 110);
     };
     AssertException::assertException($test, null, 110, 'My message.');
 }
コード例 #2
0
 public function testInterface()
 {
     $test = function () {
         throw new MyExceptionImplementsInterface();
     };
     AssertException::assertException($test, MyExceptionInterface::class);
 }
コード例 #3
0
 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);
 }