<?php
use PHPUnit\Framework\TestCase;
/**
* The exception test case with
* second parameter 0 isn't even enough.
*/
class DivideTest extends TestCase
{
public function testCalcException() : void
{
$this->expectException('\InvalidArgumentException');
$divide = new Divide();
$divide->calc(1, 0);
}
}
class Divide
{
public function calc($dividend, $divisor)
{
if (0 == $divisor) {
throw new InvalidArgumentException('you really want to divide
with 0? Are you serious?');
}
return $dividend / $divisor;
}
}