fix: final review minors m-1 to m-8
- m-1: the no-change Divi result carries preview_url/edit_url too - m-2: overview names replace-text's per-page tree_rev - m-3: divi-shortform documents validation_failed vs not_found for unknown IDs - m-4: DiviWriter/DiviPageLoader final (no mocks left), neutral NewDraft log detail, snapshots are Etappe 4 - m-5: Tested up to 7.1, changelog completed - m-6: content-create warns when the extras changed the stored layout - m-7: deleting a whole section outlines nothing instead of the next one - m-8: uninstall removes the user meta lit_mcp_log_per_page; readme lists it 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:
@@ -123,6 +123,46 @@ final class ContentCreateDiviTest extends TestCase
|
||||
self::assertArrayHasKey('divi', $this->ability(null)->inputSchema()['properties']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Review m-6: the extras are written after the layout; if that re-saves the entry (e.g. Pods
|
||||
* object fields call wp_update_post, a save_post listener) and the layout changes, say so.
|
||||
*/
|
||||
public function testALayoutChangedByTheExtrasIsReported(): void
|
||||
{
|
||||
$composer = $this->composer();
|
||||
$composer->allows('write')->andReturn(['warnings' => [], 'outline' => 's0 divi/section']);
|
||||
Functions\when('wp_insert_post')->justReturn(42);
|
||||
$this->stubStoredDraft();
|
||||
$writer = Mockery::mock(PostWriter::class);
|
||||
$writer->allows('prepare')->andReturn(['fields' => [], 'terms' => [], 'warnings' => []]);
|
||||
$writer->allows('postData')->andReturn(['post_title' => 'Start']);
|
||||
$writer->allows('deniedMeta')->andReturn([]);
|
||||
$writer->expects('writeExtras')->andReturnUsing(static function (): void {
|
||||
Functions\when('get_post')->justReturn(new WP_Post([
|
||||
'ID' => 42, 'post_title' => 'Start', 'post_type' => 'page', 'post_status' => 'draft',
|
||||
'post_content' => '<!-- wp:divi/placeholder /-->',
|
||||
]));
|
||||
});
|
||||
|
||||
$result = $this->ability($composer, $writer)->execute(self::INPUT + ['fields' => ['role' => 'x']]);
|
||||
|
||||
self::assertSame(Rev::of('<!-- wp:divi/placeholder /-->'), $result['tree_rev'], 'the stored state');
|
||||
self::assertContains(ContentCreateAbility::LAYOUT_CHANGED, $result['warnings']);
|
||||
|
||||
$this->stubStoredDraft();
|
||||
$unchanged = $this->ability($this->composerWriting(), $this->writer())->execute(self::INPUT);
|
||||
self::assertNotContains(ContentCreateAbility::LAYOUT_CHANGED, $unchanged['warnings']);
|
||||
}
|
||||
|
||||
/** @return ContentComposer&MockInterface */
|
||||
private function composerWriting(): ContentComposer
|
||||
{
|
||||
$composer = $this->composer();
|
||||
$composer->allows('write')->andReturn(['warnings' => [], 'outline' => null]);
|
||||
|
||||
return $composer;
|
||||
}
|
||||
|
||||
public function testWithoutDiviTheComposerIsNotUsed(): void
|
||||
{
|
||||
$composer = Mockery::mock(ContentComposer::class);
|
||||
|
||||
@@ -33,7 +33,7 @@ final class NewDraftTest extends TestCase
|
||||
self::assertSame(42, $e->postId);
|
||||
self::assertSame('Grund für den Client.', $e->reason);
|
||||
self::assertSame(
|
||||
'Extras of new post 42 could not be written: layout kaputt; rollback: term 15 bleibt; '
|
||||
'Writing new post 42 failed after the insert: layout kaputt; rollback: term 15 bleibt; '
|
||||
. 'draft 42 could not be deleted: delete_post hook kaputt [rollback incomplete]',
|
||||
$e->getMessage()
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user