feat: lit/divi-presets-assign – Presets site-weit zuweisen mit Probelauf und höchstens 50 Seiten je Aufruf
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 5.5
parent
65a207488e
commit
d4f235ae5e
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace LIT\MCP\Tests\Unit\Integrations\Divi\Design;
|
||||
|
||||
use InvalidArgumentException;
|
||||
use LIT\MCP\Integrations\Divi\Design\PageRewriter;
|
||||
use LIT\MCP\Integrations\Divi\Design\PostIdsInput;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
final class PostIdsInputTest extends TestCase
|
||||
{
|
||||
public function testParsesAListOfPositiveIdsWithoutDuplicates(): void
|
||||
{
|
||||
self::assertNull(PostIdsInput::parse(null));
|
||||
self::assertSame([12, 13], PostIdsInput::parse([12, 13, 12]));
|
||||
self::assertSame(PageRewriter::PAGE_LIMIT, PostIdsInput::MAX);
|
||||
}
|
||||
|
||||
/** @dataProvider invalidInput */
|
||||
public function testRefusesEverythingElse(mixed $value): void
|
||||
{
|
||||
$this->expectException(InvalidArgumentException::class);
|
||||
$this->expectExceptionMessage('Liste von 1 bis 50 Beitrags-IDs (positive ganze Zahlen) erwartet');
|
||||
|
||||
PostIdsInput::parse($value);
|
||||
}
|
||||
|
||||
/** @return array<string, array{mixed}> */
|
||||
public static function invalidInput(): array
|
||||
{
|
||||
return [
|
||||
'leer' => [[]],
|
||||
'null als ID' => [[0]],
|
||||
'negativ' => [[-3]],
|
||||
'Text' => [['12']],
|
||||
'Objekt' => [['a' => 1]],
|
||||
'zu viele' => [range(1, 51)],
|
||||
'keine Liste' => [12],
|
||||
];
|
||||
}
|
||||
|
||||
public function testSchemaMatchesTheParser(): void
|
||||
{
|
||||
$schema = PostIdsInput::schema();
|
||||
|
||||
self::assertSame('array', $schema['type']);
|
||||
self::assertSame(1, $schema['minItems']);
|
||||
self::assertSame(50, $schema['maxItems']);
|
||||
self::assertSame(['type' => 'integer', 'minimum' => 1], $schema['items']);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user