diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 0000000..49c3898 --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,48 @@ +name: Test + +on: + push: + branches: + - master + pull_request: + # Allow manually triggering the workflow. + workflow_dispatch: + +jobs: + test: + name: PHP ${{ matrix.php }} + runs-on: ubuntu-latest + + strategy: + fail-fast: false + matrix: + php: ['8.0'] + phpunit: ['latest'] + include: + - php: '7.2' + phpunit: '8.5.13' + - php: '7.3' + phpunit: '8.5.13' + - php: '7.4' + phpunit: '8.5.13' + coverage: xdebug + flags: '--coverage-clover clover.xml' +# - php: '8.1' +# experimental: true + + + steps: + - uses: actions/checkout@v2 + + - name: Use PHP ${{ matrix.php }} + uses: shivammathur/setup-php@2.11.0 + with: + php-version: ${{ matrix.php }} + tools: phpunit:${{ matrix.phpunit }} + coverage: ${{ matrix.coverage }} + + - name: Install + run: composer install + + - name: Test + run: phpunit --configuration phpunit.xml.dist ${{ matrix.flags }} diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index b0d6c25..0000000 --- a/.travis.yml +++ /dev/null @@ -1,52 +0,0 @@ -language: php - -env: - global: - - PHPUNIT_FLAGS='--no-coverage' - - TEST_COVERAGE=0 - - -# https://phpunit.de/supported-versions.html -matrix: - include: - - php: 7.1 - env: PHPUNIT_VERSION=7.5.* - - php: 7.2 - env: PHPUNIT_VERSION=7.5.* - - php: 7.3 - env: PHPUNIT_VERSION=7.5.* - - php: 7.4 - env: PHPUNIT_VERSION=7.5.* TEST_COVERAGE=1 PHPUNIT_FLAGS='--coverage-clover clover.xml' - - php: nightly - env: PHPUNIT_VERSION=7.5.* - fast_finish: true - allow_failures: - - php: nightly - -cache: - apt: true - directories: - # Cache directory for older Composer versions. - - $HOME/.composer/cache/files - # Cache directory for more recent Composer versions. - - $HOME/.cache/composer/files - -install: - # Speed up build time by disabling Xdebug unless actually needed. - - if [ "$TEST_COVERAGE" != '1' ]; then phpenv config-rm xdebug.ini || echo 'No xdebug config.'; fi - - composer global require hirak/prestissimo --no-suggest --no-interaction - # Update composer.json to overwrite phpunit with specific version - - composer require "phpunit/phpunit:${PHPUNIT_VERSION}" --dev --no-update --no-interaction --no-suggest - - composer install --no-suggest --no-interaction --ignore-platform-reqs - -script: ./vendor/bin/phpunit --configuration ./phpunit.xml.dist $PHPUNIT_FLAGS - -after_script: - - | - if [ "$TEST_COVERAGE" == '1' ]; then - travis_retry wget https://scrutinizer-ci.com/ocular.phar; - travis_retry php ocular.phar code-coverage:upload --format=php-clover clover.xml; - fi - -notifications: - email: false diff --git a/composer.json b/composer.json index ec8084a..bbfa0d5 100644 --- a/composer.json +++ b/composer.json @@ -9,13 +9,13 @@ "yourls-plugin" ], "require": { - "composer-plugin-api": "^1.0", - "wikimedia/composer-merge-plugin": "^1.4", + "composer-plugin-api": "^2.0", + "wikimedia/composer-merge-plugin": "^2.0", "symfony/thanks": "^1.2" }, "require-dev": { "composer/composer": "^2.0.13", - "phpunit/phpunit": "^7.0" + "phpunit/phpunit": "^8.5" }, "autoload": { "psr-4": { diff --git a/src/ComposerInstaller/Plugin.php b/src/ComposerInstaller/Plugin.php index 1c78d15..5d39c52 100644 --- a/src/ComposerInstaller/Plugin.php +++ b/src/ComposerInstaller/Plugin.php @@ -42,4 +42,31 @@ public function getCapabilities() ); } + /** + * Remove any hooks from Composer + * + * @codeCoverageIgnore + * + * @param \Composer\Composer $composer + * @param \Composer\IO\IOInterface $io + * @return void + */ + public function deactivate(Composer $composer, IOInterface $io) + { + // nothing to do + } + + /** + * Prepare the plugin to be uninstalled + * + * @codeCoverageIgnore + * + * @param Composer $composer + * @param IOInterface $io + * @return void + */ + public function uninstall(Composer $composer, IOInterface $io) + { + // nothing to do + } } diff --git a/tests/ComposerInstaller/MockDownloader.php b/tests/ComposerInstaller/MockDownloader.php index 545882c..273e0a0 100644 --- a/tests/ComposerInstaller/MockDownloader.php +++ b/tests/ComposerInstaller/MockDownloader.php @@ -20,7 +20,7 @@ public function getInstallationSource() return 'dist'; } - public function download(PackageInterface $package, $path) + public function download(PackageInterface $package, $path, ?$prevPackage = NULL) { // install a fake plugin directory $this->filesystem->ensureDirectoryExists($path);