Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to symfony/console 6.0 and newer version of phpunit #61

Merged
merged 5 commits into from
Feb 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 1 addition & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,9 @@ jobs:
strategy:
matrix:
include:
- php: '7.0'
mode: low-deps
- php: '7.1'
- php: '7.2'
- php: '7.4'
- php: '8.1'
- php: '8.0'
- php: '8.1'
mode: low-deps
fail-fast: false

runs-on: ubuntu-latest
Expand Down
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@
}
},
"require": {
"php": ">=7.0",
"symfony/console": "~3.0|~4.0|~5.0",
"php": ">=7.4",
"symfony/console": "~3.0|~4.0|~5.0|~6.0",
"php-di/invoker": "~2.0",
"psr/container": "^1.0|^2.0"
},
"require-dev": {
"phpunit/phpunit": "~6.4",
"phpunit/phpunit": "^6.4|^7|^8|^9",
"mnapoli/phpunit-easymock": "~1.0",
"friendsofphp/php-cs-fixer": "^2.12"
}
Expand Down
2 changes: 1 addition & 1 deletion tests/ApplicationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class ApplicationTest extends TestCase
*/
private $application;

public function setUp()
public function setUp(): void
{
$this->application = new Application();
$this->application->setAutoExit(false);
Expand Down
11 changes: 7 additions & 4 deletions tests/Command/CommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use PHPUnit\Framework\TestCase;
use Silly\Application;
use Silly\Command\Command;
use InvalidArgumentException;

class CommandTest extends TestCase
{
Expand All @@ -18,7 +19,7 @@ class CommandTest extends TestCase
*/
private $command;

public function setUp()
public function setUp(): void
{
$this->application = new Application();
$this->application->setAutoExit(false);
Expand Down Expand Up @@ -118,10 +119,11 @@ public function setting_defaults_falls_back_to_options_when_no_argument_exists()

/**
* @test
* @expectedException \InvalidArgumentException
*
*/
public function setting_unknown_defaults_throws_an_exception()
{
$this->expectException(InvalidArgumentException::class);
$this->command->defaults([
'doesnotexist' => '0',
]);
Expand All @@ -132,17 +134,18 @@ public function setting_unknown_defaults_throws_an_exception()
*/
public function reflecting_defaults_for_nonexistant_inputs_does_not_throw_an_exception()
{
$this->application->command('greet [name]', [new GreetCommand, 'greet']);
$this->expectNotToPerformAssertions();

$this->application->command('greet [name]', [new GreetCommand, 'greet']);
// An exception was thrown previously about the argument / option `times` not existing.
}

/**
* @test
* @expectedException InvalidArgumentException
*/
public function a_command_with_an_invalid_static_callable_show_throw_an_exception()
{
$this->expectException(InvalidArgumentException::class);
$this->application->command('greet [name]', [GreetCommand::class, 'greet']);
}
}
Expand Down
5 changes: 3 additions & 2 deletions tests/Command/ExpressionParserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use Silly\Command\ExpressionParser;
use Silly\Input\InputArgument;
use Silly\Input\InputOption;
use Silly\Command\InvalidCommandExpression;

class ExpressionParserTest extends TestCase
{
Expand Down Expand Up @@ -151,11 +152,11 @@ public function it_parses_options_with_shortcuts()

/**
* @test
* @expectedException \Silly\Command\InvalidCommandExpression
* @expectedExceptionMessage An option must be enclosed by brackets: [--option]
*/
public function it_provides_an_error_message_on_options_missing_brackets()
{
$this->expectExceptionMessage("An option must be enclosed by brackets: [--option]");
$this->expectException(InvalidCommandExpression::class);
$parser = new ExpressionParser();
$parser->parse('greet --yell');
}
Expand Down
16 changes: 9 additions & 7 deletions tests/FunctionalTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
use Symfony\Component\Console\Output\Output;
use Symfony\Component\Console\Output\OutputInterface as Out;
use Symfony\Component\Console\Style\SymfonyStyle;
use RuntimeException;
use InvalidArgumentException;

class FunctionalTest extends TestCase
{
Expand All @@ -21,7 +23,7 @@ class FunctionalTest extends TestCase
*/
private $application;

public function setUp()
public function setUp(): void
{
$this->application = new Application();
$this->application->setAutoExit(false);
Expand Down Expand Up @@ -381,33 +383,33 @@ public function it_should_run_a_subcommand()

/**
* @test
* @expectedException \RuntimeException
* @expectedExceptionMessage Impossible to call the 'greet' command: Unable to invoke the callable because no value was given for parameter 1 ($foo)
*/
public function it_should_throw_if_a_parameter_cannot_be_resolved()
{
$this->expectExceptionMessage('Impossible to call the \'greet\' command: Unable to invoke the callable because no value was given for parameter 1 ($foo)');
$this->expectException(RuntimeException::class);
$this->application->command('greet', function (stdClass $foo) {});
$this->assertOutputIs('greet', '');
}

/**
* @test
* @expectedException \RuntimeException
* @expectedExceptionMessage Impossible to call the 'greet' command: 'foo' is not a callable
*/
public function it_should_throw_if_the_command_is_not_a_callable()
{
$this->expectExceptionMessage("Impossible to call the 'greet' command: 'foo' is not a callable");
$this->expectException(RuntimeException::class);
$this->application->command('greet', 'foo');
$this->assertOutputIs('greet', '');
}

/**
* @test
* @expectedException \InvalidArgumentException
* @expectedExceptionMessage ['Silly\Test\FunctionalTest', 'foo'] is not a callable because 'foo' is a static method. Either use [new Silly\Test\FunctionalTest(), 'foo'] or configure a dependency injection container that supports autowiring like PHP-DI.
*/
public function it_should_throw_if_the_command_is_a_method_call_to_a_static_method()
{
$this->expectExceptionMessage("['Silly\Test\FunctionalTest', 'foo'] is not a callable because 'foo' is a static method. Either use [new Silly\Test\FunctionalTest(), 'foo'] or configure a dependency injection container that supports autowiring like PHP-DI.");
$this->expectException(InvalidArgumentException::class);
$this->application->command('greet', [__CLASS__, 'foo']);
$this->assertOutputIs('greet', '');
}
Expand Down
2 changes: 1 addition & 1 deletion tests/Mock/ArrayContainer.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public function get($id)
return $this->entries[$id];
}

public function has($id)
public function has($id): bool
{
return isset($this->entries[$id]);
}
Expand Down