Skip to content
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
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"react/promise": "^3 || ^2.7"
},
"require-dev": {
"phpstan/phpstan": "1.8.10 || 1.4.10",
"phpstan/phpstan": "1.9.2 || 1.4.10",
"phpunit/phpunit": "^9.5 || ^7.5",
"psr/container": "^2 || ^1"
},
Expand Down
2 changes: 0 additions & 2 deletions phpstan.neon.dist
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,3 @@ parameters:
# ignore unknown `Fiber` class (PHP 8.1+)
- '/^Instantiated class Fiber not found\.$/'
- '/^Call to method (start|isTerminated|getReturn)\(\) on an unknown class Fiber\.$/'
# ignore incomplete type information for mocks in legacy PHPUnit 7.5
- '/^Parameter #\d+ .+ of .+ expects .+, PHPUnit\\Framework\\MockObject\\MockObject given\.$/'
15 changes: 15 additions & 0 deletions tests/AppTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ public function testConstructWithContainerAssignsDefaultHandlersAndContainerForR
$container->expects($this->once())->method('getAccessLogHandler')->willReturn($accessLogHandler);
$container->expects($this->once())->method('getErrorHandler')->willReturn($errorHandler);

assert($container instanceof Container);
$app = new App($container);

$ref = new ReflectionProperty($app, 'handler');
Expand Down Expand Up @@ -109,6 +110,7 @@ public function testConstructWithContainerAndMiddlewareClassNameAssignsCallableF
$container = $this->createMock(Container::class);
$container->expects($this->once())->method('callable')->with('stdClass')->willReturn($middleware);

assert($container instanceof Container);
$app = new App($container, \stdClass::class);

$ref = new ReflectionProperty($app, 'handler');
Expand Down Expand Up @@ -224,6 +226,7 @@ public function testConstructWithContainerAndErrorHandlerClassAssignsErrorHandle
$container = $this->createMock(Container::class);
$container->expects($this->once())->method('getErrorHandler')->willReturn($errorHandler);

assert($container instanceof Container);
$app = new App($container, ErrorHandler::class);

$ref = new ReflectionProperty($app, 'handler');
Expand Down Expand Up @@ -257,6 +260,8 @@ public function testConstructWithMultipleContainersAndErrorHandlerClassAssignsEr
$container = $this->createMock(Container::class);
$container->expects($this->once())->method('getErrorHandler')->willReturn($errorHandler);

assert($unused instanceof Container);
assert($container instanceof Container);
$app = new App($unused, $container, ErrorHandler::class, $unused);

$ref = new ReflectionProperty($app, 'handler');
Expand Down Expand Up @@ -291,6 +296,8 @@ public function testConstructWithMultipleContainersAndMiddlewareAssignsErrorHand
$container = $this->createMock(Container::class);
$container->expects($this->once())->method('getErrorHandler')->willReturn($errorHandler);

assert($unused instanceof Container);
assert($container instanceof Container);
$app = new App($unused, $container, $middleware, $unused);

$ref = new ReflectionProperty($app, 'handler');
Expand Down Expand Up @@ -361,6 +368,9 @@ public function testConstructWithMultipleContainersAndMiddlewareAndErrorHandlerC
$container2 = $this->createMock(Container::class);
$container2->expects($this->once())->method('getErrorHandler')->willReturn($errorHandler2);

assert($unused instanceof Container);
assert($container1 instanceof Container);
assert($container2 instanceof Container);
$app = new App($unused, $container1, $middleware, $container2, ErrorHandler::class, $unused);

$ref = new ReflectionProperty($app, 'handler');
Expand Down Expand Up @@ -448,6 +458,7 @@ public function testConstructWithContainerAndAccessLogHandlerClassAndErrorHandle
$container->expects($this->once())->method('getAccessLogHandler')->willReturn($accessLogHandler);
$container->expects($this->once())->method('getErrorHandler')->willReturn($errorHandler);

assert($container instanceof Container);
$app = new App($container, AccessLogHandler::class, ErrorHandler::class);

$ref = new ReflectionProperty($app, 'handler');
Expand Down Expand Up @@ -515,6 +526,8 @@ public function testConstructWithMultipleContainersAndAccessLogHandlerClassAndEr
$container->expects($this->once())->method('getAccessLogHandler')->willReturn($accessLogHandler);
$container->expects($this->once())->method('getErrorHandler')->willReturn($errorHandler);

assert($unused instanceof Container);
assert($container instanceof Container);
$app = new App($unused, $container, AccessLogHandler::class, ErrorHandler::class, $unused);

$ref = new ReflectionProperty($app, 'handler');
Expand Down Expand Up @@ -554,6 +567,8 @@ public function testConstructWithMultipleContainersAndMiddlewareAssignsDefaultHa
$container->expects($this->once())->method('getAccessLogHandler')->willReturn($accessLogHandler);
$container->expects($this->once())->method('getErrorHandler')->willReturn($errorHandler);

assert($unused instanceof Container);
assert($container instanceof Container);
$app = new App($unused, $container, $middleware, $unused);

$ref = new ReflectionProperty($app, 'handler');
Expand Down
10 changes: 10 additions & 0 deletions tests/ContainerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1982,6 +1982,7 @@ public function __invoke(ServerRequestInterface $request): Response
$psr->expects($this->never())->method('has');
$psr->expects($this->once())->method('get')->with(get_class($controller))->willReturn($controller);

assert($psr instanceof ContainerInterface);
$container = new Container($psr);

$callable = $container->callable(get_class($controller));
Expand All @@ -2002,6 +2003,7 @@ public function testCallableReturnsCallableThatThrowsWhenFactoryReturnsInvalidCl
$psr->expects($this->never())->method('has');
$psr->expects($this->once())->method('get')->with('FooBar')->willThrowException($exception);

assert($psr instanceof ContainerInterface);
$container = new Container($psr);

$callable = $container->callable('FooBar'); // @phpstan-ignore-line
Expand Down Expand Up @@ -2054,6 +2056,7 @@ public function testGetEnvReturnsStringFromPsrContainer(): void
$psr->expects($this->once())->method('has')->with('X_FOO')->willReturn(true);
$psr->expects($this->once())->method('get')->with('X_FOO')->willReturn('bar');

assert($psr instanceof ContainerInterface);
$container = new Container($psr);

$this->assertEquals('bar', $container->getEnv('X_FOO'));
Expand All @@ -2065,6 +2068,7 @@ public function testGetEnvReturnsNullIfPsrContainerHasNoEntry(): void
$psr->expects($this->once())->method('has')->with('X_FOO')->willReturn(false);
$psr->expects($this->never())->method('get');

assert($psr instanceof ContainerInterface);
$container = new Container($psr);

$this->assertNull($container->getEnv('X_FOO'));
Expand All @@ -2076,6 +2080,7 @@ public function testGetEnvReturnsStringFromGlobalServerIfPsrContainerHasNoEntry(
$psr->expects($this->once())->method('has')->with('X_FOO')->willReturn(false);
$psr->expects($this->never())->method('get');

assert($psr instanceof ContainerInterface);
$container = new Container($psr);

$_SERVER['X_FOO'] = 'bar';
Expand All @@ -2102,6 +2107,7 @@ public function testGetEnvThrowsIfMapPsrContainerReturnsInvalidType(): void
$psr->expects($this->once())->method('has')->with('X_FOO')->willReturn(true);
$psr->expects($this->once())->method('get')->with('X_FOO')->willReturn(42);

assert($psr instanceof ContainerInterface);
$container = new Container($psr);

$this->expectException(\TypeError::class);
Expand Down Expand Up @@ -2139,6 +2145,7 @@ public function testGetAccessLogHandlerReturnsAccessLogHandlerInstanceFromPsrCon
$psr->expects($this->once())->method('has')->with(AccessLogHandler::class)->willReturn(true);
$psr->expects($this->once())->method('get')->with(AccessLogHandler::class)->willReturn($accessLogHandler);

assert($psr instanceof ContainerInterface);
$container = new Container($psr);

$ret = $container->getAccessLogHandler();
Expand All @@ -2152,6 +2159,7 @@ public function testGetAccessLogHandlerReturnsDefaultAccessLogHandlerInstanceIfP
$psr->expects($this->once())->method('has')->with(AccessLogHandler::class)->willReturn(false);
$psr->expects($this->never())->method('get');

assert($psr instanceof ContainerInterface);
$container = new Container($psr);

$accessLogHandler = $container->getAccessLogHandler();
Expand Down Expand Up @@ -2189,6 +2197,7 @@ public function testGetErrorHandlerReturnsErrorHandlerInstanceFromPsrContainer()
$psr->expects($this->once())->method('has')->with(ErrorHandler::class)->willReturn(true);
$psr->expects($this->once())->method('get')->with(ErrorHandler::class)->willReturn($errorHandler);

assert($psr instanceof ContainerInterface);
$container = new Container($psr);

$ret = $container->getErrorHandler();
Expand All @@ -2202,6 +2211,7 @@ public function testGetErrorHandlerReturnsDefaultErrorHandlerInstanceIfPsrContai
$psr->expects($this->once())->method('has')->with(ErrorHandler::class)->willReturn(false);
$psr->expects($this->never())->method('get');

assert($psr instanceof ContainerInterface);
$container = new Container($psr);

$errorHandler = $container->getErrorHandler();
Expand Down
2 changes: 2 additions & 0 deletions tests/Io/RouteHandlerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ public function testMapRouteWithClassNameAddsRouteOnRouterWithControllerCallable
$container = $this->createMock(Container::class);
$container->expects($this->once())->method('callable')->with('stdClass')->willReturn($controller);

assert($container instanceof Container);
$handler = new RouteHandler($container);

$router = $this->createMock(RouteCollector::class);
Expand Down Expand Up @@ -98,6 +99,7 @@ public function testMapRouteWithContainerAndControllerClassNameAddsRouteOnRouter
$ref->setAccessible(true);
$ref->setValue($handler, $router);

assert($container instanceof Container);
$handler->map(['GET'], '/', $container, \stdClass::class);
}

Expand Down
3 changes: 1 addition & 2 deletions tests/install-as-dep/composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{
"require": {
"clue/framework-x": "*@dev",
"react/async": "^4@dev || ^3@dev"
"clue/framework-x": "*@dev"
},
"repositories": [
{
Expand Down