aboutsummaryrefslogtreecommitdiffhomepage
path: root/crates/shirabe/tests/plugin/fixtures/subscriber-v1
diff options
context:
space:
mode:
Diffstat (limited to 'crates/shirabe/tests/plugin/fixtures/subscriber-v1')
-rw-r--r--crates/shirabe/tests/plugin/fixtures/subscriber-v1/Subscriber/Plugin.php61
-rw-r--r--crates/shirabe/tests/plugin/fixtures/subscriber-v1/composer.json12
2 files changed, 73 insertions, 0 deletions
diff --git a/crates/shirabe/tests/plugin/fixtures/subscriber-v1/Subscriber/Plugin.php b/crates/shirabe/tests/plugin/fixtures/subscriber-v1/Subscriber/Plugin.php
new file mode 100644
index 00000000..f75763ba
--- /dev/null
+++ b/crates/shirabe/tests/plugin/fixtures/subscriber-v1/Subscriber/Plugin.php
@@ -0,0 +1,61 @@
+<?php
+
+namespace Subscriber;
+
+use Composer\Composer;
+use Composer\EventDispatcher\EventSubscriberInterface;
+use Composer\IO\IOInterface;
+use Composer\Plugin\PluginInterface;
+
+class Plugin implements PluginInterface, EventSubscriberInterface
+{
+ public $version = 'subscriber-v1';
+
+ /** @var IOInterface */
+ private $io;
+
+ public function activate(Composer $composer, IOInterface $io)
+ {
+ $this->io = $io;
+ $io->write('activate subscriber-v1');
+ }
+
+ public function deactivate(Composer $composer, IOInterface $io)
+ {
+ }
+
+ public function uninstall(Composer $composer, IOInterface $io)
+ {
+ }
+
+ public static function getSubscribedEvents()
+ {
+ return [
+ 'post-install-cmd' => 'onPostInstall',
+ 'shirabe-priority-event' => [['early', 10], ['late', -10]],
+ 'shirabe-false-event' => ['returnsFalse', 0],
+ ];
+ }
+
+ public function onPostInstall($event)
+ {
+ $this->io->write('subscriber saw ' . $event->getName());
+ }
+
+ public function early($event)
+ {
+ $this->io->write('early listener');
+ }
+
+ public function late($event)
+ {
+ $this->io->write('late listener');
+ }
+
+ public function returnsFalse($event)
+ {
+ $this->io->write('failing listener');
+
+ return false;
+ }
+}
diff --git a/crates/shirabe/tests/plugin/fixtures/subscriber-v1/composer.json b/crates/shirabe/tests/plugin/fixtures/subscriber-v1/composer.json
new file mode 100644
index 00000000..40659606
--- /dev/null
+++ b/crates/shirabe/tests/plugin/fixtures/subscriber-v1/composer.json
@@ -0,0 +1,12 @@
+{
+ "name": "subscriber-v1",
+ "version": "1.0.0",
+ "type": "composer-plugin",
+ "autoload": { "psr-0": { "Subscriber": "" } },
+ "extra": {
+ "class": "Subscriber\\Plugin"
+ },
+ "require": {
+ "composer-plugin-api": "^2.0"
+ }
+}