@expect withMessage
thekid opened this issue · 0 comments
thekid commented
Scope of Change
The @expect
annotation will be enhanced to provide a means for
also checking the expected exception's message.
Rationale
Ensuring a certain exception message requires the "old-style" approach
with try
, fail();
and the checking the message inside
catch (ExpectedException $expected)
, a construct we successfully
removed the need for with @expect
years ago.
Functionality
The @expect
annotation is currently written as:
@expect([CLASSNAME])
Keeping the old syntax intact, the new form is defined as:
@expect(class= [CLASSNAME], withMessage= [MESSAGE])
This test succeeds:
<?php
#[@test, @expect(class= 'lang.IllegalArgumentException', withMessage= 'Hello')]
public function wrongMessage() {
throw new IllegalArgumentException('Hello');
}
?>
This test fails:
<?php
#[@test, @expect(class= 'lang.IllegalArgumentException', withMessage= 'Hello')]
public function wrongMessage() {
throw new IllegalArgumentException('Another message');
}
?>
Security considerations
n/a
Speed impact
Negligible
Dependencies
n/a
Related documents
- http://code.google.com/p/instinct/wiki/Specifications
- xp-framework/rfc #32 - the original @expect RFC
- http://xp-framework.net/rfc/contrib/rfc0187.diff