mirror of
https://github.com/composer/composer
synced 2025-05-09 00:22:53 +00:00
Add IOMock and get rid of all withConsecutive calls in tests (#11497)
This commit is contained in:
parent
ebd0a60411
commit
9f3e2105da
15 changed files with 394 additions and 265 deletions
|
@ -30,17 +30,10 @@ class GitHubTest extends TestCase
|
|||
public function testUsernamePasswordAuthenticationFlow(): void
|
||||
{
|
||||
$io = $this->getIOMock();
|
||||
$io
|
||||
->expects($this->atLeastOnce())
|
||||
->method('writeError')
|
||||
->withConsecutive([$this->message])
|
||||
;
|
||||
$io
|
||||
->expects($this->once())
|
||||
->method('askAndHideAnswer')
|
||||
->with('Token (hidden): ')
|
||||
->willReturn($this->password)
|
||||
;
|
||||
$io->expects([
|
||||
['text' => $this->message],
|
||||
['ask' => 'Token (hidden): ', 'reply' => $this->password],
|
||||
]);
|
||||
|
||||
$httpDownloader = $this->getHttpDownloaderMock();
|
||||
$httpDownloader->expects(
|
||||
|
@ -68,12 +61,9 @@ class GitHubTest extends TestCase
|
|||
public function testUsernamePasswordFailure(): void
|
||||
{
|
||||
$io = $this->getIOMock();
|
||||
$io
|
||||
->expects($this->exactly(1))
|
||||
->method('askAndHideAnswer')
|
||||
->with('Token (hidden): ')
|
||||
->willReturn($this->password)
|
||||
;
|
||||
$io->expects([
|
||||
['ask' => 'Token (hidden): ', 'reply' => $this->password],
|
||||
]);
|
||||
|
||||
$httpDownloader = $this->getHttpDownloaderMock();
|
||||
$httpDownloader->expects(
|
||||
|
@ -93,20 +83,6 @@ class GitHubTest extends TestCase
|
|||
$this->assertFalse($github->authorizeOAuthInteractively($this->origin));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \PHPUnit\Framework\MockObject\MockObject&\Composer\IO\ConsoleIO
|
||||
*/
|
||||
private function getIOMock()
|
||||
{
|
||||
$io = $this
|
||||
->getMockBuilder('Composer\IO\ConsoleIO')
|
||||
->disableOriginalConstructor()
|
||||
->getMock()
|
||||
;
|
||||
|
||||
return $io;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return \PHPUnit\Framework\MockObject\MockObject&\Composer\Config
|
||||
*/
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue