/** * @covers ::open * @covers ::getZip * @covers ::getRoot * @covers ::getPromptNames */ public function testOpen() { $client = new ClientMock(); $client->queueResponse('test.zip'); $template = new Template($client); $template->open('TEST_URL'); $history = $client->getHistory(); $this->assertEquals('TEST_URL', (string) $history[0]['request']->getUri()); $zip = $template->getZip(); $this->assertInstanceOf('ZipArchive', $zip); $this->assertEquals('clippings-package-template-971a36f/', $template->getRoot()); $this->assertEquals(['title', 'description'], $template->getPromptNames()); }
protected function execute(InputInterface $input, OutputInterface $output) { $packageName = $input->getArgument('package'); $dialog = $this->getHelperSet()->get('dialog'); $this->template->open($this->getPackageZipUrl($packageName)); $output->writeln('Enter Template variables (Press enter for default):'); $this->template->setValues($this->prompts->getValues($this->template->getPromptNames(), $output, $dialog)); $valuesDisplay = "Use These Variables:\n"; foreach ($this->template->getValues() as $key => $value) { $valuesDisplay .= " <info>{$key}</info>: {$value}\n"; } $valuesDisplay .= "Confirm? <comment>(Y/n)</comment>:"; if ($dialog->askConfirmation($output, $valuesDisplay, 'y')) { $this->template->putInto(getcwd()); $output->writeln('Done'); } else { $output->writeln('<error>Aborted</error>'); } }