Browse Source

Rename *-solve-dependencies to *-dependencies-solving

Jordi Boggiano 10 years ago
parent
commit
efcdb394d3

+ 2 - 0
doc/articles/scripts.md

@@ -26,6 +26,8 @@ Composer fires the following named events during its execution process:
 - **post-update-cmd**: occurs after the `update` command is executed.
 - **pre-status-cmd**: occurs before the `status` command is executed.
 - **post-status-cmd**: occurs after the `status` command is executed.
+- **pre-dependencies-solving**: occurs before the dependencies are resolved.
+- **post-dependencies-solving**: occurs after the dependencies are resolved.
 - **pre-package-install**: occurs before a package is installed.
 - **post-package-install**: occurs after a package is installed.
 - **pre-package-update**: occurs before a package is updated.

+ 4 - 4
src/Composer/Installer.php

@@ -261,10 +261,10 @@ class Installer
                         $request->install($link->getTarget(), $link->getConstraint());
                     }
 
-                    $this->eventDispatcher->dispatchInstallerEvent(InstallerEvents::PRE_SOLVE_DEPENDENCIES, $policy, $pool, $installedRepo, $request);
+                    $this->eventDispatcher->dispatchInstallerEvent(InstallerEvents::PRE_DEPENDENCIES_SOLVING, $policy, $pool, $installedRepo, $request);
                     $solver = new Solver($policy, $pool, $installedRepo);
                     $ops = $solver->solve($request);
-                    $this->eventDispatcher->dispatchInstallerEvent(InstallerEvents::POST_SOLVE_DEPENDENCIES, $policy, $pool, $installedRepo, $request, $ops);
+                    $this->eventDispatcher->dispatchInstallerEvent(InstallerEvents::POST_DEPENDENCIES_SOLVING, $policy, $pool, $installedRepo, $request, $ops);
                     foreach ($ops as $op) {
                         if ($op->getJobType() === 'uninstall') {
                             $devPackages[] = $op->getPackage();
@@ -467,11 +467,11 @@ class Installer
         $this->processDevPackages($localRepo, $pool, $policy, $repositories, $lockedRepository, $installFromLock, 'force-links');
 
         // solve dependencies
-        $this->eventDispatcher->dispatchInstallerEvent(InstallerEvents::PRE_SOLVE_DEPENDENCIES, $policy, $pool, $installedRepo, $request);
+        $this->eventDispatcher->dispatchInstallerEvent(InstallerEvents::PRE_DEPENDENCIES_SOLVING, $policy, $pool, $installedRepo, $request);
         $solver = new Solver($policy, $pool, $installedRepo);
         try {
             $operations = $solver->solve($request);
-            $this->eventDispatcher->dispatchInstallerEvent(InstallerEvents::POST_SOLVE_DEPENDENCIES, $policy, $pool, $installedRepo, $request, $operations);
+            $this->eventDispatcher->dispatchInstallerEvent(InstallerEvents::POST_DEPENDENCIES_SOLVING, $policy, $pool, $installedRepo, $request, $operations);
         } catch (SolverProblemsException $e) {
             $this->io->write('<error>Your requirements could not be resolved to an installable set of packages.</error>');
             $this->io->write($e->getMessage());

+ 4 - 4
src/Composer/Installer/InstallerEvents.php

@@ -20,7 +20,7 @@ namespace Composer\Installer;
 class InstallerEvents
 {
     /**
-     * The PRE_SOLVE_DEPENDENCIES event occurs as a installer begins
+     * The PRE_DEPENDENCIES_SOLVING event occurs as a installer begins
      * resolve operations.
      *
      * The event listener method receives a
@@ -28,10 +28,10 @@ class InstallerEvents
      *
      * @var string
      */
-    const PRE_SOLVE_DEPENDENCIES = 'pre-solve-dependencies';
+    const PRE_DEPENDENCIES_SOLVING = 'pre-dependencies-solving';
 
     /**
-     * The POST_SOLVE_DEPENDENCIES event occurs as a installer after
+     * The POST_DEPENDENCIES_SOLVING event occurs as a installer after
      * resolve operations.
      *
      * The event listener method receives a
@@ -39,5 +39,5 @@ class InstallerEvents
      *
      * @var string
      */
-    const POST_SOLVE_DEPENDENCIES = 'post-solve-dependencies';
+    const POST_DEPENDENCIES_SOLVING = 'post-dependencies-solving';
 }

+ 0 - 1
src/Composer/Script/ScriptEvents.php

@@ -182,5 +182,4 @@ class ScriptEvents
      * @var string
      */
     const POST_ARCHIVE_CMD = 'post-archive-cmd';
-
 }

+ 9 - 8
tests/Composer/Test/EventDispatcher/EventDispatcherTest.php

@@ -14,8 +14,9 @@ namespace Composer\Test\EventDispatcher;
 
 use Composer\EventDispatcher\Event;
 use Composer\EventDispatcher\EventDispatcher;
+use Composer\Installer\InstallerEvents;
 use Composer\TestCase;
-use Composer\Script;
+use Composer\Script\ScriptEvents;
 use Composer\Util\ProcessExecutor;
 
 class EventDispatcherTest extends TestCase
@@ -34,7 +35,7 @@ class EventDispatcherTest extends TestCase
             ->method('write')
             ->with('<error>Script Composer\Test\EventDispatcher\EventDispatcherTest::call handling the post-install-cmd event terminated with an exception</error>');
 
-        $dispatcher->dispatchCommandEvent("post-install-cmd", false);
+        $dispatcher->dispatchCommandEvent(ScriptEvents::POST_INSTALL_CMD, false);
     }
 
     /**
@@ -63,7 +64,7 @@ class EventDispatcherTest extends TestCase
             ->with($command)
             ->will($this->returnValue(0));
 
-        $dispatcher->dispatchCommandEvent("post-install-cmd", false);
+        $dispatcher->dispatchCommandEvent(ScriptEvents::POST_INSTALL_CMD, false);
     }
 
     public function testDispatcherCanExecuteCliAndPhpInSameEventScriptStack()
@@ -99,7 +100,7 @@ class EventDispatcherTest extends TestCase
             ->with('Composer\Test\EventDispatcher\EventDispatcherTest', 'someMethod')
             ->will($this->returnValue(true));
 
-        $dispatcher->dispatchCommandEvent("post-install-cmd", false);
+        $dispatcher->dispatchCommandEvent(ScriptEvents::POST_INSTALL_CMD, false);
     }
 
     private function getDispatcherStubForListenersTest($listeners, $io)
@@ -145,7 +146,7 @@ class EventDispatcherTest extends TestCase
             ->will($this->returnValue($listener));
 
         ob_start();
-        $dispatcher->dispatchCommandEvent("post-install-cmd", false);
+        $dispatcher->dispatchCommandEvent(ScriptEvents::POST_INSTALL_CMD, false);
         $this->assertEquals('foo', trim(ob_get_clean()));
     }
 
@@ -171,7 +172,7 @@ class EventDispatcherTest extends TestCase
             ->with($this->equalTo('<error>Script '.$code.' handling the post-install-cmd event returned with an error</error>'));
 
         $this->setExpectedException('RuntimeException');
-        $dispatcher->dispatchCommandEvent("post-install-cmd", false);
+        $dispatcher->dispatchCommandEvent(ScriptEvents::POST_INSTALL_CMD, false);
     }
 
     public function testDispatcherInstallerEvents()
@@ -195,8 +196,8 @@ class EventDispatcherTest extends TestCase
         $installedRepo = $this->getMockBuilder('Composer\Repository\CompositeRepository')->disableOriginalConstructor()->getMock();
         $request = $this->getMockBuilder('Composer\DependencyResolver\Request')->disableOriginalConstructor()->getMock();
 
-        $dispatcher->dispatchInstallerEvent("pre-solve-dependencies", $policy, $pool, $installedRepo, $request);
-        $dispatcher->dispatchInstallerEvent("post-solve-dependencies", $policy, $pool, $installedRepo, $request, array());
+        $dispatcher->dispatchInstallerEvent(InstallerEvents::PRE_DEPENDENCIES_SOLVING, $policy, $pool, $installedRepo, $request);
+        $dispatcher->dispatchInstallerEvent(InstallerEvents::POST_DEPENDENCIES_SOLVING, $policy, $pool, $installedRepo, $request, array());
     }
 
     public static function call()