Skip to content

Commit a7bf639

Browse files
committed
build: add new composer script test
Running the unit tests is difficult with the 2 different phpcs scripts and not knowing which one to use. Added new simple `test` script which determines the installed version of phpcs and runs the appropriate script, either `test-phpcs4` or `test-phpcs3`.
1 parent 4f7b5a4 commit a7bf639

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

composer.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,10 @@
5353
"Composer\\Config::disableProcessTimeout",
5454
"@php ./vendor/bin/phpunit --filter yCodeTech --no-coverage ./vendor/squizlabs/php_codesniffer/tests/AllTests.php"
5555
],
56+
"test": [
57+
"Composer\\Config::disableProcessTimeout",
58+
"@php -r \"echo 'Determining PHPCS version...\n'; $version = shell_exec('vendor/bin/phpcs --version 2>nul || vendor\\\\bin\\\\phpcs.bat --version'); if ($version && is_string($version) && preg_match('/([0-9]+)\\./', $version, $matches)) { $major = $matches[1]; } else { $major = '3'; } $script = ($major >= 4) ? 'test-phpcs4' : 'test-phpcs3'; echo 'Running ' . $script . '...' . \"\"\n\"\"; system('composer run-script ' . $script);\""
59+
],
5660
"cs-test-file": "@cs ./test_utils/TestFile.php",
5761
"fix-test-file": "@cbf ./test_utils/TestFile.php",
5862
"restore-test-file": "bash ./test_utils/restore_errors.sh",
@@ -72,6 +76,7 @@
7276
"cbf": "Run PHPCBF to fix coding standards violations.",
7377
"test-phpcs4": "PHPCS 4.x: Run PHPUnit tests without code coverage.",
7478
"test-phpcs3": "PHPCS 3.x: Run PHPUnit tests without code coverage.",
79+
"test": "Run the appropriate PHPUnit composer script based on the installed PHPCS version, (test-phpcs4 or test-phpcs3).",
7580
"cs-test-file": "Run PHPCS on the test file.",
7681
"fix-test-file": "Run PHPCBF on the test file.",
7782
"restore-test-file": "Restore the test file to its original state.",

0 commit comments

Comments
 (0)