- 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>
59 lines
2.0 KiB
PHP
59 lines
2.0 KiB
PHP
<?php
|
||
|
||
declare(strict_types=1);
|
||
|
||
namespace LIT\MCP\Tests\Unit\Integrations\Divi;
|
||
|
||
use LIT\MCP\Abilities\Ability;
|
||
use LIT\MCP\Integrations\Divi\DiviIntegration;
|
||
use LIT\MCP\Integrations\Divi\Pages\DiviContentComposer;
|
||
use LIT\MCP\Integrations\WordPress\Schema\ContentSchema;
|
||
use LIT\MCP\Tests\Support\FakeChangeLog;
|
||
use LIT\MCP\Tests\Unit\TestCase;
|
||
use Mockery;
|
||
|
||
final class DiviIntegrationTest extends TestCase
|
||
{
|
||
/** Grows with every task that adds Divi abilities – keep in the order of abilities(). */
|
||
private const EXPECTED = [
|
||
'lit/divi-outline',
|
||
'lit/divi-node-get',
|
||
'lit/divi-catalog',
|
||
'lit/divi-design-system',
|
||
'lit/divi-insert',
|
||
'lit/divi-update',
|
||
'lit/divi-move',
|
||
'lit/divi-delete',
|
||
'lit/divi-duplicate-node',
|
||
'lit/divi-replace-text',
|
||
];
|
||
|
||
public function testProvidesTheDiviAbilitiesOnlyWithDivi5(): void
|
||
{
|
||
$integration = new DiviIntegration(Mockery::mock(ContentSchema::class), FakeChangeLog::forbidden());
|
||
|
||
self::assertSame('divi', $integration->id());
|
||
self::assertFalse($integration->isAvailable(), 'no Divi classes in unit tests');
|
||
self::assertSame(
|
||
self::EXPECTED,
|
||
array_map(static fn (Ability $ability): string => $ability->name(), $integration->abilities())
|
||
);
|
||
|
||
foreach ($integration->abilities() as $ability) {
|
||
self::assertSame('object', $ability->inputSchema()['type'], $ability->name());
|
||
self::assertFalse($ability->inputSchema()['additionalProperties'], $ability->name());
|
||
self::assertNotNull($ability->outputSchema(), $ability->name());
|
||
}
|
||
}
|
||
|
||
public function testGivesContentCreateTheDiviShortForm(): void
|
||
{
|
||
$integration = new DiviIntegration(Mockery::mock(ContentSchema::class), FakeChangeLog::forbidden());
|
||
|
||
$composer = $integration->contentComposer();
|
||
|
||
self::assertInstanceOf(DiviContentComposer::class, $composer);
|
||
self::assertFalse($composer->available(), 'no Divi classes in unit tests');
|
||
}
|
||
}
|