23 lines
941 B
PHP
23 lines
941 B
PHP
<?php
|
|
namespace Tests\Unit\Freenode;
|
|
use App\Services\Freenode\NativeValidator;
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
final class NativeValidatorTest extends TestCase
|
|
{
|
|
public function testNativeErrorIndexAvoidsCheckingEveryNodeSeparately(): void
|
|
{
|
|
$mh = getenv('TEST_MIHOMO');
|
|
if (!$mh) self::markTestSkipped('Set TEST_MIHOMO for native validation');
|
|
$rows = [];
|
|
for ($i = 0; $i < 32; $i++) {
|
|
$rows[hash('sha256', (string) $i)] = ['name' => 'synthetic-'.$i, 'type' => 'ss', 'server' => 'example.invalid', 'port' => 443, 'cipher' => $i % 4 === 0 ? 'invalid-synthetic' : 'aes-128-gcm', 'password' => 'synthetic'];
|
|
}
|
|
$validator = new NativeValidator('', $mh);
|
|
$good = $validator->filter('clash', $rows);
|
|
self::assertCount(24, $good);
|
|
self::assertCount(8, $validator->rejected['clash']);
|
|
self::assertLessThanOrEqual(10, $validator->checks);
|
|
}
|
|
}
|