fix: typed write failures, template rollback, parent and term cleanup
WriteFailed maps to lit_write_failed / lit_partial_write (partial writes are logged with result partial); old template read before the update; row marker set before wp_update_post; created terms deleted on rollback; parent must be a readable non-descendant of a hierarchical type; featured image must be readable; snapshot keeps empty values; meta comparison after sanitize_meta; follow-up failures (listener, change log) only add warnings. 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:
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace LIT\MCP\Tests\Unit\Abilities;
|
||||
|
||||
use LIT\MCP\Abilities\FollowUp;
|
||||
use LIT\MCP\Tests\Unit\TestCase;
|
||||
use RuntimeException;
|
||||
|
||||
final class FollowUpTest extends TestCase
|
||||
{
|
||||
public function testReturnsTheResultOfASuccessfulStep(): void
|
||||
{
|
||||
$warnings = [];
|
||||
|
||||
self::assertSame(7, FollowUp::run(static fn (): int => 7, 'ctx', 'Warnung', $warnings));
|
||||
self::assertSame([], $warnings);
|
||||
}
|
||||
|
||||
public function testAFailingStepIsLoggedAndBecomesAWarning(): void
|
||||
{
|
||||
$log = (string) tempnam(sys_get_temp_dir(), 'lit-mcp-log');
|
||||
$previous = ini_set('error_log', $log);
|
||||
$warnings = ['alt'];
|
||||
|
||||
try {
|
||||
$result = FollowUp::run(
|
||||
static function (): void {
|
||||
throw new RuntimeException('hook kaputt');
|
||||
},
|
||||
'lit/content-create after_save',
|
||||
'Warnung',
|
||||
$warnings
|
||||
);
|
||||
} finally {
|
||||
ini_set('error_log', (string) $previous);
|
||||
}
|
||||
|
||||
self::assertNull($result);
|
||||
self::assertSame(['alt', 'Warnung'], $warnings);
|
||||
self::assertStringContainsString('lit/content-create after_save', (string) file_get_contents($log));
|
||||
self::assertStringContainsString('hook kaputt', (string) file_get_contents($log));
|
||||
unlink($log);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user