- tests/Support/FakeChangeLog extends ChangeLog: records record()/recordPartial() calls, increasing ids, optional failure; new FakeChangeLog(id) / partialsOnly() / any(id) / forbidden() mirror what the replaced mocks allowed. assertRecorded() / assertPartials() check count and the named arguments. Calls a fake does not allow throw and are also verified in TestCase::tearDown (one assertion per test that uses a fake), so swallowed change-log calls still fail like a never() expectation. - All ChangeLog mocks of ability/integration tests replaced (the admin tests that stub query/purge/clear keep their mocks); expectException tests that checked the partial log now catch and assert. - SchemaFixture::managed(?divi) replaces the 21 isManaged-only ContentSchema mocks; DiviFixtures::schema() uses it. Tests 1397 -> 1404 (FakeChangeLogTest); no test has fewer assertions. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
42 lines
1.3 KiB
PHP
42 lines
1.3 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace LIT\MCP\Tests\Unit;
|
|
|
|
use Brain\Monkey;
|
|
use Brain\Monkey\Functions;
|
|
use LIT\MCP\Tests\Support\FakeChangeLog;
|
|
use Mockery\Adapter\Phpunit\MockeryPHPUnitIntegration;
|
|
use PHPUnit\Framework\TestCase as BaseTestCase;
|
|
|
|
abstract class TestCase extends BaseTestCase
|
|
{
|
|
use MockeryPHPUnitIntegration;
|
|
|
|
protected function setUp(): void
|
|
{
|
|
parent::setUp();
|
|
Monkey\setUp();
|
|
|
|
// Pure helpers with obvious behaviour. Never use Functions\expect() on these
|
|
// names in a test: Brain Monkey forbids a stub and an expectation for the
|
|
// same function. Functions\when() may still redefine them.
|
|
Functions\stubs([
|
|
'wp_json_encode' => static fn ($data, int $flags = 0) => json_encode($data, $flags),
|
|
'is_wp_error' => static fn ($thing): bool => $thing instanceof \WP_Error,
|
|
'absint' => static fn ($value): int => abs((int) $value),
|
|
'wp_slash' => static fn ($value) => $value,
|
|
'wp_unslash' => static fn ($value) => $value,
|
|
'sanitize_text_field' => static fn ($value): string => trim(strip_tags((string) $value)),
|
|
]);
|
|
}
|
|
|
|
protected function tearDown(): void
|
|
{
|
|
Monkey\tearDown();
|
|
parent::tearDown();
|
|
FakeChangeLog::verify();
|
|
}
|
|
}
|