Exemplo n.º 1
0
 /**
  * Test that the base functionality works.
  *
  * @return void
  */
 public function testAll()
 {
     // Redirect composer config and cache into the test temp dir.
     putenv('COMPOSER_HOME=' . $this->getTempDir() . DIRECTORY_SEPARATOR . '.composer');
     $this->createFixture('.composer' . DIRECTORY_SEPARATOR . 'config.json', str_replace('##URL##', str_replace('\\', '/', $this->getTempDir() . DIRECTORY_SEPARATOR . 'test-repository' . DIRECTORY_SEPARATOR), $this->readFixture('composer' . DIRECTORY_SEPARATOR . 'config.json')));
     $this->createFixture('test-repository' . DIRECTORY_SEPARATOR . 'packages.json', str_replace('##URL##', str_replace('\\', '/', $this->getTempDir() . DIRECTORY_SEPARATOR . 'test-repository' . DIRECTORY_SEPARATOR), $this->readFixture('test-repository' . DIRECTORY_SEPARATOR . 'packages.json')));
     $this->provideFixture('test-repository' . DIRECTORY_SEPARATOR . 'vendor-package-name-1.0.0.zip');
     $this->provideFixture('test-repository' . DIRECTORY_SEPARATOR . 'vendor-dependency-name-1.0.0.zip');
     $this->provideFixture($newZip = 'test-repository' . DIRECTORY_SEPARATOR . 'vendor-dependency-name-1.1.0.zip');
     // First we need a proper installation.
     $task = new InstallTask(new JsonArray([InstallTask::SETTING_TYPE => 'install', InstallTask::SETTING_ID => 'install-task-id', InstallTask::SETTING_PACKAGE => 'vendor/package-name', InstallTask::SETTING_VERSION => '1.0.0', InstallTask::SETTING_DESTINATION_DIR => $this->getTempDir(), 'status' => InstallTask::STATE_PENDING]));
     $task->perform($this->getTempFile('logs/install-task.log'));
     if ($task->getStatus() !== InstallTask::STATE_FINISHED) {
         $this->markTestSkipped('Upgrade task can not be tested, test installation failed.');
         return;
     }
     // Now the upgrade.
     $file = new JsonFile($this->getTempDir() . DIRECTORY_SEPARATOR . 'composer.json');
     $file->set('repositories', ['packagist' => false]);
     $file->set('require/' . $file->escape('vendor/dependency-name'), '~1.0');
     unset($file);
     $task = new UpgradeTask(new JsonArray([UpgradeTask::SETTING_TYPE => 'upgrade', UpgradeTask::SETTING_ID => 'upgrade-task-id', UpgradeTask::SETTING_HOME => $this->getTempDir(), UpgradeTask::SETTING_PACKAGES => ['vendor/dependency-name'], 'status' => UpgradeTask::STATE_PENDING]));
     $task->perform($this->getTempFile('logs/task.log'));
     $this->assertEquals('upgrade-task-id', $task->getId());
     $this->assertEquals(UpgradeTask::STATE_FINISHED, $task->getStatus());
     $this->assertContains('Installing vendor/dependency-name (1.1.0)', $task->getOutput());
     $this->assertZipHasBeenUnpackedTo($this->getFixturesDirectory() . DIRECTORY_SEPARATOR . $newZip, 'vendor' . DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . 'dependency-name');
 }
Exemplo n.º 2
0
 /**
  * {@inheritDoc}
  */
 protected function setUp()
 {
     parent::setUp();
     // Redirect composer config and cache into the test temp dir.
     putenv('COMPOSER_HOME=' . $this->getTempDir() . DIRECTORY_SEPARATOR . '.composer');
     $this->createFixture('.composer' . DIRECTORY_SEPARATOR . 'config.json', str_replace('##URL##', str_replace('\\', '/', $this->getTempDir() . DIRECTORY_SEPARATOR . 'test-repository' . DIRECTORY_SEPARATOR), $this->readFixture('composer' . DIRECTORY_SEPARATOR . 'config.json')));
     $this->createFixture('test-repository' . DIRECTORY_SEPARATOR . 'packages.json', str_replace('##URL##', str_replace('\\', '/', $this->getTempDir() . DIRECTORY_SEPARATOR . 'test-repository' . DIRECTORY_SEPARATOR), $this->readFixture('test-repository' . DIRECTORY_SEPARATOR . 'packages.json')));
     $this->provideFixture('test-repository' . DIRECTORY_SEPARATOR . 'vendor-package-name-1.0.0.zip');
     $this->provideFixture('test-repository' . DIRECTORY_SEPARATOR . 'vendor-dependency-name-1.0.0.zip');
     $this->provideFixture('test-repository' . DIRECTORY_SEPARATOR . 'vendor-dependency-name-1.1.0.zip');
     // First we need a proper installation.
     $task = new InstallTask(new JsonArray([InstallTask::SETTING_TYPE => 'install', InstallTask::SETTING_ID => 'install-task-id', InstallTask::SETTING_PACKAGE => 'vendor/package-name', InstallTask::SETTING_VERSION => '1.0.0', InstallTask::SETTING_DESTINATION_DIR => $this->getTempDir(), 'status' => InstallTask::STATE_PENDING]));
     $task->perform($this->getTempFile('logs/install-task.log'));
     if ($task->getStatus() !== InstallTask::STATE_FINISHED) {
         $this->markTestSkipped('Remove package task can not be tested, test installation failed.');
         return;
     }
 }
Exemplo n.º 3
0
 /**
  * Test that the base functionality works.
  *
  * @return void
  */
 public function testAll()
 {
     // Redirect composer config and cache into the test temp dir.
     putenv('COMPOSER_HOME=' . $this->getTempDir() . DIRECTORY_SEPARATOR . '.composer');
     $this->createFixture('.composer' . DIRECTORY_SEPARATOR . 'config.json', str_replace('##URL##', str_replace('\\', '/', $this->getTempDir() . DIRECTORY_SEPARATOR . 'test-repository' . DIRECTORY_SEPARATOR), $this->readFixture('composer' . DIRECTORY_SEPARATOR . 'config.json')));
     $this->createFixture('test-repository' . DIRECTORY_SEPARATOR . 'packages.json', str_replace('##URL##', str_replace('\\', '/', $this->getTempDir() . DIRECTORY_SEPARATOR . 'test-repository' . DIRECTORY_SEPARATOR), $this->readFixture('test-repository' . DIRECTORY_SEPARATOR . 'packages.json')));
     $this->provideFixture($rootZip = 'test-repository' . DIRECTORY_SEPARATOR . 'vendor-package-name-1.0.0.zip');
     $this->provideFixture($dependencyZip = 'test-repository' . DIRECTORY_SEPARATOR . 'vendor-dependency-name-1.0.0.zip');
     $task = new InstallTask(new JsonArray([InstallTask::SETTING_TYPE => 'install', InstallTask::SETTING_ID => 'install-task-id', InstallTask::SETTING_PACKAGE => 'vendor/package-name', InstallTask::SETTING_VERSION => '1.0.0', InstallTask::SETTING_DESTINATION_DIR => $this->getTempDir(), 'status' => InstallTask::STATE_PENDING]));
     $task->perform($this->getTempFile('logs/task.log'));
     $this->assertEquals('install-task-id', $task->getId());
     $this->assertEquals(InstallTask::STATE_FINISHED, $task->getStatus());
     // Ensure the temporary directory is gone.
     $this->assertEmpty(glob($this->getTempDir() . DIRECTORY_SEPARATOR . 'install-*'));
     foreach (['vendor/composer/autoload_classmap.php', 'vendor/composer/ClassLoader.php', 'vendor/composer/autoload_real.php', 'vendor/composer/LICENSE', 'vendor/composer/autoload_psr4.php', 'vendor/composer/autoload_namespaces.php', 'vendor/composer/installed.json'] as $file) {
         $this->assertFileExists($this->getTempDir() . DIRECTORY_SEPARATOR . $file);
     }
     $this->assertZipHasBeenUnpackedTo($this->getFixturesDirectory() . DIRECTORY_SEPARATOR . $rootZip);
     $this->assertZipHasBeenUnpackedTo($this->getFixturesDirectory() . DIRECTORY_SEPARATOR . $dependencyZip, 'vendor' . DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . 'dependency-name');
 }