/** * @param string $newPluginApiVersion * @param CompletePackage[] $plugins */ private function setPluginApiVersionWithPlugins($newPluginApiVersion, array $plugins = array()) { // reset the plugin manager's installed plugins $this->pm = $this->getMockBuilder('Composer\Plugin\PluginManager') ->setMethods(array('getPluginApiVersion')) ->setConstructorArgs(array($this->io, $this->composer)) ->getMock(); // mock the Plugin API version $this->pm->expects($this->any()) ->method('getPluginApiVersion') ->will($this->returnValue($newPluginApiVersion)); $plugApiInternalPackage = $this->getPackage( 'composer-plugin-api', $newPluginApiVersion, 'Composer\Package\CompletePackage' ); // Add the plugins to the repo along with the internal Plugin package on which they all rely. $this->repository ->expects($this->any()) ->method('getPackages') ->will($this->returnCallback(function () use ($plugApiInternalPackage, $plugins) { return array_merge(array($plugApiInternalPackage), $plugins); })); $this->pm->loadInstalledPlugins(); }
public function testCommandProviderCapability() { $this->repository->expects($this->exactly(2))->method('getPackages')->will($this->returnValue(array($this->packages[7]))); $installer = new PluginInstaller($this->io, $this->composer); $this->pm->loadInstalledPlugins(); $caps = $this->pm->getPluginCapabilities('Composer\\Plugin\\Capability\\CommandProvider', array('composer' => $this->composer, 'io' => $this->io)); $this->assertCount(1, $caps); $this->assertInstanceOf('Composer\\Plugin\\Capability\\CommandProvider', $caps[0]); $commands = $caps[0]->getCommands(); $this->assertCount(1, $commands); $this->assertInstanceOf('Composer\\Command\\BaseCommand', $commands[0]); }