Skip to content

Commit 347c7ee

Browse files
committed
Improve test coverage
1 parent 7e268f2 commit 347c7ee

File tree

5 files changed

+106
-0
lines changed

5 files changed

+106
-0
lines changed

tests/Formatter/FormatterTest.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,14 @@ public function testGetUrlReturnsNullForInvalidOperation()
3333
$this->assertNull($formatter->getUrl(new DiffEntry($operation)));
3434
}
3535

36+
public function testGetProjectUrlReturnsNullForInvalidOperation()
37+
{
38+
$output = $this->getMockBuilder('Symfony\Component\Console\Output\OutputInterface')->getMock();
39+
$operation = $this->getMockBuilder('Composer\DependencyResolver\Operation\OperationInterface')->getMock();
40+
$formatter = $this->getFormatter($output, $this->getGenerators());
41+
$this->assertNull($formatter->getProjectUrl($operation));
42+
}
43+
3644
/**
3745
* @param bool $withUrls
3846
*

tests/Url/BitBucketGeneratorTest.php

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,32 @@ public function releaseUrlProvider()
3232
);
3333
}
3434

35+
public function projectUrlProvider()
36+
{
37+
return array(
38+
'with .git' => array(
39+
$this->getPackageWithSource('acme/package', '3.12.1', 'https://bitbucket.org/acme/package.git'),
40+
'https://bitbucket.org/acme/package',
41+
),
42+
'without .git' => array(
43+
$this->getPackageWithSource('acme/package', '3.12.1', 'https://bitbucket.org/acme/package'),
44+
'https://bitbucket.org/acme/package',
45+
),
46+
'ssh with .git' => array(
47+
$this->getPackageWithSource('acme/package', '3.12.1', 'git@bitbucket.org:acme/package.git'),
48+
'https://bitbucket.org/acme/package',
49+
),
50+
'ssh without .git' => array(
51+
$this->getPackageWithSource('acme/package', '3.12.1', 'git@bitbucket.org:acme/package'),
52+
'https://bitbucket.org/acme/package',
53+
),
54+
'dev version' => array(
55+
$this->getPackageWithSource('acme/package', 'dev-master', 'git@bitbucket.org:acme/package', 'd46283075d76ed244f7825b378eeb1cee246af73'),
56+
'https://bitbucket.org/acme/package',
57+
),
58+
);
59+
}
60+
3561
public function compareUrlProvider()
3662
{
3763
return array(

tests/Url/GeneratorTest.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,22 @@ public function testReleaseUrl(PackageInterface $package, $expectedUrl)
2828
$this->assertSame($expectedUrl, $this->getGenerator()->getReleaseUrl($package));
2929
}
3030

31+
/**
32+
* @param string|null $expectedUrl
33+
*
34+
* @dataProvider projectUrlProvider
35+
*/
36+
public function testProjectUrl(PackageInterface $package, $expectedUrl)
37+
{
38+
$this->assertSame($expectedUrl, $this->getGenerator()->getProjectUrl($package));
39+
}
40+
3141
abstract public function compareUrlProvider();
3242

3343
abstract public function releaseUrlProvider();
3444

45+
abstract public function projectUrlProvider();
46+
3547
/**
3648
* @return UrlGenerator
3749
*/

tests/Url/GithubGeneratorTest.php

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,32 @@ public function releaseUrlProvider()
3838
);
3939
}
4040

41+
public function projectUrlProvider()
42+
{
43+
return array(
44+
'with .git' => array(
45+
$this->getPackageWithSource('acme/package', '3.12.1', 'https://github.com/acme/package.git'),
46+
'https://github.com/acme/package',
47+
),
48+
'without .git' => array(
49+
$this->getPackageWithSource('acme/package', '3.12.1', 'https://github.com/acme/package'),
50+
'https://github.com/acme/package',
51+
),
52+
'ssh with .git' => array(
53+
$this->getPackageWithSource('acme/package', '3.12.1', 'git@github.com:acme/package.git'),
54+
'https://github.com/acme/package',
55+
),
56+
'ssh without .git' => array(
57+
$this->getPackageWithSource('acme/package', '3.12.1', 'git@github.com:acme/package'),
58+
'https://github.com/acme/package',
59+
),
60+
'dev version' => array(
61+
$this->getPackageWithSource('acme/package', 'dev-master', 'git@github.com:acme/package'),
62+
'https://github.com/acme/package',
63+
),
64+
);
65+
}
66+
4167
public function compareUrlProvider()
4268
{
4369
return array(

tests/Url/GitlabGeneratorTest.php

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,40 @@ public function releaseUrlProvider()
4040
);
4141
}
4242

43+
public function projectUrlProvider()
44+
{
45+
return array(
46+
'with .git' => array(
47+
$this->getPackageWithSource('acme/package', '3.12.1', 'https://gitlab.acme.org/acme/package.git'),
48+
'https://gitlab.acme.org/acme/package',
49+
),
50+
'without .git' => array(
51+
$this->getPackageWithSource('acme/package', '3.12.1', 'https://gitlab.acme.org/acme/package'),
52+
'https://gitlab.acme.org/acme/package',
53+
),
54+
'ssh with .git' => array(
55+
$this->getPackageWithSource('acme/package', '3.12.1', 'git@gitlab.acme.org:acme/package.git'),
56+
'https://gitlab.acme.org/acme/package',
57+
),
58+
'ssh without .git' => array(
59+
$this->getPackageWithSource('acme/package', '3.12.1', 'git@gitlab.acme.org:acme/package'),
60+
'https://gitlab.acme.org/acme/package',
61+
),
62+
'dev version' => array(
63+
$this->getPackageWithSource('acme/package', 'dev-master', 'git@gitlab.acme.org:ac/me/package'),
64+
'https://gitlab.acme.org/ac/me/package',
65+
),
66+
'https in subgroup' => array(
67+
$this->getPackageWithSource('ac/me/package', '3.12.1', 'https://gitlab.acme.org/ac/me/package.git'),
68+
'https://gitlab.acme.org/ac/me/package',
69+
),
70+
'ssh in subgroup' => array(
71+
$this->getPackageWithSource('ac/me/package', '3.12.1', 'git@gitlab.acme.org:ac/me/package.git'),
72+
'https://gitlab.acme.org/ac/me/package',
73+
),
74+
);
75+
}
76+
4377
public function compareUrlProvider()
4478
{
4579
return array(

0 commit comments

Comments
 (0)