Files
Jan-Niclas LoosenandClaude Opus 5.5 b511ef6348 refactor(compat): Prüfbausteine nach src/Compatibility, Matrix und ManifestCheck generisch
Requirement, Call, ConstantRequirement, Mirror, Problem, FeatureStatus, CompatibilityMatrix, Manifest, ManifestCheck sowie Fingerprints und LineDiff liegen jetzt im divi-freien Kern. Neu: GlobalRequirement, CompatibilityMatrix::fromProblems(), ManifestCheck-Option signatures, DiviManifestCheck::create() und DiviAreas. Divi-Verhalten unverändert.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-06 12:03:30 +01:00

57 lines
2.0 KiB
PHP

<?php
declare(strict_types=1);
namespace LIT\MCP\Tests\Unit;
use Brain\Monkey;
use Brain\Monkey\Functions;
use LIT\MCP\Compatibility\CompatibilityMatrix;
use LIT\MCP\Integrations\Divi\Release\DiviFeature;
use LIT\MCP\Integrations\Divi\Release\ReleaseGate;
use LIT\MCP\Integrations\Divi\Release\ReleaseStatus;
use LIT\MCP\Tests\Support\AssertsToolErrors;
use LIT\MCP\Tests\Support\FakeChangeLog;
use Mockery\Adapter\Phpunit\MockeryPHPUnitIntegration;
use PHPUnit\Framework\TestCase as BaseTestCase;
abstract class TestCase extends BaseTestCase
{
use AssertsToolErrors;
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,
'wp_cache_delete' => true,
'wp_cache_supports' => true,
'wp_cache_flush_group' => true,
'sanitize_text_field' => static fn ($value): string => trim(strip_tags((string) $value)),
]);
// Every Divi feature is released unless a test says otherwise (the gate would ask WordPress and Divi).
ReleaseGate::useResolver(
static fn (): ReleaseStatus => ReleaseStatus::of('5.2.1', CompatibilityMatrix::allReleased(DiviFeature::cases()))
);
}
protected function tearDown(): void
{
ReleaseGate::useResolver(null);
Monkey\tearDown();
parent::tearDown();
FakeChangeLog::verify();
}
}