Пример #1
0
 /**
  * Test that the core bundles get correctly injected.
  *
  * @return void
  */
 public function testInjectCoreBundles()
 {
     $inOut = $this->getMock('Composer\\IO\\IOInterface');
     $factory = new Factory();
     $composer = $factory->createComposer($inOut, $this->config);
     $plugin = new Plugin();
     $local = $composer->getRepositoryManager()->getLocalRepository();
     if ($core = $local->findPackages('contao/core')) {
         $this->fail('Contao core has already been injected, found version ' . $core[0]->getVersion());
     }
     $plugin->activate($composer, $inOut);
     if (!($core = $local->findPackages('contao/core'))) {
         $this->fail('Contao core has not been injected.');
     }
     $core = $core[0];
     $constraint = new Constraint('=', $core->getVersion());
     $pool = new Pool('dev');
     $pool->addRepository($local);
     $this->assertNotNull($core = $pool->whatProvides('contao/core', $constraint));
     // bundle names + 'contao-community-alliance/composer-client'
     $this->assertCount(8, $core[0]->getRequires());
     foreach (array('contao/calendar-bundle', 'contao/comments-bundle', 'contao/core-bundle', 'contao/faq-bundle', 'contao/listing-bundle', 'contao/news-bundle', 'contao/newsletter-bundle') as $bundleName) {
         $this->assertNotNull($matches = $pool->whatProvides($bundleName, $constraint));
         $this->assertCount(1, $matches);
         $this->assertEquals('metapackage', $matches[0]->getType());
     }
 }
Пример #2
0
 /**
  * When the plugin is loaded, the event listeners are registered which require the Housekeeper.
  *
  * When the plugin gets uninstalled the housekeeper does not exist anymore and a "Housekeeper class not found" is
  * thrown.
  *
  * Test for https://github.com/contao-community-alliance/composer-plugin/issues/30
  *
  * Situation:
  *  - plugin is installed.
  *  - plugin get uninstalled.
  *
  * Result:
  *  - Housekeeper class not found.
  *
  * @return void
  */
 public function testIssue30LoadHousekeeper()
 {
     $inOut = $this->getMock('Composer\\IO\\IOInterface');
     $factory = new Factory();
     $composer = $factory->createComposer($inOut);
     $plugin = new Plugin();
     $plugin->activate($composer, $inOut);
     $this->assertTrue(class_exists('ContaoCommunityAlliance\\Composer\\Plugin\\Housekeeper', false));
 }
Пример #3
0
 public function setUp()
 {
     $this->plugin = $this->getMock('\\ContaoCommunityAlliance\\Composer\\Plugin\\Plugin');
     $this->plugin->expects($this->any())->method('getContaoRoot')->will($this->returnValue('CONTAO_ROOT'));
     $package = new RootPackage('test/me', '0.8.15', '0.8.15.0');
     $package->setType(AbstractInstaller::MODULE_TYPE);
     $this->composer = new Composer();
     $this->composer->setConfig(new Config());
     $this->composer->setPackage($package);
     $this->installerStub = $this->getMockForAbstractClass('\\ContaoCommunityAlliance\\Composer\\Plugin\\AbstractInstaller', array(new NullIO(), $this->composer, $this->plugin));
 }
Пример #4
0
 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);
 }
Пример #5
0
 /**
  * Get the Contao upload path.
  *
  * @return string
  */
 protected function getUploadPath()
 {
     return $this->plugin->getContaoUploadPath();
 }