refactor: small Divi tree helpers out of DiviWriter (M3)
Block::isPlaceholder replaces the divi/placeholder literals (ledger T4); NodeIndex::parentBlock/sectionLabel replace the two parentBlock copies and DiviWriter::sectionLabel; DiviChange::idOf and Outline::summary replace the duplicated id resolution and outline text; DiviSchema holds the shared input properties. Behaviour unchanged. 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,31 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace LIT\MCP\Tests\Unit\Integrations\Divi\Pages;
|
||||
|
||||
use LIT\MCP\Integrations\Divi\BlockTree\Block;
|
||||
use LIT\MCP\Integrations\Divi\BlockTree\NodeIndex;
|
||||
use LIT\MCP\Integrations\Divi\BlockTree\Parser;
|
||||
use LIT\MCP\Integrations\Divi\Pages\DiviChange;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
final class DiviChangeTest extends TestCase
|
||||
{
|
||||
public function testIdOfAnEntryAfterTheChange(): void
|
||||
{
|
||||
$index = NodeIndex::build((new Parser())->parse(
|
||||
'<!-- wp:divi/section --><!-- wp:divi/row /--><!-- /wp:divi/section -->'
|
||||
));
|
||||
$row = $index->find('s0.r0');
|
||||
$change = (new DiviChange('x'))
|
||||
->changed($row, 'updated')
|
||||
->removed('s3.r1', Block::create('divi/row'))
|
||||
->changed(Block::create('divi/text'), 'inserted');
|
||||
|
||||
self::assertSame(
|
||||
['s0.r0', 's3.r1', null],
|
||||
array_map(static fn (array $entry): ?string => DiviChange::idOf($entry, $index), $change->entries())
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user