-
-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add extension .phar to installed tools
- Loading branch information
Showing
7 changed files
with
182 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
<?php declare(strict_types=1); | ||
/* | ||
* This file is part of Phive. | ||
* | ||
* Copyright (c) Arne Blankerts <[email protected]>, Sebastian Heuer <[email protected]> and contributors | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
* | ||
*/ | ||
|
||
namespace PharIo\Phive; | ||
|
||
use PharIo\FileSystem\Directory; | ||
use PharIo\Version\AnyVersionConstraint; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
/** | ||
* @covers \PharIo\Phive\InstallCommandConfig | ||
*/ | ||
class InstallCommandTest extends TestCase | ||
{ | ||
use ScalarTestDataProvider; | ||
|
||
/** | ||
* @dataProvider boolProvider | ||
* | ||
* @param bool $switch | ||
*/ | ||
public function testAddingOfExtension($switch): void | ||
{ | ||
$pharName = $expectedPharName = 'some-path'; | ||
if ($switch) { | ||
$expectedPharName .= '.phar'; | ||
} | ||
|
||
$directory = $this->createMock(Directory::class); | ||
$directory | ||
->expects($this->once()) | ||
->method('file') | ||
->with($expectedPharName); | ||
|
||
$requestedPhars = [ | ||
new RequestedPhar( | ||
new PharAlias($pharName), | ||
new AnyVersionConstraint(), | ||
new AnyVersionConstraint(), | ||
null, | ||
true | ||
), | ||
]; | ||
|
||
$config = $this->createMock(InstallCommandConfig::class); | ||
$config | ||
->method('getTargetDirectory') | ||
->willReturn($directory); | ||
|
||
$config | ||
->method('getRequestedPhars') | ||
->willReturn($requestedPhars); | ||
|
||
$config | ||
->method('withExtension') | ||
->willReturn($switch); | ||
|
||
$installService = $this->createMock(InstallService::class); | ||
$sourceRepository = $this->createMock(SourceRepository::class); | ||
|
||
$pharResolver = $this->createMock(RequestedPharResolverService::class); | ||
$pharResolver | ||
->method('resolve') | ||
->willReturn($sourceRepository); | ||
|
||
$url = $this->createMock(PharUrl::class); | ||
$url | ||
->method('getPharName') | ||
->willReturn($pharName); | ||
|
||
$release = $this->createMock(SupportedRelease::class); | ||
$release | ||
->method('getUrl') | ||
->willReturn($url); | ||
|
||
$selector = $this->createMock(ReleaseSelector::class); | ||
$selector | ||
->method('select') | ||
->willReturn($release); | ||
|
||
$command = new InstallCommand($config, $installService, $pharResolver, $selector); | ||
$command->execute(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<?php declare(strict_types=1); | ||
/* | ||
* This file is part of Phive. | ||
* | ||
* Copyright (c) Arne Blankerts <[email protected]>, Sebastian Heuer <[email protected]> and contributors | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
* | ||
*/ | ||
namespace PharIo\Phive; | ||
|
||
use PHPUnit\Framework\TestCase; | ||
|
||
/** | ||
* @covers \PharIo\Phive\InstallContext | ||
*/ | ||
class InstallContextTest extends TestCase { | ||
/** | ||
* @dataProvider knownOptionCharProvider | ||
* | ||
* @param string $optionChar | ||
*/ | ||
public function testHasOptionForChar($optionChar): void | ||
{ | ||
$context = new InstallContext(); | ||
self::assertTrue($context->hasOptionForChar($optionChar)); | ||
} | ||
|
||
/** | ||
* @dataProvider knowsOptionProvider | ||
* | ||
* @param string $option | ||
*/ | ||
public function testKnowsOption($option): void | ||
{ | ||
$context = new InstallContext(); | ||
self::assertTrue($context->knowsOption($option)); | ||
} | ||
|
||
public function knowsOptionProvider(): array { | ||
return [ | ||
['extension'], | ||
]; | ||
} | ||
|
||
public function knownOptionCharProvider(): array { | ||
return [ | ||
['e'], | ||
]; | ||
} | ||
} |