/** * @return Config */ public static function createConfig() { // load main Composer configuration if (!($home = getenv('COMPOSER_HOME'))) { if (defined('PHP_WINDOWS_VERSION_MAJOR')) { $home = getenv('APPDATA') . '/Composer'; } else { $home = getenv('HOME') . '/.composer'; } } // Protect directory against web access if (!file_exists($home . '/.htaccess')) { if (!is_dir($home)) { @mkdir($home, 0777, true); } @file_put_contents($home . '/.htaccess', 'Deny from all'); } $config = new Config(); $file = new JsonFile($home . '/config.json'); if ($file->exists()) { $config->merge($file->read()); } // add home dir to the config $config->merge(array('config' => array('home' => $home))); return $config; }
public function testOverrideGithubProtocols() { $config = new Config(false); $config->merge(array('config' => array('github-protocols' => array('https', 'git')))); $config->merge(array('config' => array('github-protocols' => array('https')))); $this->assertEquals(array('https'), $config->get('github-protocols')); }
public static function createConfig(IOInterface $io = null, $cwd = null) { $cwd = $cwd ?: getcwd(); $home = self::getHomeDir(); $cacheDir = self::getCacheDir($home); foreach (array($home, $cacheDir) as $dir) { if (!file_exists($dir . '/.htaccess')) { if (!is_dir($dir)) { @mkdir($dir, 0777, true); } @file_put_contents($dir . '/.htaccess', 'Deny from all'); } } $config = new Config(true, $cwd); $config->merge(array('config' => array('home' => $home, 'cache-dir' => $cacheDir))); $file = new JsonFile($config->get('home') . '/config.json'); if ($file->exists()) { if ($io && $io->isDebug()) { $io->writeError('Loading config file ' . $file->getPath()); } $config->merge($file->read()); } $config->setConfigSource(new JsonConfigSource($file)); $file = new JsonFile($config->get('home') . '/auth.json'); if ($file->exists()) { if ($io && $io->isDebug()) { $io->writeError('Loading config file ' . $file->getPath()); } $config->merge(array('config' => $file->read())); } $config->setAuthConfigSource(new JsonConfigSource($file, true)); return $config; }
protected function setUp() { $this->fs = new Filesystem(); $this->composer = new Composer(); $this->config = new Config(); $this->composer->setConfig($this->config); $this->vendorDir = realpath(sys_get_temp_dir()) . DIRECTORY_SEPARATOR . 'composer-test-vendor'; $this->ensureDirectoryExistsAndClear($this->vendorDir); $this->binDir = realpath(sys_get_temp_dir()) . DIRECTORY_SEPARATOR . 'composer-test-bin'; $this->ensureDirectoryExistsAndClear($this->binDir); $this->config->merge(array('config' => array('vendor-dir' => $this->vendorDir, 'bin-dir' => $this->binDir))); $this->dm = $this->getMockBuilder('Composer\\Downloader\\DownloadManager')->disableOriginalConstructor()->getMock(); /* @var DownloadManager $dm */ $dm = $this->dm; $this->composer->setDownloadManager($dm); $this->repository = $this->getMock('Composer\\Repository\\InstalledRepositoryInterface'); $this->io = $this->getMock('Composer\\IO\\IOInterface'); $this->type = $this->getMock('Fxp\\Composer\\AssetPlugin\\Type\\AssetTypeInterface'); $this->type->expects($this->any())->method('getName')->will($this->returnValue('foo')); $this->type->expects($this->any())->method('getComposerVendorName')->will($this->returnValue('foo-asset')); $this->type->expects($this->any())->method('getComposerType')->will($this->returnValue('foo-asset-library')); $this->type->expects($this->any())->method('getFilename')->will($this->returnValue('foo.json')); $this->type->expects($this->any())->method('getVersionConverter')->will($this->returnValue($this->getMock('Fxp\\Composer\\AssetPlugin\\Converter\\VersionConverterInterface'))); $this->type->expects($this->any())->method('getPackageConverter')->will($this->returnValue($this->getMock('Fxp\\Composer\\AssetPlugin\\Converter\\PackageConverterInterface'))); }
/** * @dataProvider dataAddPackagistRepository */ public function testAddPackagistRepository($expected, $localConfig, $systemConfig = null) { $config = new Config(); if ($systemConfig) { $config->merge(array('repositories' => $systemConfig)); } $config->merge(array('repositories' => $localConfig)); $this->assertEquals($expected, $config->getRepositories()); }
/** * {@inheritdoc} */ protected function setUp() { // Run through the Library Installer Test set up. parent::setUp(); // Also be sure to set up the Component directory. $this->componentDir = realpath(sys_get_temp_dir()) . DIRECTORY_SEPARATOR . 'composer-test-component'; $this->ensureDirectoryExistsAndClear($this->componentDir); // Merge the component-dir setting in so that it applies correctly. $this->config->merge(array('config' => array('component-dir' => $this->componentDir))); }
public function setUp() { $this->config = new Config(); $this->config->merge(array( 'config' => array( 'home' => sys_get_temp_dir() . '/composer-test', 'cache-repo-dir' => sys_get_temp_dir() . '/composer-test-cache', ), )); }
/** * {@inheritdoc} */ protected function setUp() { $this->localConfigPath = realpath(__DIR__ . '/../fixtures/local'); $this->globalConfigPath = realpath(__DIR__ . '/../fixtures/home'); $this->config = new Config(false, $this->localConfigPath); $this->config->merge(['config' => ['home' => $this->globalConfigPath]]); $package = new RootPackage('my/project', '1.0.0', '1.0.0'); $package->setExtra(['my-local-config' => ['foo' => 'bar']]); $this->composer = new Composer(); $this->composer->setConfig($this->config); $this->composer->setPackage($package); $this->SUT = new ConfigLocator($this->composer); }
protected function setUp() { $this->tempDir = TestUtil::makeTempDir('puli-composer-plugin', __CLASS__); $filesystem = new Filesystem(); $filesystem->mirror(__DIR__ . '/Fixtures/root', $this->tempDir); $this->io = $this->getMock('Composer\\IO\\IOInterface'); $this->config = new Config(false, $this->tempDir); $this->config->merge(array('config' => array('vendor-dir' => 'the-vendor'))); $this->installationManager = $this->getMockBuilder('Composer\\Installer\\InstallationManager')->disableOriginalConstructor()->getMock(); $this->installationManager->expects($this->any())->method('getInstallPath')->will($this->returnCallback(array($this, 'getInstallPath'))); $this->rootPackage = new RootPackage('vendor/root', '1.0', '1.0'); $this->rootPackage->setRequires(array('vendor/package1' => new Link('vendor/root', 'vendor/package1'), 'vendor/package2' => new Link('vendor/root', 'vendor/package2'))); $this->localRepository = new TestLocalRepository(array(new Package('vendor/package1', '1.0', '1.0'), new Package('vendor/package2', '1.0', '1.0'))); $this->repositoryManager = new RepositoryManager($this->io, $this->config); $this->repositoryManager->setLocalRepository($this->localRepository); $this->installPaths = array(); $this->composer = new Composer(); $this->composer->setRepositoryManager($this->repositoryManager); $this->composer->setInstallationManager($this->installationManager); $this->composer->setConfig($this->config); $this->composer->setPackage($this->rootPackage); $this->puliRunner = $this->getMockBuilder('Puli\\ComposerPlugin\\PuliRunner')->disableOriginalConstructor()->getMock(); $this->previousWd = getcwd(); chdir($this->tempDir); $this->plugin = new PuliPlugin($this->puliRunner); }
protected function setUp() { while (false === mkdir($this->tempDir = sys_get_temp_dir() . '/puli-plugin/PuliPluginTest_root' . rand(10000, 99999), 0777, true)) { } $filesystem = new Filesystem(); $filesystem->mirror(__DIR__ . '/Fixtures/root', $this->tempDir); $this->io = $this->getMock('Composer\\IO\\IOInterface'); $this->config = new Config(false, $this->tempDir); $this->config->merge(array('config' => array('vendor-dir' => 'the-vendor'))); $this->installationManager = $this->getMockBuilder('Composer\\Installer\\InstallationManager')->disableOriginalConstructor()->getMock(); $this->installationManager->expects($this->any())->method('getInstallPath')->will($this->returnCallback(array($this, 'getInstallPath'))); $this->rootPackage = new RootPackage('vendor/root', '1.0', '1.0'); $this->localRepository = new TestLocalRepository(array(new Package('vendor/package1', '1.0', '1.0'), new Package('vendor/package2', '1.0', '1.0'))); $this->repositoryManager = new RepositoryManager($this->io, $this->config); $this->repositoryManager->setLocalRepository($this->localRepository); $this->installPaths = array(); $this->composer = new Composer(); $this->composer->setRepositoryManager($this->repositoryManager); $this->composer->setInstallationManager($this->installationManager); $this->composer->setConfig($this->config); $this->composer->setPackage($this->rootPackage); $this->puliRunner = $this->getMockBuilder('Puli\\ComposerPlugin\\PuliRunner')->disableOriginalConstructor()->getMock(); $this->previousWd = getcwd(); chdir($this->tempDir); $this->plugin = new PuliPlugin($this->puliRunner); }
protected function setUp() { /* @var IOInterface $io */ $io = $this->getMock('Composer\IO\IOInterface'); $config = new Config(); $config->merge(array( 'config' => array( 'home' => sys_get_temp_dir() . '/composer-test', 'cache-repo-dir' => sys_get_temp_dir() . '/composer-test-cache-repo', ), )); $rm = new RepositoryManager($io, $config); $rm->setRepositoryClass($this->getType() . '-vcs', 'Fxp\Composer\AssetPlugin\Tests\Fixtures\Repository\MockAssetRepository'); $repoConfig = array( 'repository-manager' => $rm, 'asset-options' => array( 'searchable' => true, ), ); $this->io = $io; $this->config = $config; $this->rm = $rm; $this->registry = $this->getRegistry($repoConfig, $io, $config); $this->pool = $this->getMock('Composer\DependencyResolver\Pool'); }
protected function getConfig() { $config = new Config(); $settings = array('config' => array('home' => $this->testPath)); $config->merge($settings); return $config; }
/** * Mock the controller. * * @return \PHPUnit_Framework_MockObject_MockObject|PackageController */ private function prepareController() { $manager = $this->getMockBuilder(RepositoryManager::class)->disableOriginalConstructor()->setMethods(null)->getMock(); $config = new Config(); $config->merge(array('repositories' => array('packagist' => false))); $loader = new RootPackageLoader($manager, $config); $rootPackage = $loader->load(json_decode($this->readFixture('composer.json'), true)); $loader = new ArrayLoader(); $json = json_decode($this->readFixture('installed.json'), true); $packages = []; foreach ($json as $package) { $packages[] = $loader->load($package); } $manager->setLocalRepository(new WritableArrayRepository($packages)); $composer = $this->getMockBuilder(Composer::class)->setMethods(['getPackage', 'getRepositoryManager'])->getMock(); $composer->method('getPackage')->willReturn($rootPackage); $composer->method('getRepositoryManager')->willReturn($manager); $controller = $this->getMockBuilder(PackageController::class)->setMethods(['getComposer', 'forward'])->getMock(); $controller->method('getComposer')->willReturn($composer); $home = $this->getMock(HomePathDeterminator::class, ['homeDir']); $home->method('homeDir')->willReturn($this->getTempDir()); $composerJson = $this->provideFixture('composer.json'); $this->provideFixture('composer.lock'); $this->provideFixture('installed.json', 'vendor/composer/installed.json'); $container = new Container(); $container->set('tenside.home', $home); $container->set('tenside.composer_json', new ComposerJson($composerJson)); /** @var PackageController $controller */ $controller->setContainer($container); return $controller; }
/** * Search for a given package version. * * Usage examples : Composition::has('php', '5.3.*') // PHP version * Composition::has('ext-memcache') // PHP extension * Composition::has('vendor/package', '>2.1') // Package version * * @param type $packageName The package name * @param type $prettyString An optional version constraint * * @return boolean Wether or not the package has been found. */ public static function has($packageName, $prettyString = '*') { if (null === self::$pool) { if (null === self::$rootDir) { self::$rootDir = getcwd(); if (!file_exists(self::$rootDir . '/composer.json')) { throw new \RuntimeException('Unable to guess the project root dir, please specify it manually using the Composition::setRootDir method.'); } } $minimumStability = 'dev'; $config = new Config(); $file = new JsonFile(self::$rootDir . '/composer.json'); if ($file->exists()) { $projectConfig = $file->read(); $config->merge($projectConfig); if (isset($projectConfig['minimum-stability'])) { $minimumStability = $projectConfig['minimum-stability']; } } $vendorDir = self::$rootDir . '/' . $config->get('vendor-dir'); $pool = new Pool($minimumStability); $pool->addRepository(new PlatformRepository()); $pool->addRepository(new InstalledFilesystemRepository(new JsonFile($vendorDir . '/composer/installed.json'))); $pool->addRepository(new InstalledFilesystemRepository(new JsonFile($vendorDir . '/composer/installed_dev.json'))); self::$pool = $pool; } $parser = new VersionParser(); $constraint = $parser->parseConstraints($prettyString); $packages = self::$pool->whatProvides($packageName, $constraint); return empty($packages) ? false : true; }
/** * @inheritdoc */ protected function setUp() { parent::setUp(); $this->fs = new SymlinkFilesystem(); $this->composer = new Composer(); $this->config = new Config(); $this->composer->setConfig($this->config); $this->vendorDir = realpath(sys_get_temp_dir()) . DIRECTORY_SEPARATOR . 'composer-test-vendor'; $this->ensureDirectoryExistsAndClear($this->vendorDir); $this->binDir = realpath(sys_get_temp_dir()) . DIRECTORY_SEPARATOR . 'composer-test-bin'; $this->ensureDirectoryExistsAndClear($this->binDir); $this->dependenciesDir = realpath(sys_get_temp_dir()) . DIRECTORY_SEPARATOR . 'composer-test-dependencies'; $this->ensureDirectoryExistsAndClear($this->dependenciesDir); $this->symlinkDir = realpath(sys_get_temp_dir()) . DIRECTORY_SEPARATOR . 'composer-test-vendor-shared'; $this->config->merge(array('config' => array('vendor-dir' => $this->vendorDir, 'bin-dir' => $this->binDir))); $this->dm = $this->getMockBuilder('Composer\\Downloader\\DownloadManager')->disableOriginalConstructor()->getMock(); $this->composer->setDownloadManager($this->dm); /** @var RootPackage|\PHPUnit_Framework_MockObject_MockObject $package */ $package = $this->getMock('Composer\\Package\\RootPackageInterface'); $package->expects($this->any())->method('getExtra')->willReturn(array(SharedPackageInstaller::PACKAGE_TYPE => array('vendor-dir' => $this->dependenciesDir, 'symlink-dir' => $this->symlinkDir))); $this->composer->setPackage($package); $this->repository = $this->getMock('Composer\\Repository\\InstalledRepositoryInterface'); $this->io = $this->getMock('Composer\\IO\\IOInterface'); $this->dataManager = $this->getMockBuilder('LEtudiant\\Composer\\Data\\Package\\SharedPackageDataManager')->disableOriginalConstructor()->getMock(); }
public function build($rootDirectory, $optimize = false, $noDevMode = false) { $packages = $this->loadPackages($rootDirectory); $evm = new EventDispatcher(new Composer(), $this->io); $generator = new AutoloadGenerator($evm, $this->io); $generator->setDevMode(!$noDevMode); $installationManager = new InstallationManager(); $installationManager->addInstaller(new FiddlerInstaller()); $this->io->write('Building fiddler.json projects.'); foreach ($packages as $packageName => $config) { if (strpos($packageName, 'vendor') === 0) { continue; } $this->io->write(' [Build] <info>' . $packageName . '</info>'); $mainPackage = new Package($packageName, "@stable", "@stable"); $mainPackage->setType('fiddler'); $mainPackage->setAutoload($config['autoload']); $mainPackage->setDevAutoload($config['autoload-dev']); $localRepo = new FiddlerInstalledRepository(); $this->resolvePackageDependencies($localRepo, $packages, $packageName); $composerConfig = new Config(true, $rootDirectory); $composerConfig->merge(array('config' => array('vendor-dir' => $config['path'] . '/vendor'))); $generator->dump($composerConfig, $localRepo, $mainPackage, $installationManager, 'composer', $optimize); } }
/** * setUp * * @return void */ public function setUp() { $this->file = new Filesystem(); $this->composer = new Composer(); $this->config = new Config(); $this->composer->setConfig($this->config); $this->composer->setInstallationManager(new InstallationManager()); $this->vendorDir = realpath(sys_get_temp_dir()) . DIRECTORY_SEPARATOR . 'baton-test-vendor'; $this->ensureDirectoryExistsAndClear($this->vendorDir); $this->binDir = realpath(sys_get_temp_dir()) . DIRECTORY_SEPARATOR . 'baton-test-bin'; $this->ensureDirectoryExistsAndClear($this->binDir); $this->config->merge(array('config' => array('vendor-dir' => $this->vendorDir, 'bin-dir' => $this->binDir))); $this->dm = $this->getMockBuilder('Composer\\Downloader\\DownloadManager')->disableOriginalConstructor()->getMock(); $this->composer->setDownloadManager($this->dm); $this->repository = $this->getMock('Composer\\Repository\\InstalledRepositoryInterface'); $this->io = $this->getMock('Composer\\IO\\IOInterface'); }
protected function setUp() { $this->filesystem = new Filesystem(); $this->composer = new Composer(); $this->config = new Config(); $this->composer->setConfig($this->config); $this->package = new RootPackage('raulfraile/ladybug', '1.0.0', '1.0.0'); $this->composer->setPackage($this->package); $this->vendorDir = realpath(sys_get_temp_dir()) . DIRECTORY_SEPARATOR . 'composer-test-vendor'; $this->ensureDirectoryExistsAndClear($this->vendorDir); $this->binDir = realpath(sys_get_temp_dir()) . DIRECTORY_SEPARATOR . 'composer-test-bin'; $this->ensureDirectoryExistsAndClear($this->binDir); $this->config->merge(array('config' => array('vendor-dir' => $this->vendorDir, 'bin-dir' => $this->binDir))); $this->downloadManager = m::mock('Composer\\Downloader\\DownloadManager'); $this->composer->setDownloadManager($this->downloadManager); $this->repository = m::mock('Composer\\Repository\\InstalledRepositoryInterface'); $this->io = m::mock('Composer\\IO\\IOInterface'); }
/** * testRequireJson * * @dataProvider providerRequireJson */ public function testRequireJson(array $packages, array $config, $expected = null) { $configObject = new Config(); $configObject->merge(array('config' => $config)); $this->composer->setConfig($configObject); $this->process->init(); $result = $this->process->requireJson($packages); $this->assertEquals($result, $expected, sprintf('Fail to get proper expected require.js configuration')); }
public static function createConfig() { // load main Composer configuration if (!($home = getenv('COMPOSER_HOME'))) { if (defined('PHP_WINDOWS_VERSION_MAJOR')) { $home = getenv('APPDATA') . '/Composer'; } else { $home = getenv('HOME') . '/.composer'; } } $config = new Config(); $file = new JsonFile($home . '/config.json'); if ($file->exists()) { $config->merge($file->read()); } // add home dir to the config $config->merge(array('config' => array('home' => $home))); return $config; }
public function testCredentialsFromConfig() { $url = 'http://svn.apache.org'; $config = new Config(); $config->merge(array('config' => array('http-basic' => array('svn.apache.org' => array('username' => 'foo', 'password' => 'bar'))))); $svn = new Svn($url, new NullIO(), $config); $reflMethod = new \ReflectionMethod('Composer\\Util\\Svn', 'getCredentialString'); $reflMethod->setAccessible(true); $this->assertEquals($this->getCmd(" --username 'foo' --password 'bar' "), $reflMethod->invoke($svn)); }
/** * @dataProvider getAssetTypes * * @param string $type * @param string $filename * @param string $identifier */ public function testPrivateRepositoryWithEmptyComposer($type, $filename, $identifier) { $this->config->merge(array('config' => array('http-basic' => array('example.tld' => array('username' => 'peter', 'password' => 'quill'))))); $repoBaseUrl = 'svn://example.tld/composer-test/repo-name'; $repoUrl = $repoBaseUrl . '/trunk'; $io = $this->getMockBuilder('Composer\\IO\\IOInterface')->getMock(); $repoConfig = array('url' => $repoUrl, 'asset-type' => $type, 'filename' => $filename); $process = $this->getMockBuilder('Composer\\Util\\ProcessExecutor')->getMock(); $process->expects($this->any())->method('splitLines')->will($this->returnValue(array())); $process->expects($this->any())->method('execute')->will($this->returnCallback(function () { return 0; })); /* @var IOInterface $io */ /* @var ProcessExecutor $process */ $driver = new SvnDriver($repoConfig, $io, $this->config, $process, null); $driver->initialize(); $validEmpty = array('_nonexistent_package' => true); $this->assertSame($validEmpty, $driver->getComposerInformation($identifier)); }
/** * Sets up the fixture * * @return null */ protected function setUp() { $this->files = new Files(); $this->composer = new Composer(); $this->config = new Config(); $this->composer->setConfig($this->config); $this->vendorDir = realpath($this->files->mkdir()); $this->binDir = realpath($this->files->mkdir()); $this->moodleDir = realpath($this->files->mkdir()) . "/www"; $this->config->merge(array('config' => array('vendor-dir' => $this->vendorDir, 'bin-dir' => $this->binDir, 'moodle-dir' => $this->moodleDir, 'home' => $this->files->mkdir()))); $this->io = $this->getMock('Composer\\IO\\IOInterface'); }
public function setUp() { $this->filesystem = new Filesystem(); $this->composer = new Composer(); $this->config = new Config(); $this->io = new NullIO(); $this->componentDir = realpath(sys_get_temp_dir()) . DIRECTORY_SEPARATOR . 'component-installer-componentDir'; $this->vendorDir = realpath(sys_get_temp_dir()) . DIRECTORY_SEPARATOR . 'component-installer-vendorDir'; $this->binDir = realpath(sys_get_temp_dir()) . DIRECTORY_SEPARATOR . 'component-installer-binDir'; foreach (array($this->componentDir, $this->vendorDir, $this->binDir) as $dir) { if (is_dir($dir)) { $this->filesystem->removeDirectory($dir); } $this->filesystem->ensureDirectoryExists($dir); } $this->config->merge(array('config' => array('vendor-dir' => $this->vendorDir, 'component-dir' => $this->componentDir, 'bin-dir' => $this->binDir))); $this->composer->setConfig($this->config); // Set up the Installation Manager. $this->installationManager = new InstallationManager(); $this->installationManager->addInstaller(new LibraryInstaller($this->io, $this->composer)); $this->installationManager->addInstaller(new Installer($this->io, $this->composer)); $this->composer->setInstallationManager($this->installationManager); }
public function test_it_commits_with_custom_commit_message() { $this->config->merge(['config' => ['home' => realpath(__DIR__ . '/fixtures/home-commit-message')]]); $plugin = new ChangelogsPlugin(); $plugin->activate($this->composer, $this->io); $operation = $this->getUpdateOperation(); $packageEvent = new PackageEvent(PackageEvents::POST_PACKAGE_UPDATE, $this->composer, $this->io, false, new DefaultPolicy(false, false), new Pool(), new CompositeRepository([]), new Request(new Pool()), [$operation], $operation); $plugin->postPackageOperation($packageEvent); $postUpdateEvent = new Event(ScriptEvents::POST_UPDATE_CMD, $this->composer, $this->io); $plugin->postUpdate($postUpdateEvent); $this->assertFileExists($this->tempDir . '/commit-message.txt'); $commitMessage = file_get_contents($this->tempDir . '/commit-message.txt'); $this->assertStringMatchesFormat('chore: Update composer%aChangelogs summary:%a', $commitMessage); }
protected function setUp() { $this->fs = new Filesystem(); $this->composer = new Composer(); $this->config = new Config(); $this->composer->setConfig($this->config); $this->vendorDir = realpath(sys_get_temp_dir()) . DIRECTORY_SEPARATOR . 'composer-test-vendor'; $this->ensureDirectoryExistsAndClear($this->vendorDir); $this->binDir = realpath(sys_get_temp_dir()) . DIRECTORY_SEPARATOR . 'composer-test-bin'; $this->ensureDirectoryExistsAndClear($this->binDir); $this->config->merge(array('config' => array('vendor-dir' => $this->vendorDir, 'bin-dir' => $this->binDir))); $this->dm = $this->getMockBuilder('Composer\\Downloader\\DownloadManager')->disableOriginalConstructor()->getMock(); $this->composer->setDownloadManager($this->dm); $this->repository = $this->getMock('Composer\\Repository\\InstalledRepositoryInterface'); $this->io = $this->getMock('Composer\\IO\\IOInterface'); $this->rootDir = realpath(sys_get_temp_dir()) . DIRECTORY_SEPARATOR . 'composer-test-contao'; $this->uploadDir = 'upload'; $this->plugin = $this->getMock('\\ContaoCommunityAlliance\\Composer\\Plugin\\Plugin'); $this->plugin->expects($this->any())->method('getContaoRoot')->will($this->returnValue($this->rootDir)); $this->plugin->expects($this->any())->method('getUploadPath')->will($this->returnValue($this->uploadDir)); $package = new RootPackage('test/package', '1.0.0.0', '1.0.0'); $this->composer->setPackage($package); }
/** * @expectedException RuntimeException */ public function testWrongCredentialsInUrl() { $console = $this->getMock('Composer\\IO\\IOInterface'); $console->expects($this->once())->method('isInteractive')->will($this->returnValue(true)); $output = "svn: OPTIONS of 'http://corp.svn.local/repo':"; $output .= " authorization failed: Could not authenticate to server:"; $output .= " rejected Basic challenge (http://corp.svn.local/)"; $process = $this->getMock('Composer\\Util\\ProcessExecutor'); $process->expects($this->once())->method('execute')->will($this->returnValue(1)); $process->expects($this->once())->method('getErrorOutput')->will($this->returnValue($output)); $config = new Config(); $config->merge(array('config' => array('home' => sys_get_temp_dir() . '/composer-test'))); $svn = new SvnDriver('http://*****:*****@corp.svn.local/repo', $console, $config, $process); $svn->initialize(); }
public function testDownloadUsesCustomVariousProtocolsForGithub() { $packageMock = $this->getMock('Composer\\Package\\PackageInterface'); $packageMock->expects($this->any())->method('getSourceReference')->will($this->returnValue('ref')); $packageMock->expects($this->any())->method('getSourceUrl')->will($this->returnValue('https://github.com/composer/composer')); $packageMock->expects($this->any())->method('getPrettyVersion')->will($this->returnValue('1.0.0')); $processExecutor = $this->getMock('Composer\\Util\\ProcessExecutor'); $expectedGitCommand = $this->getCmd("git clone 'http://github.com/composer/composer' 'composerPath' && cd 'composerPath' && git remote add composer 'http://github.com/composer/composer' && git fetch composer"); $processExecutor->expects($this->at(0))->method('execute')->with($this->equalTo($expectedGitCommand))->will($this->returnValue(0)); $processExecutor->expects($this->exactly(4))->method('execute')->will($this->returnValue(0)); $config = new Config(); $config->merge(array('config' => array('github-protocols' => array('http')))); $downloader = $this->getDownloaderMock(null, $config, $processExecutor); $downloader->download($packageMock, 'composerPath'); }
protected function setUp() { $io = $this->getMockBuilder('Composer\\IO\\IOInterface')->getMock(); $io->expects($this->any())->method('isVerbose')->will($this->returnValue(true)); /* @var IOInterface $io */ $config = new Config(); $config->merge(array('config' => array('home' => sys_get_temp_dir() . '/composer-test', 'cache-repo-dir' => sys_get_temp_dir() . '/composer-test-cache-repo'))); $rm = new RepositoryManager($io, $config); $rm->setRepositoryClass($this->getType() . '-vcs', 'Fxp\\Composer\\AssetPlugin\\Tests\\Fixtures\\Repository\\MockAssetRepository'); $repoConfig = array_merge(array('repository-manager' => $rm, 'asset-options' => array('searchable' => true)), $this->getCustomRepoConfig()); $this->io = $io; $this->config = $config; $this->rm = $rm; $this->registry = $this->getRegistry($repoConfig, $io, $config); $this->pool = $this->getMockBuilder('Composer\\DependencyResolver\\Pool')->getMock(); }
public function testNonFeatureBranchPrettyVersion() { if (!function_exists('proc_open')) { $this->markTestSkipped('proc_open() is not available'); } $manager = $this->getMockBuilder('\\Composer\\Repository\\RepositoryManager')->disableOriginalConstructor()->getMock(); $executor = $this->getMockBuilder('\\Composer\\Util\\ProcessExecutor')->setMethods(array('execute'))->disableArgumentCloning()->disableOriginalConstructor()->getMock(); $self = $this; $executor->expects($this->at(0))->method('execute')->willReturnCallback(function ($command, &$output) use($self) { $self->assertEquals('git branch --no-color --no-abbrev -v', $command); $output = "* latest-production 38137d2f6c70e775e137b2d8a7a7d3eaebf7c7e5 Commit message\n master 4f6ed96b0bc363d2aa4404c3412de1c011f67c66 Commit message\n"; return 0; }); $config = new Config(); $config->merge(array('repositories' => array('packagist' => false))); $loader = new RootPackageLoader($manager, $config, null, new VersionGuesser($config, $executor, new VersionParser())); $package = $loader->load(array('require' => array('foo/bar' => 'self.version'), "non-feature-branches" => array("latest-.*"))); $this->assertEquals("dev-latest-production", $package->getPrettyVersion()); }