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

Remove Support for PHP 8.0, Upgrade PHPUnit to 10.x #30

Merged
merged 1 commit into from
May 18, 2023
Merged
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
4 changes: 1 addition & 3 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
/clover.xml
/coveralls-upload.json
/phpunit.xml
/vendor/
.phpcs-cache
.phpunit.result.cache
.phpunit.cache
16 changes: 8 additions & 8 deletions composer.json
Original file line number Diff line number Diff line change
@@ -25,7 +25,7 @@
"dealerdirect/phpcodesniffer-composer-installer": true
},
"platform": {
"php": "8.0.99"
"php": "8.1.99"
}
},
"extra": {
@@ -34,21 +34,21 @@
}
},
"require": {
"php": "~8.0.0 || ~8.1.0 || ~8.2.0",
"php": "~8.1.0 || ~8.2.0",
"fig/http-message-util": "^1.1.5",
"laminas/laminas-psr7bridge": "^1.0.0",
"laminas/laminas-router": "^3.10.0",
"mezzio/mezzio-router": "^3.9",
"mezzio/mezzio-router": "^3.14",
"psr/http-message": "^1.0.1"
},
"require-dev": {
"laminas/laminas-coding-standard": "~2.5.0",
"laminas/laminas-diactoros": "^2.24",
"laminas/laminas-i18n": "^2.21",
"laminas/laminas-stratigility": "^3.9",
"phpunit/phpunit": "^9.5.28",
"laminas/laminas-diactoros": "^2.25.2 || ^3.0.0",
"laminas/laminas-i18n": "^2.23",
"laminas/laminas-stratigility": "^3.10",
"phpunit/phpunit": "^10.1.3",
"psalm/plugin-phpunit": "^0.18.4",
"vimeo/psalm": "^5.6"
"vimeo/psalm": "^5.11"
},
"autoload": {
"psr-4": {
1,018 changes: 441 additions & 577 deletions composer.lock

Large diffs are not rendered by default.

23 changes: 16 additions & 7 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -4,16 +4,25 @@
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
bootstrap="./vendor/autoload.php"
colors="true"
convertDeprecationsToExceptions="true" >
<coverage processUncoveredFiles="true">
<include>
<directory suffix=".php">src</directory>
</include>
</coverage>

cacheDirectory=".phpunit.cache"
displayDetailsOnTestsThatTriggerWarnings="true"
displayDetailsOnTestsThatTriggerNotices="true"
displayDetailsOnTestsThatTriggerErrors="true"
displayDetailsOnTestsThatTriggerDeprecations="true"
displayDetailsOnSkippedTests="true"
displayDetailsOnIncompleteTests="true"
failOnNotice="true"
failOnWarning="true"
failOnDeprecation="true"
>
<testsuites>
<testsuite name="Mezzio laminas-mvc Router Tests">
<directory>./test</directory>
</testsuite>
</testsuites>
<source>
<include>
<directory suffix=".php">src</directory>
</include>
</source>
</phpunit>
23 changes: 13 additions & 10 deletions psalm-baseline.xml
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<files psalm-version="5.6.0@e784128902dfe01d489c4123d69918a9f3c1eac5">
<files psalm-version="5.11.0@c9b192ab8400fdaf04b2b13d110575adc879aa90">
<file src="src/LaminasRouter.php">
<MixedArgumentTypeCoercion>
<code>$params</code>
</MixedArgumentTypeCoercion>
<MixedArrayAccess>
<code>$options['defaults']['middleware']</code>
<code><![CDATA[$options['defaults']['middleware']]]></code>
</MixedArrayAccess>
<MixedArrayOffset>
<code>$this-&gt;allowedMethodsByPath[$params[self::METHOD_NOT_ALLOWED_ROUTE]]</code>
<code><![CDATA[$this->allowedMethodsByPath[$params[self::METHOD_NOT_ALLOWED_ROUTE]]]]></code>
</MixedArrayOffset>
<MixedInferredReturnType>
<code>string</code>
</MixedInferredReturnType>
<MixedReturnStatement>
<code>$this-&gt;laminasRouter-&gt;assemble($substitutions, $options)</code>
<code><![CDATA[$this->laminasRouter->assemble($substitutions, $options)]]></code>
</MixedReturnStatement>
<PossiblyNullArgument>
<code>$allowedMethods</code>
<code>$route-&gt;getAllowedMethods()</code>
<code><![CDATA[$route->getAllowedMethods()]]></code>
</PossiblyNullArgument>
</file>
<file src="test/LaminasRouter/ConfigProviderTest.php">
@@ -37,19 +37,22 @@
<code>array</code>
</MixedInferredReturnType>
<MixedReturnStatement>
<code>$this-&gt;routesToInject</code>
<code><![CDATA[$this->routesToInject]]></code>
</MixedReturnStatement>
<PossiblyFalseReference>
<code>getMiddleware</code>
<code>getMiddleware</code>
<code>getMiddleware</code>
</PossiblyFalseReference>
<PossiblyInvalidFunctionCall>
<PossiblyNullFunctionCall>
<code>Closure::bind($fn, $router, LaminasRouter::class)()</code>
<code>Closure::bind(fn() =&gt; $this-&gt;laminasRouter, $router, LaminasRouter::class)()</code>
</PossiblyInvalidFunctionCall>
<code><![CDATA[Closure::bind(fn() => $this->laminasRouter, $router, LaminasRouter::class)()]]></code>
</PossiblyNullFunctionCall>
<PossiblyUnusedMethod>
<code>implicitMethods</code>
</PossiblyUnusedMethod>
<UndefinedThisPropertyFetch>
<code>$this-&gt;routesToInject</code>
<code><![CDATA[$this->routesToInject]]></code>
</UndefinedThisPropertyFetch>
</file>
</files>
17 changes: 3 additions & 14 deletions psalm.xml
Original file line number Diff line number Diff line change
@@ -6,6 +6,9 @@
xmlns="https://getpsalm.org/schema/config"
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd"
errorBaseline="psalm-baseline.xml"
findUnusedBaselineEntry="true"
findUnusedCode="true"
findUnusedPsalmSuppress="true"
>
<projectFiles>
<directory name="src" />
@@ -14,20 +17,6 @@
<directory name="vendor" />
</ignoreFiles>
</projectFiles>

<issueHandlers>
<InternalMethod>
<errorLevel type="suppress">
<referencedMethod name="PHPUnit\Framework\MockObject\Builder\InvocationMocker::method"/>
</errorLevel>
<errorLevel type="suppress">
<referencedMethod name="PHPUnit\Framework\MockObject\Builder\InvocationMocker::willReturn"/>
</errorLevel>
<errorLevel type="suppress">
<referencedMethod name="PHPUnit\Framework\MockObject\Builder\InvocationMocker::with"/>
</errorLevel>
</InternalMethod>
</issueHandlers>
<plugins>
<pluginClass class="Psalm\PhpUnitPlugin\Plugin"/>
</plugins>
2 changes: 1 addition & 1 deletion test/ImplicitMethodsIntegrationTest.php
Original file line number Diff line number Diff line change
@@ -16,7 +16,7 @@ public function getRouter(): RouterInterface
return new LaminasRouter();
}

public function implicitRoutesAndRequests(): Generator
public static function implicitRoutesAndRequests(): Generator
{
$options = [
'constraints' => [
5 changes: 2 additions & 3 deletions test/LaminasRouter/ConfigProviderTest.php
Original file line number Diff line number Diff line change
@@ -7,6 +7,7 @@
use Mezzio\Router\LaminasRouter;
use Mezzio\Router\LaminasRouter\ConfigProvider;
use Mezzio\Router\RouterInterface;
use PHPUnit\Framework\Attributes\Depends;
use PHPUnit\Framework\TestCase;

class ConfigProviderTest extends TestCase
@@ -26,9 +27,7 @@ public function testInvocationReturnsArray(): array
return $config;
}

/**
* @depends testInvocationReturnsArray
*/
#[Depends('testInvocationReturnsArray')]
public function testReturnedArrayContainsDependencies(array $config): void
{
$this->assertArrayHasKey('dependencies', $config);
34 changes: 6 additions & 28 deletions test/LaminasRouterTest.php
Original file line number Diff line number Diff line change
@@ -18,6 +18,8 @@
use Mezzio\Router\LaminasRouter;
use Mezzio\Router\Route;
use Mezzio\Router\RouteResult;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\Attributes\Depends;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;
use Psr\Http\Message\ServerRequestInterface;
@@ -69,9 +71,7 @@ public function testAddingRouteAggregatesInRouter(): void
self::assertContains($route, $routesToInject);
}

/**
* @depends testAddingRouteAggregatesInRouter
*/
#[Depends('testAddingRouteAggregatesInRouter')]
public function testMatchingInjectsRoutesInRouter(): void
{
$middleware = $this->getMiddleware();
@@ -120,9 +120,7 @@ public function testMatchingInjectsRoutesInRouter(): void
$router->match($request);
}

/**
* @depends testAddingRouteAggregatesInRouter
*/
#[Depends('testAddingRouteAggregatesInRouter')]
public function testGeneratingUriInjectsRoutesInRouter(): void
{
$middleware = $this->getMiddleware();
@@ -313,9 +311,6 @@ public function testMatchedRouteNameWhenGetMethodAllowed(): void
self::assertSame($middleware, $result->getMatchedRoute()->getMiddleware());
}

/**
* @group match
*/
public function testSuccessfulMatchIsPossible(): void
{
$routeMatch = $this->createMock(RouteMatch::class);
@@ -353,9 +348,6 @@ public function testSuccessfulMatchIsPossible(): void
self::assertSame($middleware, $result->getMatchedRoute()->getMiddleware());
}

/**
* @group match
*/
public function testNonSuccessfulMatchNotDueToHttpMethodsIsPossible(): void
{
$this->laminasRouter->expects(self::once())
@@ -372,9 +364,6 @@ public function testNonSuccessfulMatchNotDueToHttpMethodsIsPossible(): void
self::assertFalse($result->isMethodFailure());
}

/**
* @group match
*/
public function testMatchFailureDueToHttpMethodReturnsRouteResultWithAllowedMethods(): void
{
$router = new LaminasRouter();
@@ -397,9 +386,6 @@ public function testMatchFailureDueToHttpMethodReturnsRouteResultWithAllowedMeth
self::assertEquals([RequestMethod::METHOD_POST, RequestMethod::METHOD_DELETE], $result->getAllowedMethods());
}

/**
* @group match
*/
public function testMatchFailureDueToMethodNotAllowedWithParamsInTheRoute(): void
{
$router = new LaminasRouter();
@@ -422,9 +408,6 @@ public function testMatchFailureDueToMethodNotAllowedWithParamsInTheRoute(): voi
self::assertEquals([RequestMethod::METHOD_POST, RequestMethod::METHOD_DELETE], $result->getAllowedMethods());
}

/**
* @group 53
*/
public function testCanGenerateUriFromRoutes(): void
{
$router = new LaminasRouter();
@@ -444,9 +427,6 @@ public function testCanGenerateUriFromRoutes(): void
self::assertEquals('/bar/BAZ', $router->generateUri('bar', ['baz' => 'BAZ']));
}

/**
* @group 3
*/
public function testPassingTrailingSlashToRouteNotExpectingItResultsIn404FailureRouteResult(): void
{
$router = new LaminasRouter();
@@ -506,17 +486,15 @@ public function testSuccessfulMatchingComposesRouteInRouteResult(): void
/**
* @return array<string, array<int, string>>
*/
public function implicitMethods(): array
public static function implicitMethods(): array
{
return [
'head' => [RequestMethod::METHOD_HEAD],
'options' => [RequestMethod::METHOD_OPTIONS],
];
}

/**
* @dataProvider implicitMethods
*/
#[DataProvider('implicitMethods')]
public function testRoutesCanMatchImplicitHeadAndOptionsRequests(string $method): void
{
$route = new Route('/foo', $this->getMiddleware(), [RequestMethod::METHOD_PUT]);