Example #1
0
 /**
  * @test
  */
 public function aliasMapConfigIsExtractedFromDeprecatedKey()
 {
     $this->packageMock->expects($this->any())->method('getExtra')->willReturn(array('helhum/class-alias-loader' => array('class-alias-maps' => array('path/map.php'))));
     $this->IOMock->expects($this->once())->method('writeError');
     $subject = new Config($this->packageMock, $this->IOMock);
     $this->assertSame(array('path/map.php'), $subject->get('class-alias-maps'));
 }
Example #2
0
 /**
  * @param string $command
  * @param bool $decorated
  * @param \PHPUnit_Framework_MockObject_Matcher_Invocation|null $matcher
  */
 protected function executeCommand($command, $decorated, \PHPUnit_Framework_MockObject_Matcher_Invocation $matcher = null)
 {
     if ($decorated) {
         $command .= ' --ansi';
     }
     $this->io->expects($this->atLeastOnce())->method('isDecorated')->will($this->returnValue($decorated));
     $this->event_command->expects($this->atLeastOnce())->method('getIO')->will($this->returnValue($this->io));
     $this->container->expects($matcher ?: $this->once())->method('executeCommand')->with($command, 0);
 }
 public function testRunPostAutoloadDumpOnlyOnce()
 {
     $listeners = $this->plugin->getSubscribedEvents();
     $this->assertArrayHasKey(ScriptEvents::POST_AUTOLOAD_DUMP, $listeners);
     $listener = $listeners[ScriptEvents::POST_AUTOLOAD_DUMP];
     $event = new CommandEvent(ScriptEvents::POST_AUTOLOAD_DUMP, $this->composer, $this->io);
     $this->io->expects($this->exactly(3))->method('write');
     $this->plugin->{$listener}($event);
     $this->plugin->{$listener}($event);
 }
 /**
  * @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);
 }
 /**
  * Helper method for setting up the the expectations for the given $credentials.
  *
  * @param array $credentials
  */
 protected function configureExpectationsFor($credentials = array())
 {
     foreach ($credentials as $host => $config) {
         // satisfies the requirement that credentials without a username get ignored
         if (!isset($config['username'])) {
             continue;
         }
         // satisfies the requirement that not existing passwords will default to null
         if (!isset($config['password'])) {
             $config['password'] = null;
         }
         $this->io->expects($this->at($this->idx++))->method('setAuthentication')->with($host, $config['username'], $config['password']);
         $this->io->expects($this->at($this->idx++))->method('setAuthentication')->with('http://' . $host . '/packages.json', $config['username'], $config['password']);
         $this->io->expects($this->at($this->idx++))->method('setAuthentication')->with('https://' . $host . '/packages.json', $config['username'], $config['password']);
     }
 }