mirror of
https://github.com/composer/composer
synced 2025-05-09 00:22:53 +00:00
Minor fixes and updated the rest of the code/tests to use HttpDownloader
This commit is contained in:
parent
56805ecafe
commit
713bc4de1d
51 changed files with 461 additions and 436 deletions
|
@ -14,6 +14,7 @@ namespace Composer\Test\Util;
|
|||
|
||||
use Composer\Downloader\TransportException;
|
||||
use Composer\Util\GitHub;
|
||||
use Composer\Util\Http\Response;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use RecursiveArrayIterator;
|
||||
use RecursiveIteratorIterator;
|
||||
|
@ -45,17 +46,15 @@ class GitHubTest extends TestCase
|
|||
->willReturn($this->password)
|
||||
;
|
||||
|
||||
$rfs = $this->getRemoteFilesystemMock();
|
||||
$rfs
|
||||
$httpDownloader = $this->getHttpDownloaderMock();
|
||||
$httpDownloader
|
||||
->expects($this->once())
|
||||
->method('getContents')
|
||||
->method('get')
|
||||
->with(
|
||||
$this->equalTo($this->origin),
|
||||
$this->equalTo(sprintf('https://api.%s/', $this->origin)),
|
||||
$this->isFalse(),
|
||||
$this->equalTo($url = sprintf('https://api.%s/', $this->origin)),
|
||||
$this->anything()
|
||||
)
|
||||
->willReturn('{}')
|
||||
->willReturn(new Response(array('url' => $url), 200, array(), '{}'));
|
||||
;
|
||||
|
||||
$config = $this->getConfigMock();
|
||||
|
@ -70,7 +69,7 @@ class GitHubTest extends TestCase
|
|||
->willReturn($this->getConfJsonMock())
|
||||
;
|
||||
|
||||
$github = new GitHub($io, $config, null, $rfs);
|
||||
$github = new GitHub($io, $config, null, $httpDownloader);
|
||||
|
||||
$this->assertTrue($github->authorizeOAuthInteractively($this->origin, $this->message));
|
||||
}
|
||||
|
@ -85,10 +84,10 @@ class GitHubTest extends TestCase
|
|||
->willReturn($this->password)
|
||||
;
|
||||
|
||||
$rfs = $this->getRemoteFilesystemMock();
|
||||
$rfs
|
||||
$httpDownloader = $this->getHttpDownloaderMock();
|
||||
$httpDownloader
|
||||
->expects($this->exactly(1))
|
||||
->method('getContents')
|
||||
->method('get')
|
||||
->will($this->throwException(new TransportException('', 401)))
|
||||
;
|
||||
|
||||
|
@ -99,7 +98,7 @@ class GitHubTest extends TestCase
|
|||
->willReturn($this->getAuthJsonMock())
|
||||
;
|
||||
|
||||
$github = new GitHub($io, $config, null, $rfs);
|
||||
$github = new GitHub($io, $config, null, $httpDownloader);
|
||||
|
||||
$this->assertFalse($github->authorizeOAuthInteractively($this->origin));
|
||||
}
|
||||
|
@ -120,15 +119,15 @@ class GitHubTest extends TestCase
|
|||
return $this->getMockBuilder('Composer\Config')->getMock();
|
||||
}
|
||||
|
||||
private function getRemoteFilesystemMock()
|
||||
private function getHttpDownloaderMock()
|
||||
{
|
||||
$rfs = $this
|
||||
->getMockBuilder('Composer\Util\RemoteFilesystem')
|
||||
$httpDownloader = $this
|
||||
->getMockBuilder('Composer\Util\HttpDownloader')
|
||||
->disableOriginalConstructor()
|
||||
->getMock()
|
||||
;
|
||||
|
||||
return $rfs;
|
||||
return $httpDownloader;
|
||||
}
|
||||
|
||||
private function getAuthJsonMock()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue