Last active
December 16, 2015 22:19
-
-
Save polyfractal/5506185 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public function assertThrowsException($exception, $code) | |
{ | |
$raisedException = null; | |
try { | |
$code(); | |
} catch (\Exception $raisedException) { | |
// No more code, we only want to catch the exception in $raisedException. | |
} | |
$this->assertInstanceOf($exception, $raisedException); | |
} | |
public function testGizmo() | |
{ | |
$widget = 'something'; | |
// Some more code | |
$this->assertThrowsException('\Package\Specific\Exception', function () use ($widget) { | |
$blah = new \Package\Gizmo($widget); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment