Next gate
Gates are operated by District IT. Current role can review the package but not advance it.
tests/SandboxTest.php
sha256 bc25acd6f75eaa06883f…1<?php 2declare(strict_types=1); 3/** 4 * Standalone sandbox test for connector build PK-261005-002. 5 * Run on any PHP 8.2+ host with NO network access: php tests/SandboxTest.php 6 * Exit code 0 = pass. The platform runs the same assertions in-process on Approve. 7 */ 8require __DIR__ . '/../src/Transport.php'; 9require __DIR__ . '/../src/Connector.php'; 10 11use Msad17\Connectors\MilestoneApigw\B2610051208502\Connector; 12use Msad17\Connectors\MilestoneApigw\B2610051208502\FixtureTransport; 13 14$fixtures = array_values(array_filter(array_map( 15 fn(string $l) => json_decode($l, true), 16 file(__DIR__ . '/../fixtures/events.jsonl', FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES) 17))); 18$expect = json_decode((string)file_get_contents(__DIR__ . '/../fixtures/expected.json'), true); 19$config = json_decode((string)file_get_contents(__DIR__ . '/../config/config.example.json'), true); 20 21$t = new FixtureTransport($fixtures); 22$c = new Connector($t, $config); 23$fail = 0; 24$n = 0; 25$check = function (bool $ok, string $msg) use (&$fail, &$n): void { 26 $n++; 27 echo ($ok ? 'ok ' : 'not ok ') . $n . ' - ' . $msg . PHP_EOL; 28 if (!$ok) { $fail++; } 29}; 30 31$p = $c->probe(); 32$check($p['ok'] === true, 'probe() returns ok against fixture transport'); 33$check($p['mode'] === 'read_only', 'connector reports read_only mode'); 34$r = $c->pullEvents(); 35$check(count($r['events']) === $expect['mapped'], "mapped events = {$expect['mapped']}"); 36$check($r['unmapped'] === $expect['unmapped'], "unmapped events = {$expect['unmapped']} (logged, not dropped)"); 37foreach ($r['events'] as $i => $e) { 38 $check($e['type'] === $expect['types'][$i], "event[{$i}] normalized to {$expect['types'][$i]}"); 39} 40$public = array_map(fn($m) => $m->getName(), (new ReflectionClass(Connector::class))->getMethods(ReflectionMethod::IS_PUBLIC)); 41$check(array_diff($public, ['__construct', 'probe', 'pullEvents', 'normalize', 'liveUri']) === [], 'no write methods exposed'); 42echo PHP_EOL . ($fail === 0 ? 'SANDBOX PASS' : "SANDBOX FAIL ({$fail})") . PHP_EOL; 43exit($fail === 0 ? 0 : 1);