Skip to content

Commit

Permalink
Configurable CLI command
Browse files Browse the repository at this point in the history
  • Loading branch information
adamziel committed Jan 14, 2023
1 parent dacb78a commit d431850
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/php-wasm/php-cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ async function main() {

php.mkdirTree('/wordpress');
php.mount({ root: '../../wordpress-develop' }, '/wordpress/');
php.addServerGlobalEntry('js_argv', JSON.stringify(process.argv.slice(2)));
php.writeFile(
'/wordpress/tests.php',
`<?php
Expand All @@ -25,18 +26,19 @@ async function main() {
putenv('WP_TESTS_SKIP_INSTALL=1');
// Provide CLI args for PHPUnit:
$_SERVER['argv'] = ['./vendor/bin/phpunit', '-c', './phpunit.xml.dist', '--filter', 'Tests_Formatting_Utf8UriEncode'];
$_SERVER['argv'] = json_decode($_SERVER['js_argv']);
// ['./vendor/bin/phpunit', '-c', './phpunit.xml.dist', '--filter', 'Tests_Formatting_Utf8UriEncode'];
chdir('/wordpress');
// Let's go!
require("/wordpress/vendor/bin/phpunit");
require($_SERVER['argv'][0]); //"/wordpress/vendor/bin/phpunit");
`
);
php.setSkipShebang(true);
const output = php.run({
scriptPath: '/wordpress/tests.php',
});
console.log(output);
// console.log(output);
console.log(new TextDecoder().decode(output.body));
}
main();

0 comments on commit d431850

Please sign in to comment.