diff --git a/composer.json b/composer.json index 273460b..01f0c2f 100644 --- a/composer.json +++ b/composer.json @@ -13,10 +13,10 @@ "require": { "php": "^5.3.2 || ^7.0", "ext-curl": "*", - "composer-plugin-api": "^1.0.0" + "composer-plugin-api": "^1.0.0 || ^2.0.0" }, "require-dev": { - "composer/composer": "1.0.0", + "composer/composer": "1.0.0 || ^2.0.0", "phpunit/phpunit": "4.8.* || 5.7.* || ^6.3", "squizlabs/php_codesniffer": "^2.5" }, diff --git a/src/Plugin.php b/src/Plugin.php index 0a42cd0..1f21db8 100644 --- a/src/Plugin.php +++ b/src/Plugin.php @@ -51,6 +51,11 @@ class Plugin implements public function activate(Composer $composer, IO\IOInterface $io) { + // Composer 2 comes with parallel downloads built-in + if (strcmp(self::PLUGIN_API_VERSION, '2.0.0') >= 0) { + return $this->disable(); + } + // @codeCoverageIgnoreStart // guard for self-update problem if (__CLASS__ !== 'Hirak\Prestissimo\Plugin') { @@ -95,6 +100,16 @@ class_exists(__NAMESPACE__ . '\\' . $class); } } + public function deactivate(Composer $composer, IO\IOInterface $io) + { + $this->disable(); + } + + public function uninstall(Composer $composer, IO\IOInterface $io) + { + $this->disable(); + } + public static function getSubscribedEvents() { return array( diff --git a/tests/unit/PluginTest.php b/tests/unit/PluginTest.php index 90a65cb..1d46ea7 100644 --- a/tests/unit/PluginTest.php +++ b/tests/unit/PluginTest.php @@ -62,6 +62,22 @@ public function testActivate() self::assertTrue(class_exists('Hirak\Prestissimo\CopyRequest', false)); } + public function testDeactivate() + { + $plugin = new Plugin; + self::assertFalse($plugin->isDisabled()); + $plugin->deactivate($this->composerp->reveal(), $this->iop->reveal()); + self::assertTrue($plugin->isDisabled()); + } + + public function testUninstall() + { + $plugin = new Plugin; + self::assertFalse($plugin->isDisabled()); + $plugin->uninstall($this->composerp->reveal(), $this->iop->reveal()); + self::assertTrue($plugin->isDisabled()); + } + public function testGetSubscribedEvent() { self::assertInternalType('array', Plugin::getSubscribedEvents());