Skip to content

Commit

Permalink
Add more on the provider factory test
Browse files Browse the repository at this point in the history
  • Loading branch information
eiriksm committed Aug 29, 2020
1 parent 2b895b7 commit a2dc644
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 12 deletions.
8 changes: 0 additions & 8 deletions src/ProcessWrapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,6 @@ class ProcessWrapper extends Process
*/
protected $executor;

/**
* @return CommandExecuter
*/
public function getExecutor()
{
return $this->executor;
}

/**
* @param CommandExecuter $executor
*/
Expand Down
42 changes: 38 additions & 4 deletions test/unit/ProviderFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,51 @@
namespace eiriksm\CosyComposerTest\unit;

use eiriksm\CosyComposer\ProviderFactory;
use eiriksm\CosyComposer\Providers\Bitbucket;
use eiriksm\CosyComposer\Providers\Github;
use eiriksm\CosyComposer\Providers\Gitlab;
use eiriksm\CosyComposer\Providers\SelfHostedGitlab;
use PHPUnit\Framework\TestCase;
use Violinist\Slug\Slug;

class ProviderFactoryTest extends TestCase
{
public function testCreateFromHost()
/**
* @dataProvider getHostAndClass
*/
public function testCreateFromHost($url, $class)
{
if ($url === 'https://bitbucket.org/eiriksm/cosy-composer' && version_compare(phpversion(), "7.1.0", "<=")) {
$this->assertTrue(true, 'Skipping bitbucket test for version ' . phpversion());
return;
}
$pf = new ProviderFactory();
$slug = Slug::createFromUrl('https://github.com/eiriksm/cosy-composer');
$provider = $pf->createFromHost($slug, []);
$this->assertEquals(get_class($provider), Github::class);
$slug = Slug::createFromUrl($url);
$url_array = parse_url($url);
$url_array['port'] = 443;
$provider = $pf->createFromHost($slug, $url_array);
$this->assertEquals(get_class($provider), $class);
}

public function getHostAndClass()
{
return [
[
'https://github.com/eiriksm/cosy-composer',
Github::class
],
[
'https://gitlab.com/eiriksm/cosy-composer',
Gitlab::class
],
[
'https://bitbucket.org/eiriksm/cosy-composer',
Bitbucket::class
],
[
'https://example.com/eiriksm/cosy-composer',
SelfHostedGitlab::class
],
];
}
}

0 comments on commit a2dc644

Please sign in to comment.