Files
janniclas.loosenandClaude Opus 5.5 06f13799de fix: full-form internal links follow the {{link:}} target rules (ruling P10)
One PostIdParser for {{link:}} and select_post; post_link_url_<type> needs a
living, readable, non-attachment target of exactly that type.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-09-27 14:54:51 +02:00

31 lines
1.0 KiB
PHP
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?php
declare(strict_types=1);
namespace LIT\MCP\Tests\Unit\Integrations\Divi\Compose;
use LIT\MCP\Integrations\Divi\Compose\PostIdParser;
use PHPUnit\Framework\TestCase;
final class PostIdParserTest extends TestCase
{
public function testAcceptsPositiveIdsAsIntOrDigits(): void
{
self::assertSame(839, PostIdParser::parse(839));
self::assertSame(839, PostIdParser::parse('839'));
self::assertSame(PHP_INT_MAX, PostIdParser::parse((string) PHP_INT_MAX));
}
/** Ruling P10: one rule for {{link:}} and post_link_url_* – no zero, sign, padding, slug or overflow. */
public function testRefusesEverythingElse(): void
{
$bad = [
0, -3, '0', '-3', '+3', '0839', '8 39', ' 839', '839 ', "839\n", '839.0', '0x1f', '1e3', 'impressum',
'99999999999999999999', '9223372036854775808', 1.5, 839.0, null, [], true, false,
];
foreach ($bad as $value) {
self::assertNull(PostIdParser::parse($value), var_export($value, true));
}
}
}