test: FakeChangeLog and SchemaFixture instead of repeated mocks (T2)

- 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>
This commit is contained in:
2026-09-26 17:53:54 +02:00
co-authored by Claude Opus 5.5
parent 3d96a41366
commit 72eeaa46ad
34 changed files with 725 additions and 353 deletions
@@ -6,10 +6,11 @@ namespace LIT\MCP\Tests\Unit\Integrations\WordPress;
use LIT\MCP\Abilities\Ability;
use Brain\Monkey\Functions;
use LIT\MCP\ChangeLog\ChangeLog;
use LIT\MCP\Integrations\WordPress\Content\ContentComposer;
use LIT\MCP\Integrations\WordPress\Schema\ContentSchema;
use LIT\MCP\Integrations\WordPress\WordPressIntegration;
use LIT\MCP\Tests\Support\FakeChangeLog;
use LIT\MCP\Tests\Support\SchemaFixture;
use LIT\MCP\Tests\Unit\TestCase;
use Mockery;
@@ -42,7 +43,7 @@ final class WordPressIntegrationTest extends TestCase
public function testProvidesTheWordPressAbilitiesInOrder(): void
{
$integration = new WordPressIntegration(Mockery::mock(ContentSchema::class), Mockery::mock(ChangeLog::class));
$integration = new WordPressIntegration(Mockery::mock(ContentSchema::class), FakeChangeLog::forbidden());
self::assertSame('wordpress', $integration->id());
self::assertTrue($integration->isAvailable());
@@ -54,7 +55,7 @@ final class WordPressIntegrationTest extends TestCase
public function testEveryAbilityHasAnObjectInputSchemaThatRejectsUnknownKeys(): void
{
$integration = new WordPressIntegration(Mockery::mock(ContentSchema::class), Mockery::mock(ChangeLog::class));
$integration = new WordPressIntegration(Mockery::mock(ContentSchema::class), FakeChangeLog::forbidden());
foreach ($integration->abilities() as $ability) {
$schema = $ability->inputSchema();
@@ -68,11 +69,10 @@ final class WordPressIntegrationTest extends TestCase
{
Functions\when('get_post_type_object')->justReturn((object) ['cap' => (object) ['create_posts' => 'edit_pages']]);
Functions\when('current_user_can')->justReturn(true);
$schema = Mockery::mock(ContentSchema::class);
$schema->allows('isManaged')->andReturn(true);
$schema = SchemaFixture::managed();
$composer = Mockery::mock(ContentComposer::class);
$composer->expects('available')->andReturn(false);
$integration = new WordPressIntegration($schema, Mockery::mock(ChangeLog::class), $composer);
$integration = new WordPressIntegration($schema, FakeChangeLog::forbidden(), $composer);
$create = array_values(array_filter(
$integration->abilities(),