Files
WP-LIT-MCP/tests/Unit/Integrations/Divi/Pages/DiviWriteAbilityTestCase.php
T
janniclas.loosenandClaude Opus 5.5 7963aa19bd test: split DiviWriteAbilitiesTest per tool (T5)
One test class per Divi write tool on a shared DiviWriteAbilityTestCase;
the 30 tests move verbatim (per-test assertion counts identical). Adds the
ledger T4 test for a TreeEditor::move() StructureRules refusal.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01At3V6SjwbMe6eMzVGW3Hs7
2026-09-26 18:27:59 +02:00

73 lines
2.1 KiB
PHP

<?php
declare(strict_types=1);
namespace LIT\MCP\Tests\Unit\Integrations\Divi\Pages;
use Brain\Monkey\Functions;
use LIT\MCP\Abilities\Rev;
use LIT\MCP\Integrations\Divi\Pages\DiviDeleteAbility;
use LIT\MCP\Integrations\Divi\Pages\DiviDuplicateNodeAbility;
use LIT\MCP\Integrations\Divi\Pages\DiviInsertAbility;
use LIT\MCP\Integrations\Divi\Pages\DiviMoveAbility;
use LIT\MCP\Integrations\Divi\Pages\DiviUpdateAbility;
use LIT\MCP\Integrations\Divi\Pages\DiviWriter;
use LIT\MCP\Tests\Support\DiviFixtures;
use LIT\MCP\Tests\Support\DiviWriterFixture;
use LIT\MCP\Tests\Unit\TestCase;
use WP_Post;
/**
* Shared setup of the Divi write tool tests: the synthetic page as post 7, a DiviWriter whose
* saver records every stored content in $saved, and one factory per tool.
*/
abstract class DiviWriteAbilityTestCase extends TestCase
{
protected WP_Post $post;
protected string $original = '';
/** @var list<string> Contents handed to DiviSaver::save(). */
protected array $saved = [];
protected DiviWriter $writer;
protected function setUp(): void
{
parent::setUp();
$this->original = DiviFixtures::markup('synthetic-basic.html');
$this->post = DiviFixtures::givenPost($this->original);
Functions\when('get_preview_post_link')->justReturn('https://kunde.test/?page_id=7&preview=true');
$this->writer = DiviWriterFixture::writer($this->saved);
}
protected function treeRev(): string
{
return Rev::of($this->original);
}
protected function insert(): DiviInsertAbility
{
return new DiviInsertAbility($this->writer);
}
protected function update(): DiviUpdateAbility
{
return new DiviUpdateAbility($this->writer);
}
protected function move(): DiviMoveAbility
{
return new DiviMoveAbility($this->writer);
}
protected function delete(): DiviDeleteAbility
{
return new DiviDeleteAbility($this->writer);
}
protected function duplicate(): DiviDuplicateNodeAbility
{
return new DiviDuplicateNodeAbility($this->writer);
}
}