Turn EventDispatcher into generic solution handling plugins as well

main
Nils Adermann 11 years ago
parent 2f43e9aefb
commit 3960edd64e

@ -13,12 +13,12 @@
namespace Composer\Autoload;
use Composer\Config;
use Composer\EventDispatcher\EventDispatcher;
use Composer\Installer\InstallationManager;
use Composer\Package\AliasPackage;
use Composer\Package\PackageInterface;
use Composer\Repository\InstalledRepositoryInterface;
use Composer\Util\Filesystem;
use Composer\Script\EventDispatcher;
use Composer\Script\ScriptEvents;
/**
@ -39,7 +39,7 @@ class AutoloadGenerator
public function dump(Config $config, InstalledRepositoryInterface $localRepo, PackageInterface $mainPackage, InstallationManager $installationManager, $targetDir, $scanPsr0Packages = false, $suffix = '')
{
$this->eventDispatcher->dispatch(ScriptEvents::PRE_AUTOLOAD_DUMP);
$this->eventDispatcher->dispatchScript(ScriptEvents::PRE_AUTOLOAD_DUMP);
$filesystem = new Filesystem();
$filesystem->ensureDirectoryExists($config->get('vendor-dir'));
@ -191,7 +191,7 @@ EOF;
fclose($targetLoader);
unset($sourceLoader, $targetLoader);
$this->eventDispatcher->dispatch(ScriptEvents::POST_AUTOLOAD_DUMP);
$this->eventDispatcher->dispatchScript(ScriptEvents::POST_AUTOLOAD_DUMP);
}
public function buildPackageMap(InstallationManager $installationManager, PackageInterface $mainPackage, array $packages)

@ -18,7 +18,7 @@ use Composer\Repository\RepositoryManager;
use Composer\Installer\InstallationManager;
use Composer\Plugin\PluginManager;
use Composer\Downloader\DownloadManager;
use Composer\Script\EventDispatcher;
use Composer\EventDispatcher\EventDispatcher;
use Composer\Autoload\AutoloadGenerator;
/**
@ -65,7 +65,7 @@ class Composer
private $config;
/**
* @var Script\EventDispatcher
* @var EventDispatcher\EventDispatcher
*/
private $eventDispatcher;
@ -188,7 +188,7 @@ class Composer
}
/**
* @param Script\EventDispatcher $eventDispatcher
* @param EventDispatcher\EventDispatcher $eventDispatcher
*/
public function setEventDispatcher(EventDispatcher $eventDispatcher)
{
@ -196,7 +196,7 @@ class Composer
}
/**
* @return Script\EventDispatcher
* @return EventDispatcher\EventDispatcher
*/
public function getEventDispatcher()
{

@ -17,6 +17,9 @@ use Composer\Cache;
use Composer\IO\IOInterface;
use Composer\Package\PackageInterface;
use Composer\Package\Version\VersionParser;
use Composer\Plugin\PluginEvents;
use Composer\Plugin\PrepareRemoteFilesystemEvent;
use Composer\EventDispatcher\EventDispatcher;
use Composer\Util\Filesystem;
use Composer\Util\GitHub;
use Composer\Util\RemoteFilesystem;
@ -27,6 +30,7 @@ use Composer\Util\RemoteFilesystem;
* @author Kirill chEbba Chebunin <iam@chebba.org>
* @author Jordi Boggiano <j.boggiano@seld.be>
* @author François Pluchino <francois.pluchino@opendisplay.com>
* @author Nils Adermann <naderman@naderman.de>
*/
class FileDownloader implements DownloaderInterface
{
@ -43,14 +47,16 @@ class FileDownloader implements DownloaderInterface
*
* @param IOInterface $io The IO instance
* @param Config $config The config
* @param EventDispatcher $eventDispatcher The event dispatcher
* @param Cache $cache Optional cache instance
* @param RemoteFilesystem $rfs The remote filesystem
* @param Filesystem $filesystem The filesystem
*/
public function __construct(IOInterface $io, Config $config, Cache $cache = null, RemoteFilesystem $rfs = null, Filesystem $filesystem = null)
public function __construct(IOInterface $io, Config $config, EventDispatcher $eventDispatcher = null, Cache $cache = null, RemoteFilesystem $rfs = null, Filesystem $filesystem = null)
{
$this->io = $io;
$this->config = $config;
$this->eventDispatcher = $eventDispatcher;
$this->rfs = $rfs ?: new RemoteFilesystem($io);
$this->filesystem = $filesystem ?: new Filesystem();
$this->cache = $cache;
@ -88,6 +94,12 @@ class FileDownloader implements DownloaderInterface
$processedUrl = $this->processUrl($package, $url);
$hostname = parse_url($processedUrl, PHP_URL_HOST);
$prepRfsEvent = new PrepareRemoteFilesystemEvent(PluginEvents::PREPARE_REMOTE_FILESYSTEM, $this->rfs, $processedUrl);
if ($this->eventDispatcher) {
$this->eventDispatcher->dispatch($prepRfsEvent->getName(), $prepRfsEvent);
}
$rfs = $prepRfsEvent->getRemoteFilesystem();
if (strpos($hostname, '.github.com') === (strlen($hostname) - 11)) {
$hostname = 'github.com';
}
@ -103,7 +115,7 @@ class FileDownloader implements DownloaderInterface
$retries = 3;
while ($retries--) {
try {
$this->rfs->copy($hostname, $processedUrl, $fileName, $this->outputProgress);
$rfs->copy($hostname, $processedUrl, $fileName, $this->outputProgress);
break;
} catch (TransportException $e) {
// if we got an http response with a proper code, then requesting again will probably not help, abort
@ -124,15 +136,18 @@ class FileDownloader implements DownloaderInterface
$this->io->write(' Loading from cache');
}
} catch (TransportException $e) {
if (in_array($e->getCode(), array(404, 403)) && 'github.com' === $hostname && !$this->io->hasAuthentication($hostname)) {
if (!in_array($e->getCode(), array(404, 403, 412))) {
throw $e;
}
if ('github.com' === $hostname && !$this->io->hasAuthentication($hostname)) {
$message = "\n".'Could not fetch '.$processedUrl.', enter your GitHub credentials '.($e->getCode() === 404 ? 'to access private repos' : 'to go over the API rate limit');
$gitHubUtil = new GitHub($this->io, $this->config, null, $this->rfs);
$gitHubUtil = new GitHub($this->io, $this->config, null, $rfs);
if (!$gitHubUtil->authorizeOAuth($hostname)
&& (!$this->io->isInteractive() || !$gitHubUtil->authorizeOAuthInteractively($hostname, $message))
) {
throw $e;
}
$this->rfs->copy($hostname, $processedUrl, $fileName, $this->outputProgress);
$rfs->copy($hostname, $processedUrl, $fileName, $this->outputProgress);
} else {
throw $e;
}

@ -14,6 +14,7 @@ namespace Composer\Downloader;
use Composer\Config;
use Composer\Cache;
use Composer\EventDispatcher\EventDispatcher;
use Composer\Util\ProcessExecutor;
use Composer\IO\IOInterface;
use ZipArchive;
@ -25,10 +26,10 @@ class ZipDownloader extends ArchiveDownloader
{
protected $process;
public function __construct(IOInterface $io, Config $config, Cache $cache = null, ProcessExecutor $process = null)
public function __construct(IOInterface $io, Config $config, EventDispatcher $eventDispatcher = null, Cache $cache = null, ProcessExecutor $process = null)
{
$this->process = $process ?: new ProcessExecutor($io);
parent::__construct($io, $config, $cache);
parent::__construct($io, $config, $eventDispatcher, $cache);
}
protected function extract($file, $path)

@ -0,0 +1,72 @@
<?php
/*
* This file is part of Composer.
*
* (c) Nils Adermann <naderman@naderman.de>
* Jordi Boggiano <j.boggiano@seld.be>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Composer\EventDispatcher;
use Composer\Composer;
use Composer\IO\IOInterface;
/**
* The base event class
*
* @author Nils Adermann <naderman@naderman.de>
*/
class Event
{
/**
* @var string This event's name
*/
protected $name;
/**
* @var boolean Whether the event should not be passed to more listeners
*/
private $propagationStopped = false;
/**
* Constructor.
*
* @param string $name The event name
*/
public function __construct($name)
{
$this->name = $name;
}
/**
* Returns the event's name.
*
* @return string The event name
*/
public function getName()
{
return $this->name;
}
/**
* Checks if stopPropagation has been called
*
* @return boolean Whether propagation has been stopped
*/
public function isPropagationStopped()
{
return $this->propagationStopped;
}
/**
* Prevents the event from being passed to further listeners
*/
public function stopPropagation()
{
$this->propagationStopped = true;
}
}

@ -10,11 +10,14 @@
* file that was distributed with this source code.
*/
namespace Composer\Script;
namespace Composer\EventDispatcher;
use Composer\IO\IOInterface;
use Composer\Composer;
use Composer\DependencyResolver\Operation\OperationInterface;
use Composer\Script;
use Composer\Script\CommandEvent;
use Composer\Script\PackageEvent;
use Composer\Util\ProcessExecutor;
/**
@ -28,6 +31,7 @@ use Composer\Util\ProcessExecutor;
*
* @author François Pluchino <francois.pluchino@opendisplay.com>
* @author Jordi Boggiano <j.boggiano@seld.be>
* @author Nils Adermann <naderman@naderman.de>
*/
class EventDispatcher
{
@ -50,16 +54,31 @@ class EventDispatcher
$this->process = $process ?: new ProcessExecutor($io);
}
/**
* Dispatch an event
*
* @param string $eventName An event name
* @param Event $event
*/
public function dispatch($eventName, Event $event = null)
{
if (null == $event) {
$event = new Event($eventName);
}
$this->doDispatch($event);
}
/**
* Dispatch a script event.
*
* @param string $eventName The constant in ScriptEvents
* @param Event $event
*/
public function dispatch($eventName, Event $event = null)
public function dispatchScript($eventName, Script\Event $event = null)
{
if (null == $event) {
$event = new Event($eventName, $this->composer, $this->io);
$event = new Script\Event($eventName, $this->composer, $this->io);
}
$this->doDispatch($event);
@ -100,7 +119,9 @@ class EventDispatcher
$listeners = $this->getListeners($event);
foreach ($listeners as $callable) {
if ($this->isPhpScript($callable)) {
if ((is_array($callable) && $is_callable($callable)) || $callable instanceof Closure) {
$callable($event);
} elseif ($this->isPhpScript($callable)) {
$className = substr($callable, 0, strpos($callable, '::'));
$methodName = substr($callable, strpos($callable, '::') + 2);
@ -127,6 +148,10 @@ class EventDispatcher
throw new \RuntimeException('Error Output: '.$this->process->getErrorOutput(), $exitCode);
}
}
if ($event->isPropagationStopped()) {
break;
}
}
}
@ -140,11 +165,46 @@ class EventDispatcher
$className::$methodName($event);
}
protected function addListener($eventName, $listener, $priority = 0)
{
$this->listeners[$eventName][$priority][] = $listener;
}
protected function addSubscriber($subscriber)
{
foreach ($subscriber->getSubscribedEvents() as $eventName => $params) {
if (is_string($params)) {
$this->addListener($eventName, array($subscriber, $params));
} elseif (is_string($params[0])) {
$this->addListener($eventName, array($subscriber, $params[0]), isset($params[1]) ? $params[1] : 0);
} else {
foreach ($params as $listener) {
$this->addListener($eventName, array($subscriber, $listener[0]), isset($listener[1]) ? $listener[1] : 0);
}
}
}
}
protected function getListeners(Event $event)
{
$scriptListeners = $this->getScriptListeners($event);
if (!isset($this->listeners[$event->getName()][0])) {
$this->listeners[$event->getName()][0] = array();
}
krsort($this->listeners[$event->getName()]);
$listeners = $this->listeners;
$listeners[$event->getName()][0] = array_merge($listeners[$event->getName()][0], $scriptListeners);
return call_user_func_array('array_merge', $listeners[$event->getName()]);
}
/**
* @param Event $event Event object
* @return array Listeners
*/
protected function getListeners(Event $event)
protected function getScriptListeners(Event $event)
{
$package = $this->composer->getPackage();
$scripts = $package->getScripts();

@ -21,7 +21,7 @@ use Composer\Repository\RepositoryManager;
use Composer\Util\ProcessExecutor;
use Composer\Util\RemoteFilesystem;
use Symfony\Component\Console\Formatter\OutputFormatterStyle;
use Composer\Script\EventDispatcher;
use Composer\EventDispatcher\EventDispatcher;
use Composer\Autoload\AutoloadGenerator;
use Composer\Package\Version\VersionParser;
@ -227,9 +227,6 @@ class Factory
$loader = new Package\Loader\RootPackageLoader($rm, $config, $parser, new ProcessExecutor($io));
$package = $loader->load($localConfig);
// initialize download manager
$dm = $this->createDownloadManager($io, $config);
// initialize installation manager
$im = $this->createInstallationManager();
@ -238,11 +235,15 @@ class Factory
$composer->setConfig($config);
$composer->setPackage($package);
$composer->setRepositoryManager($rm);
$composer->setDownloadManager($dm);
$composer->setInstallationManager($im);
// initialize event dispatcher
$dispatcher = new EventDispatcher($composer, $io);
// initialize download manager
$dm = $this->createDownloadManager($io, $config, $dispatcher);
$composer->setDownloadManager($dm);
$composer->setEventDispatcher($dispatcher);
// initialize autoload generator
@ -304,9 +305,10 @@ class Factory
/**
* @param IO\IOInterface $io
* @param Config $config
* @param EventDispatcher $eventDispatcher
* @return Downloader\DownloadManager
*/
public function createDownloadManager(IOInterface $io, Config $config)
public function createDownloadManager(IOInterface $io, Config $config, EventDispatcher $eventDispatcher = null)
{
$cache = null;
if ($config->get('cache-files-ttl') > 0) {
@ -330,10 +332,10 @@ class Factory
$dm->setDownloader('git', new Downloader\GitDownloader($io, $config));
$dm->setDownloader('svn', new Downloader\SvnDownloader($io, $config));
$dm->setDownloader('hg', new Downloader\HgDownloader($io, $config));
$dm->setDownloader('zip', new Downloader\ZipDownloader($io, $config, $cache));
$dm->setDownloader('tar', new Downloader\TarDownloader($io, $config, $cache));
$dm->setDownloader('phar', new Downloader\PharDownloader($io, $config, $cache));
$dm->setDownloader('file', new Downloader\FileDownloader($io, $config, $cache));
$dm->setDownloader('zip', new Downloader\ZipDownloader($io, $config, $eventDispatcher, $cache));
$dm->setDownloader('tar', new Downloader\TarDownloader($io, $config, $eventDispatcher, $cache));
$dm->setDownloader('phar', new Downloader\PharDownloader($io, $config, $eventDispatcher, $cache));
$dm->setDownloader('file', new Downloader\FileDownloader($io, $config, $eventDispatcher, $cache));
return $dm;
}

@ -24,6 +24,7 @@ use Composer\DependencyResolver\Rule;
use Composer\DependencyResolver\Solver;
use Composer\DependencyResolver\SolverProblemsException;
use Composer\Downloader\DownloadManager;
use Composer\EventDispatcher\EventDispatcher;
use Composer\Installer\InstallationManager;
use Composer\Config;
use Composer\Installer\NoopInstaller;
@ -41,7 +42,6 @@ use Composer\Repository\InstalledFilesystemRepository;
use Composer\Repository\PlatformRepository;
use Composer\Repository\RepositoryInterface;
use Composer\Repository\RepositoryManager;
use Composer\Script\EventDispatcher;
use Composer\Script\ScriptEvents;
/**

@ -0,0 +1,31 @@
<?php
/*
* This file is part of Composer.
*
* (c) Nils Adermann <naderman@naderman.de>
* Jordi Boggiano <j.boggiano@seld.be>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Composer\Plugin;
/**
* The Plugin Events.
*
* @author Nils Adermann <naderman@naderman.de>
*/
class PluginEvents
{
/**
* The PREPARE_REMOTE_FILESYSTEM event occurs before downloading a file
*
* The event listener method receives a
* Composer\Plugin\PrepareRemoteFilesystemEvent instance.
*
* @var string
*/
const PREPARE_REMOTE_FILESYSTEM = 'prepare-remote-filesystem';
}

@ -64,6 +64,10 @@ class PluginManager
{
$this->plugins[] = $plugin;
$plugin->activate($this->composer);
if ($plugin instanceof \Symfony\Component\EventDispatcher\EventSubscriberInterface) {
$this->composer->getPluginEventDispatcher()->addSubscriber($plugin);
}
}
public function getPlugins()

@ -0,0 +1,80 @@
<?php
/*
* This file is part of Composer.
*
* (c) Nils Adermann <naderman@naderman.de>
* Jordi Boggiano <j.boggiano@seld.be>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Composer\Plugin;
use Composer\Composer;
use Composer\IO\IOInterface;
use Composer\EventDispatcher\Event;
use Composer\Util\RemoteFilesystem;
/**
* The Prepare Remote Filesystem Event.
*
* @author Nils Adermann <naderman@naderman.de>
*/
class PrepareRemoteFilesystemEvent extends Event
{
/**
* @var RemoteFilesystem
*/
private $rfs;
/**
* @var string
*/
private $processedUrl;
/**
* Constructor.
*
* @param string $name The event name
* @param Composer $composer The composer object
* @param IOInterface $io The IOInterface object
* @param boolean $devMode Whether or not we are in dev mode
* @param OperationInterface $operation The operation object
*/
public function __construct($name, RemoteFilesystem $rfs, $processedUrl)
{
parent::__construct($name);
$this->rfs = $rfs;
$this->processedUrl = $processedUrl;
}
/**
* Returns the remote filesystem
*
* @return OperationInterface
*/
public function getRemoteFilesystem()
{
return $this->rfs;
}
/**
* Sets the remote filesystem
*/
public function setRemoteFilesystem(RemoteFilesystem $rfs)
{
$this->rfs = $rfs;
}
/**
* Retrieves the processed URL this remote filesystem will be used for
*
* @return string
*/
public function getProcessedUrl()
{
return $this->processedUrl;
}
}

@ -16,17 +16,13 @@ use Composer\Composer;
use Composer\IO\IOInterface;
/**
* The base event class
* The script event class
*
* @author François Pluchino <francois.pluchino@opendisplay.com>
* @author Nils Adermann <naderman@naderman.de>
*/
class Event
class Event extends \Composer\EventDispatcher\Event
{
/**
* @var string This event's name
*/
private $name;
/**
* @var Composer The composer instance
*/
@ -52,22 +48,12 @@ class Event
*/
public function __construct($name, Composer $composer, IOInterface $io, $devMode = false)
{
$this->name = $name;
parent::__construct($name);
$this->composer = $composer;
$this->io = $io;
$this->devMode = $devMode;
}
/**
* Returns the event's name.
*
* @return string The event name
*/
public function getName()
{
return $this->name;
}
/**
* Returns the composer instance.
*

@ -72,7 +72,7 @@ class AutoloadGeneratorTest extends TestCase
}));
$this->repository = $this->getMock('Composer\Repository\InstalledRepositoryInterface');
$this->eventDispatcher = $this->getMockBuilder('Composer\Script\EventDispatcher')
$this->eventDispatcher = $this->getMockBuilder('Composer\EventDispatcher\EventDispatcher')
->disableOriginalConstructor()
->getMock();
@ -626,12 +626,12 @@ EOF;
{
$this->eventDispatcher
->expects($this->at(0))
->method('dispatch')
->method('dispatchScript')
->with(ScriptEvents::PRE_AUTOLOAD_DUMP, false);
$this->eventDispatcher
->expects($this->at(1))
->method('dispatch')
->method('dispatchScript')
->with(ScriptEvents::POST_AUTOLOAD_DUMP, false);
$package = new Package('a', '1.0', '1.0');

@ -23,7 +23,7 @@ class FileDownloaderTest extends \PHPUnit_Framework_TestCase
$config = $config ?: $this->getMock('Composer\Config');
$rfs = $rfs ?: $this->getMockBuilder('Composer\Util\RemoteFilesystem')->disableOriginalConstructor()->getMock();
return new FileDownloader($io, $config, null, $rfs);
return new FileDownloader($io, $config, null, null, $rfs);
}
/**

@ -10,11 +10,12 @@
* file that was distributed with this source code.
*/
namespace Composer\Test\Script;
namespace Composer\Test\EventDispatcher;
use Composer\EventDispatcher\Event;
use Composer\EventDispatcher\EventDispatcher;
use Composer\Test\TestCase;
use Composer\Script\Event;
use Composer\Script\EventDispatcher;
use Composer\Script;
use Composer\Util\ProcessExecutor;
class EventDispatcherTest extends TestCase
@ -26,12 +27,12 @@ class EventDispatcherTest extends TestCase
{
$io = $this->getMock('Composer\IO\IOInterface');
$dispatcher = $this->getDispatcherStubForListenersTest(array(
"Composer\Test\Script\EventDispatcherTest::call"
"Composer\Test\EventDispatcher\EventDispatcherTest::call"
), $io);
$io->expects($this->once())
->method('write')
->with('<error>Script Composer\Test\Script\EventDispatcherTest::call handling the post-install-cmd event terminated with an exception</error>');
->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);
}
@ -43,7 +44,7 @@ class EventDispatcherTest extends TestCase
public function testDispatcherCanExecuteSingleCommandLineScript($command)
{
$process = $this->getMock('Composer\Util\ProcessExecutor');
$dispatcher = $this->getMockBuilder('Composer\Script\EventDispatcher')
$dispatcher = $this->getMockBuilder('Composer\EventDispatcher\EventDispatcher')
->setConstructorArgs(array(
$this->getMock('Composer\Composer'),
$this->getMock('Composer\IO\IOInterface'),
@ -68,7 +69,7 @@ class EventDispatcherTest extends TestCase
public function testDispatcherCanExecuteCliAndPhpInSameEventScriptStack()
{
$process = $this->getMock('Composer\Util\ProcessExecutor');
$dispatcher = $this->getMockBuilder('Composer\Script\EventDispatcher')
$dispatcher = $this->getMockBuilder('Composer\EventDispatcher\EventDispatcher')
->setConstructorArgs(array(
$this->getMock('Composer\Composer'),
$this->getMock('Composer\IO\IOInterface'),
@ -86,7 +87,7 @@ class EventDispatcherTest extends TestCase
$listeners = array(
'echo -n foo',
'Composer\\Test\\Script\\EventDispatcherTest::someMethod',
'Composer\\Test\\EventDispatcher\\EventDispatcherTest::someMethod',
'echo -n bar',
);
$dispatcher->expects($this->atLeastOnce())
@ -95,7 +96,7 @@ class EventDispatcherTest extends TestCase
$dispatcher->expects($this->once())
->method('executeEventPhpScript')
->with('Composer\Test\Script\EventDispatcherTest', 'someMethod')
->with('Composer\Test\EventDispatcher\EventDispatcherTest', 'someMethod')
->will($this->returnValue(true));
$dispatcher->dispatchCommandEvent("post-install-cmd", false);
@ -103,7 +104,7 @@ class EventDispatcherTest extends TestCase
private function getDispatcherStubForListenersTest($listeners, $io)
{
$dispatcher = $this->getMockBuilder('Composer\Script\EventDispatcher')
$dispatcher = $this->getMockBuilder('Composer\EventDispatcher\EventDispatcher')
->setConstructorArgs(array(
$this->getMock('Composer\Composer'),
$io,
@ -129,7 +130,7 @@ class EventDispatcherTest extends TestCase
public function testDispatcherOutputsCommands()
{
$dispatcher = $this->getMockBuilder('Composer\Script\EventDispatcher')
$dispatcher = $this->getMockBuilder('Composer\EventDispatcher\EventDispatcher')
->setConstructorArgs(array(
$this->getMock('Composer\Composer'),
$this->getMock('Composer\IO\IOInterface'),
@ -150,7 +151,7 @@ class EventDispatcherTest extends TestCase
public function testDispatcherOutputsErrorOnFailedCommand()
{
$dispatcher = $this->getMockBuilder('Composer\Script\EventDispatcher')
$dispatcher = $this->getMockBuilder('Composer\EventDispatcher\EventDispatcher')
->setConstructorArgs(array(
$this->getMock('Composer\Composer'),
$io = $this->getMock('Composer\IO\IOInterface'),

@ -66,7 +66,7 @@ class InstallerTest extends TestCase
$locker = $this->getMockBuilder('Composer\Package\Locker')->disableOriginalConstructor()->getMock();
$installationManager = new InstallationManagerMock();
$eventDispatcher = $this->getMockBuilder('Composer\Script\EventDispatcher')->disableOriginalConstructor()->getMock();
$eventDispatcher = $this->getMockBuilder('Composer\EventDispatcher\EventDispatcher')->disableOriginalConstructor()->getMock();
$autoloadGenerator = $this->getMockBuilder('Composer\Autoload\AutoloadGenerator')->disableOriginalConstructor()->getMock();
$installer = new Installer($io, $config, clone $rootPackage, $downloadManager, $repositoryManager, $locker, $installationManager, $eventDispatcher, $autoloadGenerator);
@ -189,7 +189,7 @@ class InstallerTest extends TestCase
$locker = new Locker($io, $lockJsonMock, $repositoryManager, $composer->getInstallationManager(), md5(json_encode($composerConfig)));
$composer->setLocker($locker);
$eventDispatcher = $this->getMockBuilder('Composer\Script\EventDispatcher')->disableOriginalConstructor()->getMock();
$eventDispatcher = $this->getMockBuilder('Composer\EventDispatcher\EventDispatcher')->disableOriginalConstructor()->getMock();
$autoloadGenerator = $this->getMock('Composer\Autoload\AutoloadGenerator', array(), array($eventDispatcher));
$composer->setAutoloadGenerator($autoloadGenerator);
$composer->setEventDispatcher($eventDispatcher);

@ -53,7 +53,7 @@ class PluginInstallerTest extends \PHPUnit_Framework_TestCase
$this->io = $this->getMock('Composer\IO\IOInterface');
$dispatcher = $this->getMockBuilder('Composer\Script\EventDispatcher')->disableOriginalConstructor()->getMock();
$dispatcher = $this->getMockBuilder('Composer\EventDispatcher\EventDispatcher')->disableOriginalConstructor()->getMock();
$this->autoloadGenerator = new AutoloadGenerator($dispatcher);
$this->composer = new Composer();

Loading…
Cancel
Save