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

Feature request: Allow asserting that trigger_error() is called #25

Open
mallorydxw opened this issue Aug 8, 2016 · 1 comment
Open
Labels

Comments

@mallorydxw
Copy link
Contributor

PHPUnit has $this->setExpectedException('PHPUnit_Framework_Error_Warning');. Leo should provide some way of doing this too. Something like this:

expect(function () {
    trigger_error('Oh no!', E_USER_WARNING);
})->to->triggererror(E_USER_WARNING, 'Oh no!');
@ezzatron
Copy link
Contributor

ezzatron commented Aug 8, 2016

Sounds like a good idea to me! For now, I'll shamelessly plug a couple of my own libraries that might help you out:

  • errors/exceptions will automatically install an error handler that turns errors into error exceptions.
  • Asplode is very similar, but requires you to call Asplode::install() in your peridot.php.

Neither of these handlers throw different error exception types for different error severities. If you need that level of granularity, you'll have to use a try/catch block for now.

Also please be aware of #20. It will probably affect you also, if you choose one of the above approaches.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants