Making Expectations
Complex test suites need to make expectations about how a test might run that can't be accomplished with the assertion API. Learn how to use expectations as another form of validating tests.
Expecting An Exception
Expecting only on Exception type
<?php
use Cspray\Labrador\AsyncUnit\TestCase;
use Cspray\Labrador\AsyncUnit\Attribute\Test;
use Cspray\Labrador\AsyncUnit\Exception\Exception;
use Cspray\Labrador\AsyncUnit\Exception\InvalidArgumentException;
class MyExceptionTestCase extends TestCase {
#[Test]
public function checkExceptionThrown() {
$this->expect()->exception(Exception::class);
throw new InvalidArgumentException();
}
}Expecting on Exception type and message
Expecting an Exception not thrown
Expecting No Assertions
Last updated
Was this helpful?