refactor: WriteFailed named constructors, Rollback runner, Errors read-back helpers (H6)
- WriteFailed::rolledBack()/partial() replace the 11-parameter constructor (now private); the hint/state of either error are plain $hint/$state. - Rollback::attempt(...steps) runs every undo step and collects failure messages; used by ContentCreate::discard, ContentUpdate::rollBack, MediaUpdate::rollBack and DiviSaver::restore. - Errors::clientMessage/codeOf/fieldsOf replace DiviReplaceTextAbility::reason, the JSON digging in MediaUpdateAbility::failure and ContentCreateAbility::fields. - Errors docblock documents the exception/WP_Error split. - ContentCreateAbility::discard takes the client reason as a parameter (both callers still pass REASON_EXTRAS; changing the Divi text needs a ruling). Error payloads unchanged. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -171,7 +171,7 @@ final class DiviWriterTest extends TestCase
|
||||
$content = DiviPageLoaderTest::fixture('synthetic-basic.html');
|
||||
DiviPageLoaderTest::givenPost($content);
|
||||
$saver = Mockery::mock(DiviSaver::class);
|
||||
$saver->allows('save')->andThrow(new WriteFailed(DiviSaver::REASON, false, 7, 811));
|
||||
$saver->allows('save')->andThrow(WriteFailed::partial(DiviSaver::REASON, postId: 7, revisionId: 811));
|
||||
$log = Mockery::mock(ChangeLog::class);
|
||||
$log->expects('recordPartial')->with('lit/divi-delete', 'page', '7', 'Divi "Start": Änderung nur teilweise zurückgenommen', 811);
|
||||
$writer = $this->writer($saver, $log);
|
||||
@@ -187,7 +187,7 @@ final class DiviWriterTest extends TestCase
|
||||
$content = DiviPageLoaderTest::fixture('synthetic-basic.html');
|
||||
DiviPageLoaderTest::givenPost($content);
|
||||
$saver = Mockery::mock(DiviSaver::class);
|
||||
$saver->allows('save')->andThrow(new WriteFailed(DiviSaver::REASON, true, 7, 811));
|
||||
$saver->allows('save')->andThrow(WriteFailed::rolledBack(DiviSaver::REASON, postId: 7, revisionId: 811));
|
||||
$log = Mockery::mock(ChangeLog::class);
|
||||
$log->expects('recordPartial')->never();
|
||||
$log->expects('record')->never();
|
||||
|
||||
Reference in New Issue
Block a user