protected function execute(InputInterface $input, OutputInterface $output) { $manifest = $input->getOption('manifest') ?: 'https://platform.sh/cli/manifest.json'; $currentVersion = $input->getOption('current-version') ?: $this->getApplication()->getVersion(); if (extension_loaded('Phar') && !($localPhar = \Phar::running(false))) { $this->stdErr->writeln('This instance of the CLI was not installed as a Phar archive.'); if (file_exists(CLI_ROOT . '/../../autoload.php')) { $this->stdErr->writeln('Update using: <info>composer global update</info>'); } return 1; } $manager = new Manager(Manifest::loadFile($manifest)); if (isset($localPhar)) { $manager->setRunningFile($localPhar); } $onlyMinor = !$input->getOption('major'); $updated = $manager->update($currentVersion, $onlyMinor); if ($updated) { $this->stdErr->writeln("Successfully updated"); $localPhar = $manager->getRunningFile(); passthru('php ' . escapeshellarg($localPhar) . ' --version'); } else { $this->stdErr->writeln("No updates found. The Platform.sh CLI is up-to-date."); } return 0; }
/** * @depends testGetRunningFile */ public function testSetRunningFile() { $file = $this->createFile(); $this->manager->setRunningFile($file); $this->assertEquals($file, $this->manager->getRunningFile()); }