Пример #1
0
 /**
  * @covers ::set
  * @covers ::get
  */
 public function testSetGet()
 {
     $file = __DIR__ . '/composer-token-test';
     if (file_exists($file)) {
         unlink($file);
     }
     $token = new Token($file);
     $this->assertSame(null, $token->get(), 'Should return null if no token file');
     $token->set('TEST_TOKEN');
     $this->assertEquals('TEST_TOKEN', file_get_contents($file), 'Token file should be created');
     $otherToken = new Token($file);
     $this->assertEquals('TEST_TOKEN', $otherToken->get(), 'Token should be read by file');
     unlink($file);
 }
Пример #2
0
 public function __construct($tokenFile = '~/.composer-init')
 {
     parent::__construct('Composer Init', '0.3');
     $packagist = new Client(['base_uri' => 'https://packagist.org']);
     $token = new Token($tokenFile);
     $githubOptions = ['base_uri' => 'https://api.github.com'];
     if (null !== $token->get()) {
         $githubOptions['query']['access_token'] = $token->get();
     }
     $github = new Client($githubOptions);
     $gitConfig = new GitConfig();
     $inflector = new Inflector();
     $prompts = new Prompts($gitConfig, $github, $inflector);
     $template = new Template($github);
     $this->add(new SearchCommand($packagist));
     $this->add(new UseCommand($template, $prompts, $packagist));
     $this->add(new TokenCommand($token));
 }
Пример #3
0
 /**
  * @param  InputInterface  $input
  * @param  OutputInterface $output
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $token = $input->getArgument('token');
     $this->token->set($token);
     $output->writeln("Token saved to {$this->token->getFilename()}");
 }