Skip to content

Commit

Permalink
Merge pull request #93 from pechondra/3813-new-nette-requirements
Browse files Browse the repository at this point in the history
Use newer composer requirements for nette/utils and symfony/console
  • Loading branch information
Spamercz committed Aug 20, 2021
2 parents cee7512 + dd4d395 commit 143e022
Show file tree
Hide file tree
Showing 15 changed files with 89 additions and 21 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/php-package-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ jobs:
- uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php }}
extensions: iconv
env:
COMPOSER_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- run: make composer

Expand Down
8 changes: 6 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@ cs:
vendor/bin/parallel-lint -e php,phpt --exclude vendor .

phpstan:
vendor/bin/phpstan analyse src tests/KdybyTests
vendor/bin/phpstan analyse -l 2 -c phpstan.neon src tests/KdybyTests

phpstan-generate-baseline:
git clean -xdf tests/
php -d memory_limit=-1 vendor/bin/phpstan.phar analyse -l 2 -c phpstan.neon src tests/KdybyTests --no-progress --generate-baseline

tester:
vendor/bin/tester -s -c ./tests/php.ini-unix ./tests/KdybyTests/
vendor/bin/tester -s -C ./tests/KdybyTests/
6 changes: 3 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,16 @@
"nette/di": "^3.0",
"nette/routing": "^3.0.0",
"tracy/tracy": "^2.8 || ^3.0",
"nette/utils": "^3.0",
"symfony/console": "~2.3 || ^3.0 || ^4.0"
"nette/utils": "^3.1",
"symfony/console": "~2.3 || ^3.0 || < 4.3"
},
"require-dev": {
"nette/application": "^3.0",
"nette/bootstrap": "^3.0",
"nette/caching": "^3.0",
"nette/http": "^3.0",
"kdyby/events": "dev-patch-1 as 3.2.99",
"symfony/event-dispatcher": "~2.3 || ^3.0 || ^4.0",
"symfony/event-dispatcher": "~2.3 || ^3.0 || < 4.3",

"nette/tester": "^2.2",
"phpstan/phpstan": "^0.12.88",
Expand Down
12 changes: 12 additions & 0 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
parameters:
ignoreErrors:
-
message: "#^Call to an undefined method Nette\\\\Application\\\\Application\\:\\:onError\\(\\)\\.$#"
count: 1
path: src/Application.php

-
message: "#^Callable callable\\(Nette\\\\Application\\\\Application, Throwable\\|null\\)\\: void invoked with 1 parameter, 2 required\\.$#"
count: 1
path: src/CliResponse.php

3 changes: 3 additions & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,6 @@ parameters:

excludes_analyse:
- *src/DI/ClassAliasMap.php

includes:
- phpstan-baseline.neon
22 changes: 10 additions & 12 deletions tests/KdybyTests/Console/ApplicationTest.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,6 @@

declare(strict_types = 1);

/**
* Test: Kdyby\Console\Application.
*
* @testCase
*/

namespace KdybyTests\Console;

use Kdyby\Console\Application;
Expand All @@ -17,10 +11,14 @@ use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Command\ListCommand;
use Symfony\Component\Console\Tester\ApplicationTester;
use Tester\Assert;
use Tester\Environment as TesterEnvironment;

require_once __DIR__ . '/../bootstrap.php';

/**
* Test: Kdyby\Console\Application.
*
* @testCase
*/
class ApplicationTest extends \Tester\TestCase
{

Expand Down Expand Up @@ -54,18 +52,18 @@ class ApplicationTest extends \Tester\TestCase
$app = $container->getByType(Application::class);
$tester = new ApplicationTester($app);

Assert::same(0, $tester->run(['list']));
Assert::same(0, $tester->run(['command' => 'list']));
Assert::same([
['command', ListCommand::class],
['terminate', ListCommand::class, 0],
], $listener->calls);
}

/**
* @phpVersion >= 7.0
*/
public function testRenderThrowable(): void
{
if (PHP_VERSION_ID < 70000) {
TesterEnvironment::skip('Testing throwable is only relevant with PHP >= 7.0');
}

/** @var \Nette\DI\Container $container */
$container = $this->prepareConfigurator()->createContainer();
Expand All @@ -80,7 +78,7 @@ class ApplicationTest extends \Tester\TestCase
$app->add($command);

$tester = new ApplicationTester($app);
$exitCode = $tester->run(['fail']);
$exitCode = $tester->run(['command' => 'fail']);
Assert::same(42, $exitCode);

$output = $tester->getDisplay();
Expand Down
8 changes: 4 additions & 4 deletions tests/KdybyTests/Console/InputErrorsTest.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class InputErrorsTest extends \Tester\TestCase
{
$config = new Configurator();
$config->setTempDirectory(TEMP_DIR);
$config->addParameters(['container' => ['class' => 'SystemContainer_' . md5((string) mt_rand())]]);
$config->addParameters(['container' => ['class' => 'SystemContainer_' . md5((string)mt_rand())]]);
$config->onCompile[] = static function ($config, \Nette\DI\Compiler $compiler): void {
$compiler->addExtension('console', new \Kdyby\Console\DI\ConsoleExtension());
};
Expand Down Expand Up @@ -58,7 +58,7 @@ class InputErrorsTest extends \Tester\TestCase
$app = $container->getByType(Application::class);
$tester = new ApplicationTester($app);

Assert::same(Application::INPUT_ERROR_EXIT_CODE, $tester->run(['tipo']));
Assert::same(Application::INPUT_ERROR_EXIT_CODE, $tester->run(['command' => 'tipo']));
Assert::same([], $listener->calls);
}

Expand All @@ -68,8 +68,8 @@ class InputErrorsTest extends \Tester\TestCase
public function getAmbiguousCommandData(): array
{
return [
[['ambiguous'], '%a%ambiguous%a%'],
[['name:ambi'], '%a%ambiguous%a%'],
[['command' => 'ambiguous'], '%a%ambiguous%a%'],
[['command' => 'name:ambi'], '%a%ambiguous%a%'],
];
}

Expand Down
6 changes: 6 additions & 0 deletions tests/KdybyTests/Console/data/AmbiguousCommand1.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ protected function configure()
$this->setName('ambiguous1');
}

/**
* @param InputInterface $input
* @param OutputInterface $output
* @return void
* @throws \Tester\AssertException
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
Assert::fail("This command shouldn't have been executed.");
Expand Down
6 changes: 6 additions & 0 deletions tests/KdybyTests/Console/data/AmbiguousCommand2.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ protected function configure()
$this->setName('ambiguous2');
}

/**
* @param InputInterface $input
* @param OutputInterface $output
* @return void
* @throws \Tester\AssertException
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
Assert::fail("This command shouldn't have been executed.");
Expand Down
6 changes: 6 additions & 0 deletions tests/KdybyTests/Console/data/ArgCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ protected function configure()
->addOption('no-value', 'x', InputOption::VALUE_NONE);
}

/**
* @param InputInterface $input
* @param OutputInterface $output
* @return void
* @throws \Tester\AssertException
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
Assert::fail("This command shouldn't have been executed.");
Expand Down
6 changes: 6 additions & 0 deletions tests/KdybyTests/Console/data/NamespaceAmbiguousCommand1.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ protected function configure()
$this->setName('namespace1:ambiguous');
}

/**
* @param InputInterface $input
* @param OutputInterface $output
* @return void
* @throws \Tester\AssertException
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
Assert::fail("This command shouldn't have been executed.");
Expand Down
6 changes: 6 additions & 0 deletions tests/KdybyTests/Console/data/NamespaceAmbiguousCommand2.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ protected function configure()
$this->setName('namespace2:ambiguous');
}

/**
* @param InputInterface $input
* @param OutputInterface $output
* @return void
* @throws \Tester\AssertException
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
Assert::fail("This command shouldn't have been executed.");
Expand Down
6 changes: 6 additions & 0 deletions tests/KdybyTests/Console/data/SameArgsCommandOne.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@ protected function configure()
$this->setName('sameArgsCommand:one');
}

/**
* @param InputInterface $input
* @param OutputInterface $output
* @return void
* @throws \Tester\AssertException
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
Assert::fail("This command shouldn't have been executed.");
Expand Down
6 changes: 6 additions & 0 deletions tests/KdybyTests/Console/data/SameArgsCommandTwo.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@ protected function configure()
$this->setName('sameArgsCommand:two');
}

/**
* @param InputInterface $input
* @param OutputInterface $output
* @return void
* @throws \Tester\AssertException
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
Assert::fail("This command shouldn't have been executed.");
Expand Down
6 changes: 6 additions & 0 deletions tests/KdybyTests/Console/data/TypoCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,12 @@ protected function configure()
$this->setName('typo');
}

/**
* @param InputInterface $input
* @param OutputInterface $output
* @return void
* @throws \Tester\AssertException
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
Assert::fail("This command shouldn't have been executed.");
Expand Down

0 comments on commit 143e022

Please sign in to comment.