stolt/composer-multitest

Composer script to run a Composer test or spec script against all versions managed by PHPBrew or phpenv.

v1.1.0 2016-11-03 19:12 UTC

This package is auto-updated.

Last update: 2024-10-18 17:36:47 UTC


README

Build Status Version PHP Version composer.lock available

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.

Assumptions

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.

Installation

The Composer script should be installed as a development dependency through Composer.

composer require --dev stolt/composer-multitest

Usage

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"
    },

Example output

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
❯

Running tests

composer cm:test

License

This Composer script is licensed under the MIT license. Please see LICENSE for more details.

Changelog

Please see CHANGELOG for more details.

Contributing

Please see CONTRIBUTING for more details.