Пример #1
0
 /**
  * Test that a locally installed contao can be found when overriding the path via composer.json in the root package.
  *
  * @return void
  */
 public function testOverrideViaExtra()
 {
     $plugin = $this->clearTest('/tmp/path');
     $this->fs->ensureDirectoryExists($this->testRoot . '/tmp/path/system');
     $package = new RootPackage('test/package', '1.0.0.0', '1.0.0');
     $package->setExtra(array('contao' => array('root' => 'tmp/path')));
     $this->assertEquals($this->testRoot . '/tmp/path', $plugin->getContaoRoot($package));
 }
 public function setUp()
 {
     $composer = new Composer();
     $package = new RootPackage("test", "1", "1");
     $package->setExtra(['opencart-dir' => 'tests/resources/sampleocdir']);
     $composer->setPackage($package);
     $composer->setConfig(new Config());
     $this->openCartExtensionInstaller = new OpenCartExtensionInstaller($this->getMockBuilder('Composer\\IO\\IOInterface')->getMock(), $composer);
 }
 /**
  * {@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);
 }
 /**
  * setUp
  *
  * @return void
  */
 public function setUp()
 {
     $this->fs = new Filesystem();
     $this->composer = new Composer();
     $root = new RootPackage('gingerwfms/ginger-wfms', '1.0.0', '1.0.0');
     $root->setExtra(array('bootstrap' => 'GingerPluginInstallerTest\\Mock\\BootstrapMock'));
     $this->composer->setPackage($root);
     $this->config = new Config();
     $this->composer->setConfig($this->config);
     $this->vendorDir = realpath(sys_get_temp_dir()) . DIRECTORY_SEPARATOR . 'ginger-test-vendor';
     $this->ensureDirectoryExistsAndClear($this->vendorDir);
     $this->binDir = realpath(sys_get_temp_dir()) . DIRECTORY_SEPARATOR . 'ginger-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');
 }
 public function testIgnoredBundles()
 {
     $packages = array($this->createPackage('foo/foo-bundle', 'symfony-bundle', array('psr-0' => array('Acme\\FooBundle' => ''))), $this->createPackage('acme/library-bundle', 'symfony-bundle', array('psr-0' => array('Acme\\LibraryBundle' => ''))));
     $rootPackage = new RootPackage('DemoPackage', 'dev-master', '1.x-dev');
     $rootPackage->setExtra(array('checkbundles-ignore' => array('Acme\\LibraryBundle\\AcmeLibraryBundle')));
     $this->composerMock->expects($this->any())->method('getPackage')->will($this->returnValue($rootPackage));
     $this->localRepository->expects($this->any())->method('getPackages')->will($this->returnValue($packages));
     $kernelHelper = $this->getMockBuilder('WillemJan\\Util\\KernelHelper')->disableOriginalConstructor()->setMethods(array('getBundlesForKernels'))->getMock();
     $kernelHelper->expects($this->any())->method('getBundlesForKernels')->will($this->returnValue(array('Acme\\FooBundle\\AcmeFooBundle')));
     $composerHelper = $this->getMockBuilder('WillemJan\\CheckBundles\\Util\\ComposerHelper')->setConstructorArgs(array($this->composerMock))->setMethods(array('getInstalledRepository', 'findBundleFiles'))->getMock();
     $composerHelper->expects($this->any())->method('findBundleFiles')->will($this->returnCallback(function ($package) use($packages) {
         switch ($package->getName()) {
             case 'foo/foo-bundle':
                 return array('AcmeFooBundle.php');
                 break;
             case 'acme/library-bundle':
                 return array('AcmeLibraryBundle.php');
                 break;
         }
         return array('ShouldNotHappenBundle.php');
     }));
     $composerHelper->expects($this->any())->method('getInstalledRepository')->will($this->returnValue($this->localRepository));
     $this->assertEquals(array(), $composerHelper->getNonActiveSymfonyBundles($kernelHelper->getBundlesForKernels()));
 }
 public function testUnInstallCoreFromUpdateOperation()
 {
     $corePackage = $this->createCorePackage();
     $rootPackage = new RootPackage('some/project', '1.0.0', 'some/project');
     $rootPackage->setExtra(array('magento-root-dir' => 'htdocs'));
     $this->composer->setPackage($rootPackage);
     $pool = $this->getMockBuilder('Composer\\DependencyResolver\\Pool')->disableOriginalConstructor()->getMock();
     $request = $this->getMockBuilder('Composer\\DependencyResolver\\Request')->disableOriginalConstructor()->getMock();
     $compositeRepo = new CompositeRepository(array($this->localRepository));
     $event = new PackageEvent('install-event', $this->composer, $this->io, false, $this->getMock('Composer\\DependencyResolver\\PolicyInterface'), $pool, $compositeRepo, $request, array(), new UpdateOperation($corePackage, $this->createCorePackage('magento/target')));
     $plugin = $this->getPluginWithMockedInstaller('unInstall');
     $l = '  - <comment>MagentoCoreInstaller: </comment>';
     $l .= '<info>Removing: "magento/core-package" version: "1.0.0" from: "htdocs"</info>';
     $this->io->expects($this->once())->method('write')->with($l);
     $plugin->activate($this->composer, $this->io);
     $plugin->uninstallCore($event);
 }
 /**
  * Merge extra config into a RootPackage
  *
  * @param RootPackage $root
  * @param PluginState $state
  */
 public function mergeExtra(RootPackage $root, PluginState $state)
 {
     $extra = $this->package->getExtra();
     unset($extra['merge-plugin']);
     if (!$state->shouldMergeExtra() || empty($extra)) {
         return;
     }
     $rootExtra = $root->getExtra();
     if ($state->replaceDuplicateLinks()) {
         $root->setExtra(array_merge($rootExtra, $extra));
     } else {
         foreach ($extra as $key => $value) {
             if (isset($rootExtra[$key])) {
                 $this->logger->debug("Ignoring duplicate <comment>{$key}</comment> in " . "<comment>{$this->path}</comment> extra config.");
             }
         }
         $root->setExtra(array_merge($extra, $rootExtra));
     }
 }
 /**
  * @param $includeMageDir
  * @return RootPackage
  */
 public function createRootPackage($includeMageDir = true)
 {
     $package = new RootPackage("root/package", "1.0.0", "root/package");
     if ($includeMageDir) {
         $extra = array('magento-root-dir' => 'htdocs');
         $package->setExtra($extra);
     }
     $this->composer->setPackage($package);
     return $package;
 }