diff --git a/phpunit.xml.dist b/phpunit.xml.dist
new file mode 100644
index 00000000..62409b3b
--- /dev/null
+++ b/phpunit.xml.dist
@@ -0,0 +1,18 @@
+
+
+
+
+
+ ./tests/
+
+
+
+
+
+ src/
+
+
+ vendor/
+
+
+
diff --git a/src/PatchEvent.php b/src/PatchEvent.php
new file mode 100644
index 00000000..31d36f89
--- /dev/null
+++ b/src/PatchEvent.php
@@ -0,0 +1,70 @@
+package = $package;
+ $this->url = $url;
+ $this->description = $description;
+ }
+
+ /**
+ * Returns the package that is patched.
+ *
+ * @return PackageInterface
+ */
+ public function getPackage() {
+ return $this->package;
+ }
+
+ /**
+ * Returns the url of the patch.
+ *
+ * @return string
+ */
+ public function getUrl() {
+ return $this->url;
+ }
+
+ /**
+ * Returns the description of the patch.
+ *
+ * @return string
+ */
+ public function getDescription() {
+ return $this->description;
+ }
+
+}
diff --git a/src/PatchEvents.php b/src/PatchEvents.php
new file mode 100644
index 00000000..ecee9476
--- /dev/null
+++ b/src/PatchEvents.php
@@ -0,0 +1,30 @@
+composer = $composer;
$this->io = $io;
+ $this->eventDispatcher = $composer->getEventDispatcher();
$this->executor = new ProcessExecutor($this->io);
$this->patches = array();
}
@@ -226,7 +231,9 @@ public function postInstall(PackageEvent $event) {
foreach ($this->patches[$package_name] as $description => $url) {
$this->io->write(' ' . $url . ' (' . $description. ')');
try {
+ $this->eventDispatcher->dispatch(NULL, new PatchEvent(PatchEvents::PRE_PATCH_APPLY, $package, $url, $description));
$this->getAndApplyPatch($downloader, $install_path, $url);
+ $this->eventDispatcher->dispatch(NULL, new PatchEvent(PatchEvents::POST_PATCH_APPLY, $package, $url, $description));
$extra['patches_applied'][$description] = $url;
}
catch (\Exception $e) {
diff --git a/tests/PatchEventTest.php b/tests/PatchEventTest.php
new file mode 100644
index 00000000..0f6adb7a
--- /dev/null
+++ b/tests/PatchEventTest.php
@@ -0,0 +1,39 @@
+assertEquals($event_name, $patch_event->getName());
+ $this->assertEquals($package, $patch_event->getPackage());
+ $this->assertEquals($url, $patch_event->getUrl());
+ $this->assertEquals($description, $patch_event->getDescription());
+ }
+
+ public function patchEventDataProvider() {
+ $prophecy = $this->prophesize('Composer\Package\PackageInterface');
+ $package = $prophecy->reveal();
+
+ return array(
+ array(PatchEvents::PRE_PATCH_APPLY, $package, 'https://www.drupal.org', 'A test patch'),
+ array(PatchEvents::POST_PATCH_APPLY, $package, 'https://www.drupal.org', 'A test patch'),
+ );
+ }
+
+}