Author: Sylvain Lorinet (sylvain.lorinet@gmail.com)
 /**
  * @test
  */
 public function uninstallKeepSources()
 {
     $this->io->expects($this->once())->method('askConfirmation')->willReturn(false);
     /** @var SymlinkFilesystem|\PHPUnit_Framework_MockObject_MockObject $filesystem */
     $filesystem = $this->getMock('\\LEtudiant\\Composer\\Util\\SymlinkFilesystem');
     $filesystem->expects($this->once())->method('removeSymlink')->willReturn(true);
     $installer = $this->createInstaller($this->config, $filesystem);
     $package = $this->createPackageMock();
     $this->repository->expects($this->once())->method('removePackage')->with($package);
     $this->dm->expects($this->never())->method('remove');
     $this->dataManager->expects($this->once())->method('removePackageUsage')->with($package);
     $installer->uninstall($this->repository, $package);
 }
 /**
  * @test
  */
 public function uninstallDevelopment()
 {
     $this->io->expects($this->once())->method('askConfirmation')->willReturn(true);
     /** @var SymlinkFilesystem|\PHPUnit_Framework_MockObject_MockObject $filesystem */
     $filesystem = $this->getMock('\\LEtudiant\\Composer\\Util\\SymlinkFilesystem');
     $filesystem->expects($this->once())->method('removeSymlink')->willReturn(true);
     $library = new SharedPackageInstaller($this->io, $this->composer, $filesystem, $this->dataManager);
     $package = $this->createDevelopmentPackageMock();
     $this->repository->expects($this->exactly(1))->method('hasPackage')->with($package)->will($this->onConsecutiveCalls(true, true));
     $this->repository->expects($this->once())->method('removePackage')->with($package);
     $this->dm->expects($this->once())->method('remove')->with($package, $this->dependenciesDir . '/letudiant/foo-bar/dev-develop');
     $this->dataManager->expects($this->once())->method('removePackageUsage')->with($package);
     $library->uninstall($this->repository, $package);
 }
 /**
  * Detect if other project use the dependency by using the "packages.json" file
  *
  * @param PackageInterface $package
  *
  * @return bool
  */
 protected function isSourceDirUnused(PackageInterface $package)
 {
     $usageData = $this->packageDataManager->getPackageUsage($package);
     return sizeof($usageData) <= 1;
 }