Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

@expect withMessage #187

Closed
thekid opened this issue Oct 17, 2011 · 0 comments
Closed

@expect withMessage #187

thekid opened this issue Oct 17, 2011 · 0 comments

Comments

@thekid
Copy link
Member

thekid commented Oct 17, 2011

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

@thekid thekid closed this as completed Oct 17, 2011
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant