1
0
Fork 0
mirror of https://github.com/composer/composer synced 2025-05-09 00:22:53 +00:00

VcsRepositories: handle initialize with invalid repository URL (#10525)

This commit is contained in:
Stephan 2022-02-16 08:37:36 +00:00 committed by GitHub
parent 6698317342
commit 3eb12efae5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 63 additions and 5 deletions

View file

@ -218,6 +218,14 @@ class GitBitbucketDriverTest extends TestCase
);
}
public function testInitializeInvalidRepositoryUrl()
{
$this->setExpectedException('\InvalidArgumentException');
$driver = $this->getDriver(array('url' => 'https://bitbucket.org/acme'));
$driver->initialize();
}
public function testSupports()
{
$this->assertTrue(

View file

@ -14,11 +14,11 @@ namespace Composer\Test\Repository\Vcs;
use Composer\Downloader\TransportException;
use Composer\Repository\Vcs\GitHubDriver;
use Composer\Test\Mock\ProcessExecutorMock;
use Composer\Test\TestCase;
use Composer\Util\Filesystem;
use Composer\Util\Http\Response;
use Composer\Test\Mock\ProcessExecutorMock;
use Composer\Config;
use Composer\Util\Http\Response;
use Composer\Util\ProcessExecutor;
class GitHubDriverTest extends TestCase
@ -341,6 +341,50 @@ class GitHubDriverTest extends TestCase
$process->assertComplete($this);
}
/**
* @return void
*/
public function initializeInvalidReoUrl()
{
$this->setExpectedException('\InvalidArgumentException');
$repoConfig = array(
'url' => 'https://github.com/acme',
);
$io = $this->getMockBuilder('Composer\IO\IOInterface')->getMock();
$httpDownloader = $this->getMockBuilder('Composer\Util\HttpDownloader')
->setConstructorArgs(array($io, $this->config))
->getMock();
$gitHubDriver = new GitHubDriver($repoConfig, $io, $this->config, $httpDownloader, new ProcessExecutorMock);
$gitHubDriver->initialize();
}
/**
* @dataProvider supportsProvider
* @param bool $expected
* @param string $repoUrl
*/
public function testSupports($expected, $repoUrl)
{
$io = $this->getMockBuilder('Composer\IO\IOInterface')->getMock();
$this->assertSame($expected, GitHubDriver::supports($io, $this->config, $repoUrl));
}
/**
* @return list<array{bool, string}>
*/
public function supportsProvider()
{
return array(
array(false, 'https://github.com/acme'),
array(true, 'https://github.com/acme/repository'),
array(true, 'git@github.com:acme/repository.git'),
);
}
/**
* @param string|object $object
* @param string $attribute