From 177f1ec6ea8de322f5f92865f57b156b23d69bc3 Mon Sep 17 00:00:00 2001 From: David Grudl Date: Wed, 15 Jan 2020 04:20:28 +0100 Subject: [PATCH 01/11] RoutingPanel: fixed compatibility with new RouteList --- src/Bridges/ApplicationTracy/RoutingPanel.php | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/Bridges/ApplicationTracy/RoutingPanel.php b/src/Bridges/ApplicationTracy/RoutingPanel.php index 449eeba6a..7cf1a8ff2 100644 --- a/src/Bridges/ApplicationTracy/RoutingPanel.php +++ b/src/Bridges/ApplicationTracy/RoutingPanel.php @@ -99,8 +99,10 @@ public function getPanel(): string private function analyse(Nette\Routing\Router $router, string $module = ''): void { if ($router instanceof Routers\RouteList) { - foreach ($router as $subRouter) { - $this->analyse($subRouter, $module . $router->getModule()); + if ($router->match($this->httpRequest)) { + foreach ($router as $subRouter) { + $this->analyse($subRouter, $module . $router->getModule()); + } } return; } From 2961c97c825a97487a348955a18931c45677d971 Mon Sep 17 00:00:00 2001 From: David Grudl Date: Tue, 7 Jan 2020 11:40:34 +0100 Subject: [PATCH 02/11] composer: license clarification --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 8e7d7fa14..999818939 100644 --- a/composer.json +++ b/composer.json @@ -3,7 +3,7 @@ "description": "🏆 Nette Application: a full-stack component-based MVC kernel for PHP that helps you write powerful and modern web applications. Write less, have cleaner code and your work will bring you joy.", "keywords": ["nette", "mvc", "framework", "component-based", "routing", "seo", "mvp", "presenter", "control", "forms"], "homepage": "https://nette.org", - "license": ["BSD-3-Clause", "GPL-2.0", "GPL-3.0"], + "license": ["BSD-3-Clause", "GPL-2.0-only", "GPL-3.0-only"], "authors": [ { "name": "David Grudl", From ccc9441f2600aa594cedbf2328b13ac8e007d4f0 Mon Sep 17 00:00:00 2001 From: David Grudl Date: Tue, 7 Jan 2020 17:50:36 +0100 Subject: [PATCH 03/11] class aliases are loaded on demand --- composer.json | 3 +-- src/Application/UI/Component.php | 3 +++ src/Application/UI/ComponentReflection.php | 3 +++ src/compatibility.php | 21 +++++++++++++++++++-- 4 files changed, 26 insertions(+), 4 deletions(-) diff --git a/composer.json b/composer.json index 999818939..289359cf4 100644 --- a/composer.json +++ b/composer.json @@ -43,8 +43,7 @@ "tracy/tracy": "<2.5" }, "autoload": { - "classmap": ["src/"], - "files": ["src/compatibility.php"] + "classmap": ["src/"] }, "minimum-stability": "dev", "scripts": { diff --git a/src/Application/UI/Component.php b/src/Application/UI/Component.php index 411233a18..f0108eba4 100644 --- a/src/Application/UI/Component.php +++ b/src/Application/UI/Component.php @@ -330,3 +330,6 @@ public function error(string $message = '', int $httpCode = Nette\Http\IResponse throw new Nette\Application\BadRequestException($message, $httpCode); } } + + +class_exists(PresenterComponent::class); diff --git a/src/Application/UI/ComponentReflection.php b/src/Application/UI/ComponentReflection.php index d7523c240..4c472fd5e 100644 --- a/src/Application/UI/ComponentReflection.php +++ b/src/Application/UI/ComponentReflection.php @@ -310,3 +310,6 @@ public static function getClassesAndTraits(string $class): array return $res; } } + + +class_exists(PresenterComponentReflection::class); diff --git a/src/compatibility.php b/src/compatibility.php index 587f20b39..cf55aa4bc 100644 --- a/src/compatibility.php +++ b/src/compatibility.php @@ -7,5 +7,22 @@ declare(strict_types=1); -class_alias(Nette\Application\UI\Component::class, Nette\Application\UI\PresenterComponent::class); -class_alias(Nette\Application\UI\ComponentReflection::class, Nette\Application\UI\PresenterComponentReflection::class); +namespace Nette\Application\UI; + +if (false) { + /** @deprecated use Nette\Application\UI\Component */ + class PresenterComponent + { + } +} elseif (!class_exists(PresenterComponent::class)) { + class_alias(Component::class, PresenterComponent::class); +} + +if (false) { + /** @deprecated use Nette\Application\UI\ComponentReflection */ + class PresenterComponentReflection + { + } +} elseif (!class_exists(PresenterComponentReflection::class)) { + class_alias(ComponentReflection::class, PresenterComponentReflection::class); +} From 8358b58dcd236b616636300a4e7e0212ef0eae25 Mon Sep 17 00:00:00 2001 From: David Grudl Date: Wed, 8 Jan 2020 02:04:34 +0100 Subject: [PATCH 04/11] cs --- src/Application/IPresenterFactory.php | 1 - src/Application/IResponse.php | 1 - src/Application/UI/IRenderable.php | 1 - src/Application/UI/IStatePersistent.php | 1 - src/Application/UI/ITemplate.php | 1 - 5 files changed, 5 deletions(-) diff --git a/src/Application/IPresenterFactory.php b/src/Application/IPresenterFactory.php index c20ce05d1..db2106fae 100644 --- a/src/Application/IPresenterFactory.php +++ b/src/Application/IPresenterFactory.php @@ -15,7 +15,6 @@ */ interface IPresenterFactory { - /** * Generates and checks presenter class name. * @throws InvalidPresenterException diff --git a/src/Application/IResponse.php b/src/Application/IResponse.php index ae3258a3f..1d788449c 100644 --- a/src/Application/IResponse.php +++ b/src/Application/IResponse.php @@ -17,7 +17,6 @@ */ interface IResponse { - /** * Sends response to output. */ diff --git a/src/Application/UI/IRenderable.php b/src/Application/UI/IRenderable.php index 5cd114aa1..5c051037e 100644 --- a/src/Application/UI/IRenderable.php +++ b/src/Application/UI/IRenderable.php @@ -15,7 +15,6 @@ */ interface IRenderable { - /** * Forces control to repaint. */ diff --git a/src/Application/UI/IStatePersistent.php b/src/Application/UI/IStatePersistent.php index 9130c6d7a..8112b56cb 100644 --- a/src/Application/UI/IStatePersistent.php +++ b/src/Application/UI/IStatePersistent.php @@ -15,7 +15,6 @@ */ interface IStatePersistent { - /** * Loads state informations. */ diff --git a/src/Application/UI/ITemplate.php b/src/Application/UI/ITemplate.php index 25d74889b..22e7a3eaf 100644 --- a/src/Application/UI/ITemplate.php +++ b/src/Application/UI/ITemplate.php @@ -15,7 +15,6 @@ */ interface ITemplate { - /** * Renders template to output. */ From 913c6060f9bc7c7c7b944e2902df8093b23cbf15 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Karel=20Horsk=C3=BD?= Date: Fri, 3 Jan 2020 22:37:19 +0100 Subject: [PATCH 05/11] Presenter: added isModuleCurrent() [Closes #240] (#243) --- src/Application/UI/Presenter.php | 7 ++++ tests/UI/Presenter.isModuleCurrent().phpt | 49 +++++++++++++++++++++++ 2 files changed, 56 insertions(+) create mode 100644 tests/UI/Presenter.isModuleCurrent().phpt diff --git a/src/Application/UI/Presenter.php b/src/Application/UI/Presenter.php index e1db614b0..3543e9423 100644 --- a/src/Application/UI/Presenter.php +++ b/src/Application/UI/Presenter.php @@ -179,6 +179,13 @@ public function getUniqueId(): string } + public function isModuleCurrent(string $module): bool + { + $current = Helpers::splitName($this->getName())[0]; + return Nette\Utils\Strings::startsWith($current . ':', ltrim($module . ':', ':')); + } + + /********************* interface IPresenter ****************d*g**/ diff --git a/tests/UI/Presenter.isModuleCurrent().phpt b/tests/UI/Presenter.isModuleCurrent().phpt new file mode 100644 index 000000000..ffa69b70b --- /dev/null +++ b/tests/UI/Presenter.isModuleCurrent().phpt @@ -0,0 +1,49 @@ +setParent(null, 'Test'); + + Assert::true($presenter->isModuleCurrent('')); + Assert::false($presenter->isModuleCurrent('Test')); + Assert::false($presenter->isModuleCurrent(':Test')); +}); + + +test(function () { + $presenter = new TestPresenter; + $presenter->setParent(null, 'First:Second:Third:Test'); + + Assert::false($presenter->isModuleCurrent('First:Second:Third:Test')); + + Assert::true($presenter->isModuleCurrent('First:Second:Third')); + Assert::true($presenter->isModuleCurrent('First:Second')); + Assert::true($presenter->isModuleCurrent('First')); + Assert::true($presenter->isModuleCurrent('')); + + Assert::true($presenter->isModuleCurrent(':First:Second:Third')); + Assert::true($presenter->isModuleCurrent(':First:Second')); + Assert::true($presenter->isModuleCurrent(':First')); + Assert::true($presenter->isModuleCurrent(':')); + + Assert::false($presenter->isModuleCurrent('First:Second:Other')); + Assert::false($presenter->isModuleCurrent('First:Other')); + Assert::false($presenter->isModuleCurrent('First:Second:T')); + Assert::false($presenter->isModuleCurrent('First:S')); +}); From 42560dd32f323b8cfc2160780fe60aca4d88a97c Mon Sep 17 00:00:00 2001 From: David Grudl Date: Sat, 4 Jan 2020 18:25:52 +0100 Subject: [PATCH 06/11] uses latte 2.6 --- composer.json | 6 +++--- src/Bridges/ApplicationLatte/UIMacros.php | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/composer.json b/composer.json index 289359cf4..fed58a6a3 100644 --- a/composer.json +++ b/composer.json @@ -26,12 +26,12 @@ "latte/latte": "Allows using Latte in templates" }, "require-dev": { - "nette/tester": "^2.0.1", + "nette/tester": "^2.3.1", "nette/di": "^v3.0", "nette/forms": "^3.0", "nette/robot-loader": "^3.2", "nette/security": "^3.0", - "latte/latte": "^2.5.1", + "latte/latte": "^2.6", "tracy/tracy": "^2.6", "mockery/mockery": "^1.0", "phpstan/phpstan-nette": "^0.12" @@ -39,7 +39,7 @@ "conflict": { "nette/di": "<3.0-stable", "nette/forms": "<3.0", - "latte/latte": "<2.4", + "latte/latte": "<2.6", "tracy/tracy": "<2.5" }, "autoload": { diff --git a/src/Bridges/ApplicationLatte/UIMacros.php b/src/Bridges/ApplicationLatte/UIMacros.php index 4a6773baf..09730528f 100644 --- a/src/Bridges/ApplicationLatte/UIMacros.php +++ b/src/Bridges/ApplicationLatte/UIMacros.php @@ -114,7 +114,7 @@ public function macroControl(MacroNode $node, PhpWriter $writer) public function macroLink(MacroNode $node, PhpWriter $writer) { $node->modifiers = preg_replace('#\|safeurl\s*(?=\||$)#Di', '', $node->modifiers); - return $writer->using($node) + return $writer->using($node, $this->getCompiler()) ->write('echo %escape(%modify(' . ($node->name === 'plink' ? '$this->global->uiPresenter' : '$this->global->uiControl') . '->link(%node.word, %node.array?)))' From 15d268a360ec0899e318d44b5847f9977b80aac2 Mon Sep 17 00:00:00 2001 From: David Grudl Date: Fri, 3 Jan 2020 22:59:33 +0100 Subject: [PATCH 07/11] tests: added more tests --- tests/Bridges.Latte/UIMacros.link.2.phpt | 2 +- .../UIMacros.renderSnippets5.phpt | 64 +++++++++++++++++++ .../UIMacros.renderSnippets6.phpt | 42 ++++++++++++ 3 files changed, 107 insertions(+), 1 deletion(-) create mode 100644 tests/Bridges.Latte/UIMacros.renderSnippets5.phpt create mode 100644 tests/Bridges.Latte/UIMacros.renderSnippets6.phpt diff --git a/tests/Bridges.Latte/UIMacros.link.2.phpt b/tests/Bridges.Latte/UIMacros.link.2.phpt index 3e4a50c0a..80243c381 100644 --- a/tests/Bridges.Latte/UIMacros.link.2.phpt +++ b/tests/Bridges.Latte/UIMacros.link.2.phpt @@ -117,4 +117,4 @@ EOD EOD -, $params), [''' => "'"])); +, $params), [''' => "'", ''' => "'"])); diff --git a/tests/Bridges.Latte/UIMacros.renderSnippets5.phpt b/tests/Bridges.Latte/UIMacros.renderSnippets5.phpt new file mode 100644 index 000000000..242d37d0f --- /dev/null +++ b/tests/Bridges.Latte/UIMacros.renderSnippets5.phpt @@ -0,0 +1,64 @@ +setLoader(new Latte\Loaders\StringLoader); + UIMacros::install($latte->getCompiler()); + $latte->addProvider('uiControl', $this); + $latte->addProvider('snippetBridge', new SnippetBridge($this)); + $latte->render($template, ['presenter' => $this]); + } +} + + +$presenter = new TestPresenter; +$presenter->snippetMode = true; +$presenter->redrawControl('foo'); +$presenter->render('
Hello
'); +Assert::same([ + 'snippets' => [ + 'snippet--foo' => 'Hello', + ], +], (array) $presenter->payload); + + +$presenter = new TestPresenter; +$presenter->snippetMode = true; +$presenter->redrawControl('foo'); +Assert::exception(function () use ($presenter) { + $presenter->render('
Hello
'); +}, Latte\CompileException::class, 'Cannot combine HTML attribute id with n:snippet.'); + + +$presenter = new TestPresenter; +$presenter->snippetMode = true; +$presenter->redrawControl('foo'); +Assert::exception(function () use ($presenter) { + $presenter->render('
Hello
'); +}, Latte\CompileException::class, 'Dynamic snippets are allowed only inside static snippet/snippetArea.'); + + +$presenter = new TestPresenter; +$presenter->snippetMode = true; +$presenter->redrawControl('foo'); +Assert::exception(function () use ($presenter) { + $presenter->render('
Hello
'); +}, Latte\CompileException::class, 'Cannot combine HTML attribute id with n:snippet.'); diff --git a/tests/Bridges.Latte/UIMacros.renderSnippets6.phpt b/tests/Bridges.Latte/UIMacros.renderSnippets6.phpt new file mode 100644 index 000000000..a0c7f0f5e --- /dev/null +++ b/tests/Bridges.Latte/UIMacros.renderSnippets6.phpt @@ -0,0 +1,42 @@ +setLoader(new Latte\Loaders\StringLoader); + UIMacros::install($latte->getCompiler()); + $latte->addProvider('snippetBridge', new Nette\Bridges\ApplicationLatte\SnippetBridge($this)); + $latte->onCompile[] = function ($latte) { + $latte->getCompiler()->getMacros()['snippet'][0]->snippetAttribute = 'data-snippet'; + }; + $latte->render($template); + } +} + + +$presenter = new TestPresenter; +ob_start(); +$presenter->render('
hello
'); +$content = ob_get_clean(); +Assert::same('
hello
', $content); + + +$presenter = new TestPresenter; +Assert::exception(function () use ($presenter) { + $presenter->render('
hello
'); +}, Latte\CompileException::class, 'Cannot combine HTML attribute data-snippet with n:snippet.'); From 4a60713c9952775a2a52d0ac46175c991c2fcf09 Mon Sep 17 00:00:00 2001 From: David Grudl Date: Sat, 4 Jan 2020 18:29:45 +0100 Subject: [PATCH 08/11] Template: added custom functions isLinkCurrent() and isModuleCurrent() --- .../ApplicationLatte/TemplateFactory.php | 5 +++++ .../Bridges.Latte/UIMacros.isLinkCurrent.phpt | 18 ++++++++++++++++-- .../expected/UIMacros.isLinkCurrent.phtml | 4 ++++ 3 files changed, 25 insertions(+), 2 deletions(-) diff --git a/src/Bridges/ApplicationLatte/TemplateFactory.php b/src/Bridges/ApplicationLatte/TemplateFactory.php index e34e0fec4..a2ddf66c2 100644 --- a/src/Bridges/ApplicationLatte/TemplateFactory.php +++ b/src/Bridges/ApplicationLatte/TemplateFactory.php @@ -100,6 +100,11 @@ public function createTemplate(UI\Control $control = null): UI\ITemplate }); } + if ($presenter) { + $latte->addFunction('isLinkCurrent', [$presenter, 'isLinkCurrent']); + $latte->addFunction('isModuleCurrent', [$presenter, 'isModuleCurrent']); + } + // default parameters $template->user = $this->user; $template->baseUrl = $this->httpRequest ? rtrim($this->httpRequest->getUrl()->withoutUserInfo()->getBaseUrl(), '/') : null; diff --git a/tests/Bridges.Latte/UIMacros.isLinkCurrent.phpt b/tests/Bridges.Latte/UIMacros.isLinkCurrent.phpt index 79ea6e5c6..23bc3c157 100644 --- a/tests/Bridges.Latte/UIMacros.isLinkCurrent.phpt +++ b/tests/Bridges.Latte/UIMacros.isLinkCurrent.phpt @@ -6,16 +6,28 @@ declare(strict_types=1); -use Nette\Bridges\ApplicationLatte\UIMacros; use Tester\Assert; require __DIR__ . '/../bootstrap.php'; +Tester\Environment::bypassFinals(); + $latte = new Latte\Engine; + +$latteFactory = Mockery::mock(Nette\Bridges\ApplicationLatte\ILatteFactory::class); +$latteFactory->shouldReceive('create')->andReturn($latte); + +$presenter = Mockery::mock(Nette\Application\UI\Presenter::class); +$presenter->shouldReceive('getPresenterIfExists')->andReturn($presenter); +$presenter->shouldReceive('getHttpResponse')->andReturn((Mockery::mock(Nette\Http\IResponse::class))->shouldIgnoreMissing()); +$presenter->shouldIgnoreMissing(); + +$factory = new Nette\Bridges\ApplicationLatte\TemplateFactory($latteFactory); +$factory->createTemplate($presenter); + $latte->setLoader(new Latte\Loaders\StringLoader); -UIMacros::install($latte->getCompiler()); Assert::matchFile(__DIR__ . '/expected/UIMacros.isLinkCurrent.phtml', $latte->compile( 'n:href before n:class @@ -29,4 +41,6 @@ Assert::matchFile(__DIR__ . '/expected/UIMacros.isLinkCurrent.phtml', $latte->co {ifCurrent}empty{/ifCurrent} {ifCurrent default}default{/ifCurrent} + +custom function ')); diff --git a/tests/Bridges.Latte/expected/UIMacros.isLinkCurrent.phtml b/tests/Bridges.Latte/expected/UIMacros.isLinkCurrent.phtml index d4e7568ff..333fcf43f 100644 --- a/tests/Bridges.Latte/expected/UIMacros.isLinkCurrent.phtml +++ b/tests/Bridges.Latte/expected/UIMacros.isLinkCurrent.phtml @@ -17,4 +17,8 @@ if ($this->global->uiPresenter->isLinkCurrent("default")) { ?>default + + +global->_fnislinkcurrent)('default') ? 'current' : null%A%>custom function %A% From c84fbf323896258b39f08b84ff681d99d5533f4f Mon Sep 17 00:00:00 2001 From: David Grudl Date: Fri, 10 Jan 2020 11:05:37 +0100 Subject: [PATCH 09/11] Presenter::restoreRequest() redirects on GET request --- src/Application/UI/Presenter.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/Application/UI/Presenter.php b/src/Application/UI/Presenter.php index 3543e9423..a5702b810 100644 --- a/src/Application/UI/Presenter.php +++ b/src/Application/UI/Presenter.php @@ -1068,11 +1068,15 @@ public function restoreRequest(string $key): void } $request = clone $session[$key][1]; unset($session[$key]); - $request->setFlag(Application\Request::RESTORED, true); $params = $request->getParameters(); $params[self::FLASH_KEY] = $this->getFlashKey(); $request->setParameters($params); - $this->sendResponse(new Responses\ForwardResponse($request)); + if ($request->isMethod('POST')) { + $request->setFlag(Application\Request::RESTORED, true); + $this->sendResponse(new Responses\ForwardResponse($request)); + } else { + $this->redirectUrl($this->requestToUrl($request)); + } } From cc7db2eaf1076ef4c589eb51ba2f8026b6123f8f Mon Sep 17 00:00:00 2001 From: David Grudl Date: Thu, 16 Jan 2020 18:20:32 +0100 Subject: [PATCH 10/11] travis: uses PHP 7.4 for coding checks --- .travis.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.travis.yml b/.travis.yml index 67a74fc5c..2f495a05d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -32,6 +32,7 @@ jobs: - name: Nette Code Checker + php: 7.4 install: - travis_retry composer create-project nette/code-checker temp/code-checker ^3 --no-progress script: @@ -39,6 +40,7 @@ jobs: - name: Nette Coding Standard + php: 7.4 install: - travis_retry composer create-project nette/coding-standard temp/coding-standard ^2 --no-progress script: @@ -51,6 +53,7 @@ jobs: - stage: Code Coverage + php: 7.4 script: - vendor/bin/tester -p phpdbg tests -s --coverage ./coverage.xml --coverage-src ./src after_script: From da24ae52e65fe52fa6d26f2181a56ec48958ccb0 Mon Sep 17 00:00:00 2001 From: David Grudl Date: Mon, 20 Jan 2020 12:15:46 +0100 Subject: [PATCH 11/11] added GitHub Actions workflow --- .github/workflows/coding-style.yml | 31 +++++++++++++++ .github/workflows/static-analysis.yml | 21 ++++++++++ .github/workflows/tests.yml | 56 +++++++++++++++++++++++++++ 3 files changed, 108 insertions(+) create mode 100644 .github/workflows/coding-style.yml create mode 100644 .github/workflows/static-analysis.yml create mode 100644 .github/workflows/tests.yml diff --git a/.github/workflows/coding-style.yml b/.github/workflows/coding-style.yml new file mode 100644 index 000000000..4a708c531 --- /dev/null +++ b/.github/workflows/coding-style.yml @@ -0,0 +1,31 @@ +name: Coding Style + +on: [push, pull_request] + +jobs: + nette_cc: + name: Nette Code Checker + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: shivammathur/setup-php@v1 + with: + php-version: 7.4 + coverage: none + + - run: composer create-project nette/code-checker temp/code-checker ^3 --no-progress + - run: php temp/code-checker/code-checker --strict-types --no-progress + + + nette_cs: + name: Nette Coding Standard + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: shivammathur/setup-php@v1 + with: + php-version: 7.4 + coverage: none + + - run: composer create-project nette/coding-standard temp/coding-standard ^2 --no-progress + - run: php temp/coding-standard/ecs check src tests --config temp/coding-standard/coding-standard-php71.yml diff --git a/.github/workflows/static-analysis.yml b/.github/workflows/static-analysis.yml new file mode 100644 index 000000000..e129028ce --- /dev/null +++ b/.github/workflows/static-analysis.yml @@ -0,0 +1,21 @@ +name: Static Analysis (only informative) + +on: + push: + branches: + - master + +jobs: + phpstan: + name: PHPStan + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: shivammathur/setup-php@v1 + with: + php-version: 7.4 + coverage: none + + - run: composer install --no-progress --prefer-dist + - run: composer phpstan + continue-on-error: true # is only informative diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 000000000..708879fd6 --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,56 @@ +name: Tests + +on: [push, pull_request] + +jobs: + tests: + runs-on: ubuntu-latest + strategy: + matrix: + php: ['7.1', '7.2', '7.3', '7.4'] + + fail-fast: false + + name: PHP ${{ matrix.php }} tests + steps: + - uses: actions/checkout@v2 + - uses: shivammathur/setup-php@v1 + with: + php-version: ${{ matrix.php }} + coverage: none + + - run: composer install --no-progress --prefer-dist + - run: vendor/bin/tester tests -s -C + - if: failure() + run: for i in $(find tests -name \*.actual); do echo "--- $i"; cat $i; echo; echo; done + shell: bash + + + lowest_dependencies: + name: Lowest Dependencies + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: shivammathur/setup-php@v1 + with: + php-version: 7.1 + coverage: none + + - run: composer update --no-progress --prefer-dist --prefer-lowest --prefer-stable + - run: vendor/bin/tester tests -s -C + + + code_coverage: + name: Code Coverage + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: shivammathur/setup-php@v1 + with: + php-version: 7.4 + coverage: none + + - run: composer install --no-progress --prefer-dist + - run: wget https://github.com/satooshi/php-coveralls/releases/download/v1.0.1/coveralls.phar + - run: vendor/bin/tester -p phpdbg tests -s -C --coverage ./coverage.xml --coverage-src ./src + - run: php coveralls.phar --verbose --config tests/.coveralls.yml