Skip to content

Commit

Permalink
Merge f4617ae into 4b83e02
Browse files Browse the repository at this point in the history
  • Loading branch information
adriansuter committed Dec 22, 2019
2 parents 4b83e02 + f4617ae commit 9d265f2
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 15 deletions.
2 changes: 1 addition & 1 deletion composer.json
Expand Up @@ -49,7 +49,7 @@
"nyholm/psr7": "^1.1",
"nyholm/psr7-server": "^0.3.0",
"phpunit/phpunit": "^7.5",
"phpspec/prophecy": "1.9",
"phpspec/prophecy": "^1.10",
"phpstan/phpstan": "^0.11.5",
"slim/http": "^0.7",
"slim/psr7": "^0.3",
Expand Down
7 changes: 7 additions & 0 deletions tests/AppTest.php
Expand Up @@ -1429,6 +1429,13 @@ public function testInvokeWithNonExistentMethodOnCallableRegisteredInContainer()
$requestProphecy = $this->prophesize(ServerRequestInterface::class);
$requestProphecy->getMethod()->willReturn('GET');
$requestProphecy->getUri()->willReturn($uriProphecy->reveal());
$requestProphecy->getAttribute(RouteContext::ROUTING_RESULTS)->willReturn(null);
$requestProphecy->withAttribute(Argument::type('string'), Argument::any())
->will(function ($args) {
$clone = clone $this;
$clone->getAttribute($args[0])->willReturn($args[1]);
return $clone;
});

$app->handle($requestProphecy->reveal());
}
Expand Down
19 changes: 10 additions & 9 deletions tests/Routing/RouteCollectorProxyTest.php
Expand Up @@ -9,6 +9,7 @@

namespace Slim\Tests\Routing;

use Prophecy\Argument;
use Psr\Container\ContainerInterface;
use Psr\Http\Message\ResponseFactoryInterface;
use Psr\Http\Message\ResponseInterface;
Expand Down Expand Up @@ -134,7 +135,7 @@ public function testGet()

$routeCollectorProphecy = $this->prophesize(RouteCollectorInterface::class);
$routeCollectorProphecy
->map(['GET'], $pattern, $callable)
->map(['GET'], $pattern, Argument::is($callable))
->willReturn($routeProphecy->reveal())
->shouldBeCalledOnce();

Expand Down Expand Up @@ -167,7 +168,7 @@ public function testPost()

$routeCollectorProphecy = $this->prophesize(RouteCollectorInterface::class);
$routeCollectorProphecy
->map(['POST'], $pattern, $callable)
->map(['POST'], $pattern, Argument::is($callable))
->willReturn($routeProphecy->reveal())
->shouldBeCalledOnce();

Expand Down Expand Up @@ -200,7 +201,7 @@ public function testPut()

$routeCollectorProphecy = $this->prophesize(RouteCollectorInterface::class);
$routeCollectorProphecy
->map(['PUT'], $pattern, $callable)
->map(['PUT'], $pattern, Argument::is($callable))
->willReturn($routeProphecy->reveal())
->shouldBeCalledOnce();

Expand Down Expand Up @@ -233,7 +234,7 @@ public function testPatch()

$routeCollectorProphecy = $this->prophesize(RouteCollectorInterface::class);
$routeCollectorProphecy
->map(['PATCH'], $pattern, $callable)
->map(['PATCH'], $pattern, Argument::is($callable))
->willReturn($routeProphecy->reveal())
->shouldBeCalledOnce();

Expand Down Expand Up @@ -266,7 +267,7 @@ public function testDelete()

$routeCollectorProphecy = $this->prophesize(RouteCollectorInterface::class);
$routeCollectorProphecy
->map(['DELETE'], $pattern, $callable)
->map(['DELETE'], $pattern, Argument::is($callable))
->willReturn($routeProphecy->reveal())
->shouldBeCalledOnce();

Expand Down Expand Up @@ -299,7 +300,7 @@ public function testOptions()

$routeCollectorProphecy = $this->prophesize(RouteCollectorInterface::class);
$routeCollectorProphecy
->map(['OPTIONS'], $pattern, $callable)
->map(['OPTIONS'], $pattern, Argument::is($callable))
->willReturn($routeProphecy->reveal())
->shouldBeCalledOnce();

Expand Down Expand Up @@ -332,7 +333,7 @@ public function testAny()

$routeCollectorProphecy = $this->prophesize(RouteCollectorInterface::class);
$routeCollectorProphecy
->map(['GET', 'POST', 'PUT', 'PATCH', 'DELETE', 'OPTIONS'], $pattern, $callable)
->map(['GET', 'POST', 'PUT', 'PATCH', 'DELETE', 'OPTIONS'], $pattern, Argument::is($callable))
->willReturn($routeProphecy->reveal())
->shouldBeCalledOnce();

Expand Down Expand Up @@ -366,7 +367,7 @@ public function testMap()

$routeCollectorProphecy = $this->prophesize(RouteCollectorInterface::class);
$routeCollectorProphecy
->map($methods, $pattern, $callable)
->map($methods, $pattern, Argument::is($callable))
->willReturn($routeProphecy->reveal())
->shouldBeCalledOnce();

Expand Down Expand Up @@ -440,7 +441,7 @@ public function testGroup()

$routeCollectorProphecy = $this->prophesize(RouteCollectorInterface::class);
$routeCollectorProphecy
->group($pattern, $callable)
->group($pattern, Argument::is($callable))
->willReturn($routeGroupProphecy->reveal())
->shouldBeCalledOnce();

Expand Down
3 changes: 2 additions & 1 deletion tests/Routing/RouteCollectorTest.php
Expand Up @@ -9,6 +9,7 @@

namespace Slim\Tests\Routing;

use Prophecy\Argument;
use Psr\Container\ContainerInterface;
use Psr\Http\Message\ResponseFactoryInterface;
use RuntimeException;
Expand Down Expand Up @@ -73,7 +74,7 @@ public function testMapPrependsGroupPattern()

$callableResolverProphecy = $this->prophesize(CallableResolverInterface::class);
$callableResolverProphecy
->resolve($callable)
->resolve(Argument::is($callable))
->willReturn($callable)
->shouldBeCalledOnce();

Expand Down
13 changes: 9 additions & 4 deletions tests/Routing/RouteTest.php
Expand Up @@ -49,8 +49,13 @@ public function createRoute($methods = 'GET', string $pattern = '/', $callable =

$callableResolverProphecy = $this->prophesize(CallableResolverInterface::class);
$callableResolverProphecy
->resolve($callable)
->resolve(Argument::is($callable))
->willReturn($callable);
$callableResolverProphecy
->resolve(MockMiddlewareWithoutConstructor::class)
->will(function ($args) {
return [new MockMiddlewareWithoutConstructor(), 'process'];
});

$streamProphecy = $this->prophesize(StreamInterface::class);

Expand Down Expand Up @@ -280,7 +285,7 @@ public function testAddMiddlewareOnGroup()

$callableResolverProphecy = $this->prophesize(CallableResolverInterface::class);
$callableResolverProphecy
->resolve($callable)
->resolve(Argument::is($callable))
->willReturn($callable)
->shouldBeCalledOnce();

Expand Down Expand Up @@ -410,7 +415,7 @@ public function testControllerMethodAsStringResolvesWithContainer()
$callable = 'CallableTest:toCall';

$callableResolverProphecy
->resolve($callable)
->resolve(Argument::is($callable))
->willReturn(function (
ServerRequestInterface $request,
ResponseInterface $response
Expand All @@ -425,7 +430,7 @@ public function testControllerMethodAsStringResolvesWithContainer()

$deferred = $callableResolverProphecy->reveal()->resolve($callable);
$callableResolverProphecy
->resolve($deferred)
->resolve(Argument::is($deferred))
->willReturn($deferred)
->shouldBeCalledOnce();

Expand Down

0 comments on commit 9d265f2

Please sign in to comment.