From efcdb394d3ded5dfd7f358d7d025059b494ee406 Mon Sep 17 00:00:00 2001 From: Jordi Boggiano Date: Tue, 30 Sep 2014 16:26:55 +0100 Subject: [PATCH] Rename *-solve-dependencies to *-dependencies-solving --- doc/articles/scripts.md | 2 ++ src/Composer/Installer.php | 8 ++++---- src/Composer/Installer/InstallerEvents.php | 8 ++++---- src/Composer/Script/ScriptEvents.php | 1 - .../EventDispatcher/EventDispatcherTest.php | 17 +++++++++-------- 5 files changed, 19 insertions(+), 17 deletions(-) diff --git a/doc/articles/scripts.md b/doc/articles/scripts.md index adbf07f6b..6dece97e9 100644 --- a/doc/articles/scripts.md +++ b/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. diff --git a/src/Composer/Installer.php b/src/Composer/Installer.php index 7c252c5b0..2899e2bdb 100644 --- a/src/Composer/Installer.php +++ b/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('Your requirements could not be resolved to an installable set of packages.'); $this->io->write($e->getMessage()); diff --git a/src/Composer/Installer/InstallerEvents.php b/src/Composer/Installer/InstallerEvents.php index 5929b0964..e05c92587 100644 --- a/src/Composer/Installer/InstallerEvents.php +++ b/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'; } diff --git a/src/Composer/Script/ScriptEvents.php b/src/Composer/Script/ScriptEvents.php index 64ecbc8c5..616b2b97e 100644 --- a/src/Composer/Script/ScriptEvents.php +++ b/src/Composer/Script/ScriptEvents.php @@ -182,5 +182,4 @@ class ScriptEvents * @var string */ const POST_ARCHIVE_CMD = 'post-archive-cmd'; - } diff --git a/tests/Composer/Test/EventDispatcher/EventDispatcherTest.php b/tests/Composer/Test/EventDispatcher/EventDispatcherTest.php index a6cad7602..69e1de290 100644 --- a/tests/Composer/Test/EventDispatcher/EventDispatcherTest.php +++ b/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('Script Composer\Test\EventDispatcher\EventDispatcherTest::call handling the post-install-cmd event terminated with an exception'); - $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('Script '.$code.' handling the post-install-cmd event returned with an 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()