Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01At3V6SjwbMe6eMzVGW3Hs7
38 lines
1.1 KiB
PHP
38 lines
1.1 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace LIT\MCP\Tests\Unit\Integrations\WordPress;
|
|
|
|
use Brain\Monkey\Functions;
|
|
use LIT\MCP\Integrations\WordPress\RevisionPoint;
|
|
use LIT\MCP\Tests\Unit\TestCase;
|
|
use WP_Post;
|
|
|
|
final class RevisionPointTest extends TestCase
|
|
{
|
|
public function testCaptureSavesARevisionAndReturnsTheNewest(): void
|
|
{
|
|
$order = [];
|
|
Functions\expect('wp_save_post_revision')->once()->with(5)->andReturnUsing(static function () use (&$order) {
|
|
$order[] = 'save';
|
|
return 811;
|
|
});
|
|
Functions\expect('wp_get_post_revisions')->once()->with(5, ['posts_per_page' => 1])
|
|
->andReturnUsing(static function () use (&$order): array {
|
|
$order[] = 'latest';
|
|
return [811 => new WP_Post(['ID' => 811, 'post_type' => 'revision'])];
|
|
});
|
|
|
|
self::assertSame(811, RevisionPoint::capture(5));
|
|
self::assertSame(['save', 'latest'], $order);
|
|
}
|
|
|
|
public function testLatestIsNullWithoutRevisions(): void
|
|
{
|
|
Functions\when('wp_get_post_revisions')->justReturn([]);
|
|
|
|
self::assertNull(RevisionPoint::latest(5));
|
|
}
|
|
}
|