/**
  * @test
  */
 public function removePackageUsageWithData()
 {
     $this->initializePackageData();
     $dataManager = new SharedPackageDataManager($this->composer);
     $dataManager->setVendorDir($this->vendorDir);
     $this->rootPackage->expects($this->exactly(2))->method('getName')->will($this->onConsecutiveCalls('letudiant/root-package', 'letudiant/root-package2'));
     $package = $this->getMock('Composer\\Package\\PackageInterface');
     $package->expects($this->exactly(4))->method('getPrettyName')->willReturn('letudiant/foo-bar');
     $package->expects($this->exactly(4))->method('getPrettyVersion')->willReturn('dev-develop');
     $package->expects($this->exactly(0))->method('getInstallationSource');
     // Remove the right package
     $this->initializePackageData();
     $dataManager->removePackageUsage($package);
     $this->assertFileExists($this->vendorDir . '/' . SharedPackageDataManager::PACKAGE_DATA_FILENAME);
     $content = file_get_contents($this->vendorDir . '/' . SharedPackageDataManager::PACKAGE_DATA_FILENAME);
     $this->assertJson($content);
     $this->assertEquals(array(), json_decode($content, true));
     // Remove another package, should not remove the initial package
     $this->initializePackageData();
     $dataManager = new SharedPackageDataManager($this->composer);
     $dataManager->setVendorDir($this->vendorDir);
     $dataManager->removePackageUsage($package);
     $this->assertFileExists($this->vendorDir . '/' . SharedPackageDataManager::PACKAGE_DATA_FILENAME);
     $content = file_get_contents($this->vendorDir . '/' . SharedPackageDataManager::PACKAGE_DATA_FILENAME);
     $this->assertJson($content);
     $this->assertEquals(array('letudiant/foo-bar/dev-develop' => array('installation-source' => 'source', 'project-usage' => array('letudiant/root-package'))), json_decode($content, true));
 }
 public function testCreateWithCustomIgnoreSection()
 {
     $extra = array('custom-ignore-files' => array('foo-asset/foo' => array('PATTERN'), 'foo-asset/bar' => array()));
     $this->rootPackage->expects($this->any())->method('getExtra')->will($this->returnValue($extra));
     $manager = IgnoreFactory::create($this->composer, $this->package, null, 'custom-ignore-files');
     $this->assertTrue($manager->isEnabled());
     $this->assertTrue($manager->hasPattern());
     $this->validateInstallDir($manager, $this->config->get('vendor-dir') . '/' . $this->package->getName());
 }
예제 #3
0
 /**
  * @param array $tag
  * @param string $current_version
  * @param int $result
  *
  * @return UpdateCommand
  */
 protected function getCommandToExecute(array $tag, $current_version, $result)
 {
     $that = $this;
     $installer = $this->getMockBuilder('\\Composer\\Installer')->disableOriginalConstructor()->getMock();
     $installer->expects($this->once())->method('run')->will($this->returnValue($result));
     $this->container->expects($that->at(0))->method('get')->will($this->returnValue($this->composer))->with('anime_db.composer');
     $this->container->expects($that->at(1))->method('get')->will($this->returnValue($this->github))->with('anime_db.client.github');
     $this->composer->expects($this->once())->method('setIO')->will($this->returnCallback(function ($io) use($that) {
         $that->assertInstanceOf('\\Composer\\IO\\ConsoleIO', $io);
     }));
     $this->github->expects($this->once())->method('getLastRelease')->will($this->returnValue($tag))->with('anime-db/anime-db');
     $this->composer->expects($this->atLeastOnce())->method('getRootPackage')->will($this->returnValue($this->package));
     $this->composer->expects($this->once())->method('getInstaller')->will($this->returnValue($installer));
     $this->package->expects($this->once())->method('getPrettyVersion')->will($this->returnValue($current_version));
     /* @var $helper_set HelperSet */
     $helper_set = $this->getMockBuilder('\\Symfony\\Component\\Console\\Helper\\HelperSet')->disableOriginalConstructor()->getMock();
     $this->output->expects($this->at(0))->method('writeln')->with('Search for a new version of the application');
     $command = new UpdateCommand();
     $command->setHelperSet($helper_set);
     $command->setContainer($this->container);
     return $command;
 }