feat: content-create and content-update with schema validation
All-or-nothing writes: validation (fields, terms, featured image, parent, template) before any write; failed extras delete the new draft (create) or restore revision, old columns, fields, terms and featured image (update). content-update requires rev; Rev::ofPost covers content, title, excerpt, status and post_modified_gmt. MetaFieldSource::write() now throws on failure. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01At3V6SjwbMe6eMzVGW3Hs7
This commit is contained in:
@@ -8,6 +8,7 @@ use LIT\MCP\Abilities\JsonMap;
|
||||
use LIT\MCP\Abilities\Rev;
|
||||
use LIT\MCP\Tests\Unit\TestCase;
|
||||
use stdClass;
|
||||
use WP_Post;
|
||||
|
||||
final class RevAndJsonMapTest extends TestCase
|
||||
{
|
||||
@@ -18,6 +19,26 @@ final class RevAndJsonMapTest extends TestCase
|
||||
self::assertNotSame(Rev::of('abc'), Rev::of('abd'));
|
||||
}
|
||||
|
||||
public function testPostRevCoversContentTitleExcerptStatusAndModification(): void
|
||||
{
|
||||
$base = [
|
||||
'post_content' => '<p>A</p>',
|
||||
'post_title' => 'T',
|
||||
'post_excerpt' => 'E',
|
||||
'post_status' => 'draft',
|
||||
'post_modified_gmt' => '2026-09-25 08:00:00',
|
||||
];
|
||||
$rev = Rev::ofPost(new WP_Post($base));
|
||||
|
||||
self::assertMatchesRegularExpression('/^[0-9a-f]{12}$/', $rev);
|
||||
self::assertSame($rev, Rev::ofPost(new WP_Post($base)));
|
||||
self::assertNotSame(Rev::of('<p>A</p>'), $rev);
|
||||
foreach (['post_content' => '<p>B</p>', 'post_title' => 'U', 'post_excerpt' => 'F',
|
||||
'post_status' => 'publish', 'post_modified_gmt' => '2026-09-25 08:00:01'] as $key => $value) {
|
||||
self::assertNotSame($rev, Rev::ofPost(new WP_Post(array_merge($base, [$key => $value]))), $key);
|
||||
}
|
||||
}
|
||||
|
||||
public function testEmptyMapBecomesJsonObject(): void
|
||||
{
|
||||
self::assertInstanceOf(stdClass::class, JsonMap::of([]));
|
||||
|
||||
Reference in New Issue
Block a user