Skip to content

Instantly share code, notes, and snippets.

@dharkness
Created October 27, 2012 19:55
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dharkness/3965902 to your computer and use it in GitHub Desktop.
Save dharkness/3965902 to your computer and use it in GitHub Desktop.
Using Hamcrest matchers with PHPUnit
<?php
class Hamcrest_Integration_PHPUnit_TestCase extends PHPUnit_Framework_TestCase
{
/**
* Collects assertions performed by Hamcrest matchers during the test.
*/
public function runBare() {
Hamcrest_MatcherAssert::resetCount();
try {
parent::runBare();
}
catch (Exception $e) {
// rethrown below
}
$this->addToAssertionCount(Hamcrest_MatcherAssert::getCount());
if ($e) {
throw $e;
}
}
@rklak
Copy link

rklak commented Oct 18, 2013

if (isset($e)) {
    throw $e;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment