/**
  * @covers ::getTemplates
  */
 public function testGetTemplates()
 {
     $client = new ClientMock();
     $client->queueResponse('packagist/list.json');
     $command = new SearchCommand($client);
     $templates = $command->getTemplates();
     $expected = ['clippings/package-template', 'harp-orm/harp-template', 'openbuildings/jam-template'];
     $this->assertEquals($expected, $templates);
     $history = $client->getHistory();
     $this->assertEquals('/packages/list.json?type=composer-init-template', (string) $history[0]['request']->getUri());
 }
 /**
  * @covers ::getDefault
  */
 public function testGetDefaultGithub()
 {
     $gitConfig = $this->getMockBuilder('CL\\ComposerInit\\GitConfig')->getMock();
     $gitConfig->method('getOrigin')->willReturn('octocat/Hello-World');
     $github = new ClientMock();
     $github->queueResponse('github/repo.json');
     $prompt = new DescriptionPrompt($gitConfig, $github);
     $this->assertEquals('This your first repo!', $prompt->getDefault());
     $history = $github->getHistory();
     $this->assertEquals('/repos/octocat/Hello-World', (string) $history[0]['request']->getUri());
 }
 /**
  * @covers ::getPackageZipUrl
  */
 public function testGetPackageZipUrl()
 {
     $template = $this->getMockBuilder('CL\\ComposerInit\\Template')->disableOriginalConstructor()->getMock();
     $prompts = $this->getMockBuilder('CL\\ComposerInit\\Prompt\\Prompts')->disableOriginalConstructor()->getMock();
     $packagist = new ClientMock();
     $packagist->queueResponse('packagist/package.json');
     $command = new UseCommand($template, $prompts, $packagist);
     $url = $command->getPackageZipUrl('clippings/package-template');
     $expected = 'https://api.github.com/repos/clippings/package-template/zipball/60c22c4aa0ae0afc3b0d7176a7154a9f2a005c0c';
     $this->assertEquals($expected, $url);
     $history = $packagist->getHistory();
     $this->assertEquals('/packages/clippings/package-template.json', (string) $history[0]['request']->getUri());
 }
 /**
  * @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());
 }
 /**
  * @covers ::getDefaults
  */
 public function testGetDefaultsFull()
 {
     $gitConfig = $this->getMockBuilder('CL\\ComposerInit\\GitConfig')->getMock();
     $gitConfig->method('getOrigin')->willReturn('octocat/Hello-World');
     $gitConfig->method('get')->with($this->equalTo('user.name'))->willReturn('TEST_USER');
     $github = new ClientMock();
     $github->queueResponse('github/repo.json')->queueResponse('github/organization.json')->queueResponse('github/user.json');
     $prompt = new CopyrightPrompt($gitConfig, $github);
     $expected = ['github', 'monalisa octocat', 'TEST_USER', get_current_user()];
     $this->assertEquals($expected, $prompt->getDefaults());
     $history = $github->getHistory();
     $this->assertEquals('/repos/octocat/Hello-World', (string) $history[0]['request']->getUri());
     $this->assertEquals('/orgs/github', (string) $history[1]['request']->getUri());
     $this->assertEquals('/users/octocat', (string) $history[2]['request']->getUri());
 }