mirror of
https://github.com/php/pie.git
synced 2026-03-23 23:12:17 +01:00
Added happy and sad tests for resolving a requested package and version
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1,4 +1,5 @@
|
||||
/vendor/
|
||||
/psalm.xml
|
||||
/.phpunit.cache/
|
||||
/.phpunit.result.cache
|
||||
/.phpcs-cache
|
||||
|
||||
@@ -26,7 +26,9 @@
|
||||
],
|
||||
"require": {
|
||||
"php": "8.1.*||8.2.*||8.3.*",
|
||||
"symfony/console": "^6.4"
|
||||
"composer/composer": "^2.7",
|
||||
"symfony/console": "^6.4",
|
||||
"webmozart/assert": "^1.11"
|
||||
},
|
||||
"require-dev": {
|
||||
"doctrine/coding-standard": "^12.0",
|
||||
|
||||
1865
composer.lock
generated
1865
composer.lock
generated
File diff suppressed because it is too large
Load Diff
@@ -8,21 +8,52 @@ use Php\Pie\Command\DownloadCommand;
|
||||
use PHPUnit\Framework\Attributes\CoversClass;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\Console\Output\BufferedOutput;
|
||||
use Throwable;
|
||||
|
||||
use const PHP_VERSION;
|
||||
use const PHP_VERSION_ID;
|
||||
|
||||
#[CoversClass(DownloadCommand::class)]
|
||||
class DownloadCommandTest extends TestCase
|
||||
{
|
||||
public function testDownloadCommand(): void
|
||||
{
|
||||
$input = $this->createMock(InputInterface::class);
|
||||
$output = $this->createMock(OutputInterface::class);
|
||||
$input = $this->createMock(InputInterface::class);
|
||||
$input->expects(self::once())
|
||||
->method('getArgument')
|
||||
->with('requested-package-and-version')
|
||||
->willReturn('ramsey/uuid');
|
||||
|
||||
$output->expects(self::once())
|
||||
->method('writeln')
|
||||
->with('<info>to do</info>');
|
||||
$output = new BufferedOutput();
|
||||
|
||||
$command = new DownloadCommand();
|
||||
self::assertSame(0, $command->execute($input, $output));
|
||||
|
||||
$outputString = $output->fetch();
|
||||
self::assertStringContainsString('Found package: ramsey/uuid (version: ', $outputString);
|
||||
self::assertStringContainsString('Dist download URL: https://api.github.com/repos/ramsey/uuid/zipball/', $outputString);
|
||||
}
|
||||
|
||||
public function testDownloadCommandFailsWhenUsingIncompatiblePhpVersion(): void
|
||||
{
|
||||
if (PHP_VERSION_ID >= 80200) {
|
||||
self::markTestSkipped('This test can only run on older than PHP 8.2 - you are running ' . PHP_VERSION);
|
||||
}
|
||||
|
||||
$input = $this->createMock(InputInterface::class);
|
||||
$input->expects(self::once())
|
||||
->method('getArgument')
|
||||
->with('requested-package-and-version')
|
||||
->willReturn('phpunit/phpunit:^11.0');
|
||||
|
||||
$output = new BufferedOutput();
|
||||
|
||||
$command = new DownloadCommand();
|
||||
|
||||
// @todo narrow this down to our true expected failure;
|
||||
// i.e. phpunit/phpunit:^11.0 should NOT be installable on PHP 8.1
|
||||
$this->expectException(Throwable::class);
|
||||
$command->execute($input, $output);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user