composer-multitest
is a Composer script that runs a test
or spec
Composer script against multiple PHP versions managed by PHPBrew or phpenv. Kind of a local Travis CI.
As composer-multitest
utilizes phpenv and PHPBrew it's assumed that at least one of them is installed and manages several PHP versions. It will first look for phpenv managed versions and when this fails it will subsequently look for PHPBrew managed ones.
The versions to test against are read from the local Travis CI configuration so it's assumed that one is present. Versions present in the Travis CI configuration not having a phpenv or PHPBrew managed version will fail the script when not disabled via the --skip-missing-versions
option.
The Composer script composer-multitest
will run MUST be named test
or spec
and it can be defined in a Composer script namespace like library:test|spec
.
The Composer script should be installed as a development dependency through Composer.
composer require --dev stolt/composer-multitest
Once installed add the Composer script to the existing composer.json
and use it afterwards via composer multitest
.
{
"scripts": {
"multitest": "Stolt\\Composer\\Multitest::run"
},
}
If you want to disable the prerequisite that the tests or specs have to be run against all PHP versions defined in the Travis CI configuration use the --skip-missing-versions
option like shown next.
{
"scripts": {
"multitest-run": "Stolt\\Composer\\Multitest::run",
"multitest": "composer run-script multitest-run -- --skip-missing-versions"
},
The follow console output shows an example multitest run against two PHP versions.
❯ composer multitest
> Stolt\Composer\Multitest::run
>> Switching to 'php-7.0.4'.
>> Running 'composer lpv:test'.
PHPUnit 5.6.1 by Sebastian Bergmann and contributors.
................................................................. 65 / 96 ( 67%)
............................... 96 / 96 (100%)
Time: 591 ms, Memory: 12.25MB
OK (96 tests, 150 assertions)
>> Switching to 'php-5.6.19'.
>> Running 'composer lpv:test'.
PHPUnit 5.6.1 by Sebastian Bergmann and contributors.
................................................................. 65 / 96 ( 67%)
............................... 96 / 96 (100%)
Time: 591 ms, Memory: 12.25MB
OK (96 tests, 150 assertions)
❯ echo $?
0
❯
composer cm:test
This Composer script is licensed under the MIT license. Please see LICENSE for more details.
Please see CHANGELOG for more details.
Please see CONTRIBUTING for more details.