Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
45 lines
1.5 KiB
PHP
45 lines
1.5 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace LIT\MCP\Tests\Unit\Integrations\Divi\Release;
|
|
|
|
use LIT\MCP\Integrations\Divi\Release\DiviAdapters;
|
|
use LIT\MCP\Integrations\Divi\Release\DiviReference;
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
final class DiviReferenceTest extends TestCase
|
|
{
|
|
public function testEveryMirrorHasAnExpectedFingerprintAndAReferenceSource(): void
|
|
{
|
|
$ids = array_map(static fn ($mirror): string => $mirror->id, DiviAdapters::mirrors());
|
|
sort($ids);
|
|
$expected = DiviReference::expected();
|
|
|
|
self::assertSame($ids, array_keys($expected));
|
|
foreach ($expected as $id => $hash) {
|
|
self::assertMatchesRegularExpression('/^[0-9a-f]{64}$/', $hash, $id);
|
|
self::assertNotNull(DiviReference::readSource($id, (string) DiviReference::sourceDir()), $id);
|
|
}
|
|
}
|
|
|
|
public function testWritesAndReadsExpectedFingerprintsSorted(): void
|
|
{
|
|
$file = (string) tempnam(sys_get_temp_dir(), 'lit');
|
|
|
|
try {
|
|
DiviReference::writeExpected(['b' => str_repeat('b', 64), 'a' => str_repeat('a', 64)], $file);
|
|
|
|
self::assertSame(['a' => str_repeat('a', 64), 'b' => str_repeat('b', 64)], DiviReference::expected($file));
|
|
self::assertStringEndsWith("\n", (string) file_get_contents($file));
|
|
} finally {
|
|
unlink($file);
|
|
}
|
|
}
|
|
|
|
public function testMissingOrBrokenFileMeansNoExpectations(): void
|
|
{
|
|
self::assertSame([], DiviReference::expected('/nonexistent/fingerprints.json'));
|
|
}
|
|
}
|