Skip to content

Commit

Permalink
upgrade composer deps
Browse files Browse the repository at this point in the history
  • Loading branch information
petrparolek committed Nov 11, 2024
1 parent 085f91a commit f890c44
Show file tree
Hide file tree
Showing 14 changed files with 136 additions and 114 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ jobs:
strategy:
fail-fast: false
matrix:
php: [ '7.2', '7.3', '7.4', '8.0', '8.1' ]
php: [ '8.1', '8.2', '8.3' ]

name: PHP ${{ matrix.php }}

Expand Down
9 changes: 7 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,15 @@
"php": ">=7.2",
"nette/application": "^3.2",
"nette/forms": "^3.2",
"nette/http": "^3.3.2",
"nette/http": "^3.3.1",
"nette/security": "^3.2",
"nette/tester": "~2.0"
},
"require-dev": {
"latte/latte": "^3.0",
"nette/bootstrap": "~3.2.0",
"nextras/secured-links": "@dev",
"ninjify/qa": "^0.13",
"contributte/qa": "^0.3",
"phpstan/phpstan": "^1.0",
"phpstan/phpstan-deprecation-rules": "^1.0",
"phpstan/phpstan-nette": "^1.0",
Expand All @@ -38,5 +38,10 @@
},
"autoload-dev": {
"classmap": ["tests/inc"]
},
"config": {
"allow-plugins": {
"dealerdirect/phpcodesniffer-composer-installer": true
}
}
}
4 changes: 1 addition & 3 deletions phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,11 @@ includes:
parameters:
level: 8

checkMissingIterableValueType: false

universalObjectCratesClasses:
- Nette\Http\SessionSection

ignoreErrors:
- '#Property Nette\\Http\\Request::\$(.*) is not writable.#'
#- '#Property Nette\\Http\\Request::\$(.*) is not writable.#'
-
message: """
#^Call to deprecated method validateConfig\\(\\) of class Nette\\\\DI\\\\CompilerExtension\\:
Expand Down
9 changes: 7 additions & 2 deletions ruleset.xml
Original file line number Diff line number Diff line change
@@ -1,18 +1,23 @@
<?xml version="1.0"?>
<ruleset>
<!-- Contributte Coding Standard -->
<rule ref="./vendor/ninjify/coding-standard/contributte.xml"/>
<rule ref="./vendor/contributte/qa/ruleset.xml"/>

<!-- Specific rules -->
<rule ref="SlevomatCodingStandard.Files.TypeNameMatchesFileName">
<properties>
<property name="rootNamespaces" type="array" value="
src=>Webnazakazku\MangoTester\PresenterTester,
tests/cases=>AppTests\Tester\PresenterTester,
tests/cases=>AppTests\Tester\PresenterTester,
tests/inc=>Tests\Tester\PresenterTester,
"/>
<property name="extensions" type="array" value="php,phpt"/>
</properties>
<!--<exclude name="SlevomatCodingStandard.Functions.DisallowEmptyFunction.EmptyFunction" />
<exclude name="SlevomatCodingStandard.PHP.DisallowReference.DisallowedReturningReference" />
<exclude name="SlevomatCodingStandard.TypeHints.PropertyTypeHint.MissingNativeTypeHint" />
<exclude name="SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingNativeTypeHint" />-->
<exclude name="SlevomatCodingStandard.Functions.DisallowEmptyFunction.EmptyFunction" />
<exclude name="Generic.NamingConventions.CamelCapsFunctionName.ScopeNotCamelCaps" />
</rule>

Expand Down
8 changes: 4 additions & 4 deletions src/Bridges/Infrastructure/PresenterTesterExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@

use Nette\Application\Application;
use Nette\Application\IPresenterFactory;
use Nette\Application\IRouter;
use Nette\DI\CompilerExtension;
use Nette\DI\Definitions\ServiceDefinition;
use Nette\DI\Definitions\Statement;
use Nette\Http\IRequest;
use Nette\Http\Session;
use Nette\Routing\Router;
use Nette\Security\User;
use Webnazakazku\MangoTester\Infrastructure\MangoTesterExtension;
use Webnazakazku\MangoTester\PresenterTester\IPresenterTesterListener;
Expand All @@ -18,8 +18,8 @@
class PresenterTesterExtension extends CompilerExtension
{

/** @var array */
public $defaults = [
/** @var array<mixed> */
public array $defaults = [
'baseUrl' => 'https://test.dev',
'identityFactory' => null,
];
Expand All @@ -43,7 +43,7 @@ public function loadConfiguration(): void
->setType(PresenterTesterTestCaseListener::class);
$this->requireService(IPresenterFactory::class);
$this->requireService(User::class);
$this->requireService(IRouter::class);
$this->requireService(Router::class);
$this->requireService(IRequest::class);
$this->requireService(Session::class);
$this->requireService(Application::class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class PresenterTesterTestCaseListener implements ITestCaseListener
{

/** @var PresenterTester|NULL */
public $presenterTester;
public ?PresenterTester $presenterTester = null;

public function setUp(TestCase $testCase): void
{
Expand Down
11 changes: 8 additions & 3 deletions src/PresenterAssert.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,28 @@
namespace Webnazakazku\MangoTester\PresenterTester;

use Nette\Application\Request;
use Nette\Application\UI;
use Nette\Application\UI\Presenter;
use Nette\StaticClass;
use Tester\Assert;
use Tester\AssertException;

class PresenterAssert
{

use StaticClass;

/**
* @param array<mixed>|null $actual
* @throws AssertException
*/
public static function assertRequestMatch(Request $expected, ?array $actual, bool $onlyIntersectedParameters = true): void
{
Assert::notSame(null, $actual);
assert($actual !== null);

$presenter = $actual[UI\Presenter::PRESENTER_KEY] ?? null;
$presenter = $actual[Presenter::PresenterKey] ?? null;
Assert::same($expected->getPresenterName(), $presenter);
unset($actual[UI\Presenter::PRESENTER_KEY]);
unset($actual[Presenter::PresenterKey]);

$expectedParameters = $expected->getParameters();

Expand Down
36 changes: 15 additions & 21 deletions src/PresenterTester.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,45 +7,39 @@
use Nette\Application\BadRequestException;
use Nette\Application\IPresenter;
use Nette\Application\IPresenterFactory;
use Nette\Application\IRouter;
use Nette\Application\Request as AppRequest;
use Nette\Application\UI\Presenter;
use Nette\Http\IRequest;
use Nette\Http\Request;
use Nette\Http\Session;
use Nette\Http\UrlScript;
use Nette\Routing\Router;
use Nette\Security\User;
use Tester\Assert;

class PresenterTester
{

/** @var Session */
private $session;
private Session $session;

/** @var IPresenterFactory */
private $presenterFactory;
private IPresenterFactory $presenterFactory;

/** @var IRouter */
private $router;
private Router $router;

/** @var Request */
private $httpRequest;
private Request $httpRequest;

/** @var string */
private $baseUrl;
private string $baseUrl;

/** @var User */
private $user;
private User $user;

/** @var IPresenterTesterListener[] */
private $listeners;
private array $listeners;

/** @var callable|NULL */
private $identityFactory;

/** @var TestPresenterResult[] */
private $results = [];
private array $results = [];

/**
* @param IPresenterTesterListener[] $listeners
Expand All @@ -54,7 +48,7 @@ public function __construct(
string $baseUrl,
Session $session,
IPresenterFactory $presenterFactory,
IRouter $router,
Router $router,
IRequest $httpRequest,
User $user,
array $listeners = [],
Expand Down Expand Up @@ -93,13 +87,13 @@ public function execute(TestPresenterRequest $testRequest): TestPresenterResult
$response = null;
}

if ($applicationRequest->getParameter(Presenter::SIGNAL_KEY) && method_exists($presenter, 'isSignalProcessed')) {
if ($applicationRequest->getParameter(Presenter::SignalKey) && method_exists($presenter, 'isSignalProcessed')) {
if (!$presenter->isSignalProcessed()) {
if ($badRequestException) {
$cause = 'BadRequestException with code ' . $badRequestException->getCode() . ' and message "' . $badRequestException->getMessage() . '"';
} else {
assert($response !== null);
$cause = get_class($response);
$cause = $response::class;
}

Assert::fail('Signal has not been processed at all, received ' . $cause);
Expand Down Expand Up @@ -176,7 +170,7 @@ protected function setupHttpRequest(TestPresenterRequest $request): void

$url = new UrlScript((string) $this->router->constructUrl($appRequest->toArray(), $refUrl), '/');

Closure::bind(function () use ($request, $url) {
Closure::bind(function () use ($request, $url): void {
/** @var Request $this */
$this->headers = $request->getHeaders() + $this->headers;
if ($request->isAjax()) {
Expand All @@ -190,13 +184,13 @@ protected function setupHttpRequest(TestPresenterRequest $request): void
$this->method = ($request->getPost() || $request->getRawBody()) ? 'POST' : 'GET';
$rawBodyCallback = [$request, 'getRawBody'];
$this->rawBodyCallback = \Closure::fromCallable($rawBodyCallback);

Check failure on line 186 in src/PresenterTester.php

View workflow job for this annotation

GitHub Actions / PHP 8.1

Readonly property Nette\Http\Request::$rawBodyCallback is assigned outside of its declaring class.

Check failure on line 186 in src/PresenterTester.php

View workflow job for this annotation

GitHub Actions / PHP 8.2

Readonly property Nette\Http\Request::$rawBodyCallback is assigned outside of its declaring class.

Check failure on line 186 in src/PresenterTester.php

View workflow job for this annotation

GitHub Actions / PHP 8.3

Readonly property Nette\Http\Request::$rawBodyCallback is assigned outside of its declaring class.
}, $this->httpRequest, Request::class)->__invoke();
}, $this->httpRequest, Request::class)();
}

protected function setupUIPresenter(Presenter $presenter): void
{
$presenter->autoCanonicalize = false;
$presenter->invalidLinkMode = Presenter::INVALID_LINK_EXCEPTION;
$presenter->invalidLinkMode = Presenter::InvalidLinkException;
}

}
Loading

0 comments on commit f890c44

Please sign in to comment.