<?php // tests/HamcrestTestCase.php
namespace Tests;
use Hamcrest\MatcherAssert;
use Hamcrest\Util;
class HamcrestTestCase extends \PHPUnit\Framework\TestCase
{
public function runBare(): void
{
Util::registerGlobalFunctions();
MatcherAssert::resetCount();
try {
parent::runBare();
} finally {
$this->addToAssertionCount(MatcherAssert::getCount());
}
}
}
<?php // TrueTest.php
class TrueTest extends Tests\HamcrestTestCase
{
public function testTrueIsTrue()
{
assertThat(true, is(true));
}
}