Skip to content

Instantly share code, notes, and snippets.

@fomigo
Created March 8, 2023 05:44
Show Gist options
  • Save fomigo/ca2285050383017bcfa091b7dbde150a to your computer and use it in GitHub Desktop.
Save fomigo/ca2285050383017bcfa091b7dbde150a to your computer and use it in GitHub Desktop.
Hamcrest Test Case for PHPUnit
<?php // test/HamcrestTestCase.php
namespace App\Test;
use PHPUnit\Framework\TestCase;
use Hamcrest\MatcherAssert;
use Hamcrest\Util;
class HamcrestTestCase extends TestCase {
public function runBare(): void {
Util::registerGlobalFunctions();
MatcherAssert::resetCount();
try {
parent::runBare();
} finally {
$this->addToAssertionCount(MatcherAssert::getCount());
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment