phpunit expect exception

Solutions on MaxInterview for phpunit expect exception by the best coders in the world

showing results for - "phpunit expect exception"
Tyron
11 Aug 2016
1<?php
2require_once 'PHPUnit/Framework.php';
3
4class ExceptionTest extends PHPUnit_Framework_TestCase
5{
6    public function testException()
7    {
8        $this->expectException(InvalidArgumentException::class);
9        // or for PHPUnit < 5.2
10        // $this->setExpectedException(InvalidArgumentException::class);
11
12        //...and then add your test code that generates the exception 
13        exampleMethod($anInvalidArgument);
14    }
15}