Skip to content

Instantly share code, notes, and snippets.

@glennpratt
Created October 16, 2014 04:15
Show Gist options
  • Save glennpratt/51cece2e677c6685a402 to your computer and use it in GitHub Desktop.
Save glennpratt/51cece2e677c6685a402 to your computer and use it in GitHub Desktop.
<?php
function testThrows() {
$this->assertThrows(function() {
// throw new \Exception('BAH!');
}, 'Exception', "/BAH/");
}
function testThrowsA() {
$this->assertThrows(function() {
throw new \RuntimeException('BAH!');
}, 'InvalidArgumentException');
}
function testThrowsB() {
$this->assertThrows(function() {
throw new \Exception('BAH!');
}, 'Exception', "/DOES NOT MATCH/");
}
function testThrowsC() {
$this->assertThrows(function() {
throw new \Exception('BAH!');
}, 'Exception', "/BAH/");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment