refactor: PostRow::update and PostGuard::assertNoMissedSchedule (M5)
- PostRow::update(id, columns, failure) / ::save(): the slashed wp_update_post of internal row writes, refusals as RuntimeException '<failure>: <why>'. Used by ContentUpdate::restoreRow, PostCloner::updateRow, MediaMetaWriter apply/restore. - PostGuard::assertNoMissedSchedule(postId, message) replaces the re-read + check in ContentUpdate::restoreRow, PostCloner and DiviSaver::restore (DiviSaver keeps its own kses window; M4). - PostCloner::restore uses Rollback::attempt. Log messages unchanged. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -148,4 +148,20 @@ final class PostGuardTest extends TestCase
|
||||
Functions\when('current_user_can')->justReturn(false);
|
||||
self::assertSame('lit_forbidden', PostGuard::postType('page', $this->schema(), 'create_posts')->get_error_code());
|
||||
}
|
||||
|
||||
public function testAssertNoMissedScheduleRefusesAMissedScheduleWithTheCallersMessage(): void
|
||||
{
|
||||
Functions\when('get_post')->alias(static fn (int $id): ?WP_Post => match ($id) {
|
||||
5 => new WP_Post(['ID' => 5, 'post_status' => 'future', 'post_date_gmt' => '2020-01-01 09:00:00']),
|
||||
6 => new WP_Post(['ID' => 6, 'post_status' => 'publish']),
|
||||
default => null,
|
||||
});
|
||||
|
||||
PostGuard::assertNoMissedSchedule(6, 'nie');
|
||||
PostGuard::assertNoMissedSchedule(7, 'nie');
|
||||
|
||||
$this->expectException(\RuntimeException::class);
|
||||
$this->expectExceptionMessage('Post 5 not written');
|
||||
PostGuard::assertNoMissedSchedule(5, 'Post 5 not written');
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user