Ejemplo n.º 1
0
    /**
     * @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();
    }