Skip to content

Commit

Permalink
Improve test coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
giggsey committed Jan 6, 2022
1 parent 7e268f2 commit 347c7ee
Show file tree
Hide file tree
Showing 5 changed files with 106 additions and 0 deletions.
8 changes: 8 additions & 0 deletions tests/Formatter/FormatterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,14 @@ public function testGetUrlReturnsNullForInvalidOperation()
$this->assertNull($formatter->getUrl(new DiffEntry($operation)));
}

public function testGetProjectUrlReturnsNullForInvalidOperation()
{
$output = $this->getMockBuilder('Symfony\Component\Console\Output\OutputInterface')->getMock();
$operation = $this->getMockBuilder('Composer\DependencyResolver\Operation\OperationInterface')->getMock();
$formatter = $this->getFormatter($output, $this->getGenerators());
$this->assertNull($formatter->getProjectUrl($operation));
}

/**
* @param bool $withUrls
*
Expand Down
26 changes: 26 additions & 0 deletions tests/Url/BitBucketGeneratorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,32 @@ public function releaseUrlProvider()
);
}

public function projectUrlProvider()
{
return array(
'with .git' => array(
$this->getPackageWithSource('acme/package', '3.12.1', 'https://bitbucket.org/acme/package.git'),
'https://bitbucket.org/acme/package',
),
'without .git' => array(
$this->getPackageWithSource('acme/package', '3.12.1', 'https://bitbucket.org/acme/package'),
'https://bitbucket.org/acme/package',
),
'ssh with .git' => array(
$this->getPackageWithSource('acme/package', '3.12.1', '[email protected]:acme/package.git'),
'https://bitbucket.org/acme/package',
),
'ssh without .git' => array(
$this->getPackageWithSource('acme/package', '3.12.1', '[email protected]:acme/package'),
'https://bitbucket.org/acme/package',
),
'dev version' => array(
$this->getPackageWithSource('acme/package', 'dev-master', '[email protected]:acme/package', 'd46283075d76ed244f7825b378eeb1cee246af73'),
'https://bitbucket.org/acme/package',
),
);
}

public function compareUrlProvider()
{
return array(
Expand Down
12 changes: 12 additions & 0 deletions tests/Url/GeneratorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,22 @@ public function testReleaseUrl(PackageInterface $package, $expectedUrl)
$this->assertSame($expectedUrl, $this->getGenerator()->getReleaseUrl($package));
}

/**
* @param string|null $expectedUrl
*
* @dataProvider projectUrlProvider
*/
public function testProjectUrl(PackageInterface $package, $expectedUrl)
{
$this->assertSame($expectedUrl, $this->getGenerator()->getProjectUrl($package));
}

abstract public function compareUrlProvider();

abstract public function releaseUrlProvider();

abstract public function projectUrlProvider();

/**
* @return UrlGenerator
*/
Expand Down
26 changes: 26 additions & 0 deletions tests/Url/GithubGeneratorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,32 @@ public function releaseUrlProvider()
);
}

public function projectUrlProvider()
{
return array(
'with .git' => array(
$this->getPackageWithSource('acme/package', '3.12.1', 'https://github.com/acme/package.git'),
'https://github.com/acme/package',
),
'without .git' => array(
$this->getPackageWithSource('acme/package', '3.12.1', 'https://github.com/acme/package'),
'https://github.com/acme/package',
),
'ssh with .git' => array(
$this->getPackageWithSource('acme/package', '3.12.1', '[email protected]:acme/package.git'),
'https://github.com/acme/package',
),
'ssh without .git' => array(
$this->getPackageWithSource('acme/package', '3.12.1', '[email protected]:acme/package'),
'https://github.com/acme/package',
),
'dev version' => array(
$this->getPackageWithSource('acme/package', 'dev-master', '[email protected]:acme/package'),
'https://github.com/acme/package',
),
);
}

public function compareUrlProvider()
{
return array(
Expand Down
34 changes: 34 additions & 0 deletions tests/Url/GitlabGeneratorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,40 @@ public function releaseUrlProvider()
);
}

public function projectUrlProvider()
{
return array(
'with .git' => array(
$this->getPackageWithSource('acme/package', '3.12.1', 'https://gitlab.acme.org/acme/package.git'),
'https://gitlab.acme.org/acme/package',
),
'without .git' => array(
$this->getPackageWithSource('acme/package', '3.12.1', 'https://gitlab.acme.org/acme/package'),
'https://gitlab.acme.org/acme/package',
),
'ssh with .git' => array(
$this->getPackageWithSource('acme/package', '3.12.1', '[email protected]:acme/package.git'),
'https://gitlab.acme.org/acme/package',
),
'ssh without .git' => array(
$this->getPackageWithSource('acme/package', '3.12.1', '[email protected]:acme/package'),
'https://gitlab.acme.org/acme/package',
),
'dev version' => array(
$this->getPackageWithSource('acme/package', 'dev-master', '[email protected]:ac/me/package'),
'https://gitlab.acme.org/ac/me/package',
),
'https in subgroup' => array(
$this->getPackageWithSource('ac/me/package', '3.12.1', 'https://gitlab.acme.org/ac/me/package.git'),
'https://gitlab.acme.org/ac/me/package',
),
'ssh in subgroup' => array(
$this->getPackageWithSource('ac/me/package', '3.12.1', '[email protected]:ac/me/package.git'),
'https://gitlab.acme.org/ac/me/package',
),
);
}

public function compareUrlProvider()
{
return array(
Expand Down

0 comments on commit 347c7ee

Please sign in to comment.