#!/usr/bin/env php '.dylib', default => '.so', }; $extPath = __DIR__ . '/../../target/release/libkreuzberg_php' . $extSuffix; // If the locally-built extension exists and we have not already restarted with it, // re-exec PHP with the freshly-built extension loaded explicitly via `-d extension=`. // The system php.ini is kept (no `-n`) so PHPUnit's required extensions — dom, json, // libxml, mbstring, tokenizer, xml, xmlwriter — remain available. `-n` drops every // shared module, which breaks PHPUnit on distributions that ship those as shared // extensions (e.g. Debian/Ubuntu); they only survive `-n` where compiled statically. if (file_exists($extPath) && !getenv('ALEF_PHP_LOCAL_EXT_LOADED')) { putenv('ALEF_PHP_LOCAL_EXT_LOADED=1'); $php = PHP_BINARY; $phpunitPath = __DIR__ . '/vendor/bin/phpunit'; $cmd = array_merge( [$php, '-d', 'extension=' . $extPath], [$phpunitPath], array_slice($GLOBALS['argv'], 1) ); passthru(implode(' ', array_map('escapeshellarg', $cmd)), $exitCode); exit($exitCode); } // Extension is now loaded (via the restart above). // Invoke PHPUnit normally. $phpunitPath = __DIR__ . '/vendor/bin/phpunit'; if (!file_exists($phpunitPath)) { echo "PHPUnit not found at $phpunitPath. Run 'composer install' first.\n"; exit(1); } require $phpunitPath;