mirror of
https://we.phorge.it/source/arcanist.git
synced 2024-11-22 06:42:41 +01:00
[ArcanistPhutilTestCase] add ->assertException() to the base test case
Summary: Simpler assert function for asserting a type of exception was raised. Test Plan: Wrote this for (and tested it with) D1836. Reviewers: epriestley Reviewed By: epriestley CC: aran, epriestley Differential Revision: https://secure.phabricator.com/D1837
This commit is contained in:
parent
8088b4cdac
commit
bdfc021d39
1 changed files with 19 additions and 0 deletions
|
@ -113,6 +113,25 @@ abstract class ArcanistPhutilTestCase {
|
|||
/* -( Exception Handling )------------------------------------------------- */
|
||||
|
||||
|
||||
/**
|
||||
* This simplest way to assert exceptions are thrown.
|
||||
*
|
||||
* @param exception The expected exception.
|
||||
* @param callable The thing which throws the exception.
|
||||
*
|
||||
* @return void
|
||||
* @task exceptions
|
||||
*/
|
||||
final protected function assertException($expected_exception_class,
|
||||
$callable) {
|
||||
$this->tryTestCases(
|
||||
array('assertException' => array()),
|
||||
array(false),
|
||||
$callable,
|
||||
$expected_exception_class
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Straightforward method for writing unit tests which check if some block of
|
||||
* code throws an exception. For example, this allows you to test the
|
||||
|
|
Loading…
Reference in a new issue