Requirement, Call, ConstantRequirement, Mirror, Problem, FeatureStatus, CompatibilityMatrix, Manifest, ManifestCheck sowie Fingerprints und LineDiff liegen jetzt im divi-freien Kern. Neu: GlobalRequirement, CompatibilityMatrix::fromProblems(), ManifestCheck-Option signatures, DiviManifestCheck::create() und DiviAreas. Divi-Verhalten unverändert. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
53 lines
1.7 KiB
PHP
53 lines
1.7 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace LIT\MCP\Tests\Unit\Compatibility;
|
|
|
|
use LIT\MCP\Compatibility\Call;
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
final class CallTest extends TestCase
|
|
{
|
|
public static function sample(int $a, int $b = 0): void
|
|
{
|
|
}
|
|
|
|
private static function method(): string
|
|
{
|
|
return self::class . '::sample';
|
|
}
|
|
|
|
public function testAcceptsAnExistingFunctionWithAMatchingArgumentCount(): void
|
|
{
|
|
self::assertTrue((new Call('strlen', 1))->accepts());
|
|
self::assertTrue((new Call('sprintf', 5))->accepts(), 'variadic');
|
|
}
|
|
|
|
public function testRejectsAnArgumentCountThePlatformFunctionDoesNotTake(): void
|
|
{
|
|
self::assertFalse((new Call('strlen', 2))->accepts(), 'strlen takes one argument');
|
|
self::assertFalse((new Call('str_replace', 2))->accepts(), 'str_replace needs three');
|
|
}
|
|
|
|
public function testNullArgumentCountOnlyChecksExistence(): void
|
|
{
|
|
self::assertTrue((new Call('str_replace'))->accepts());
|
|
}
|
|
|
|
public function testMissingFunctionOrMethodIsRejected(): void
|
|
{
|
|
self::assertFalse((new Call('lit_mcp_missing_function'))->accepts());
|
|
self::assertFalse((new Call(self::class . '::missing'))->accepts());
|
|
self::assertFalse((new Call('Lit\Missing\Klass::method'))->accepts());
|
|
}
|
|
|
|
public function testChecksTheArgumentCountOfAMethod(): void
|
|
{
|
|
self::assertTrue((new Call(self::method(), 1))->accepts());
|
|
self::assertTrue((new Call(self::method(), 2))->accepts());
|
|
self::assertFalse((new Call(self::method(), 0))->accepts(), 'one required');
|
|
self::assertFalse((new Call(self::method(), 3))->accepts(), 'at most two');
|
|
}
|
|
}
|