Skip to content

Commit

Permalink
Fix closures in method prophecies
Browse files Browse the repository at this point in the history
  • Loading branch information
adriansuter committed Dec 19, 2019
1 parent 941828c commit c853037
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 14 deletions.
19 changes: 10 additions & 9 deletions tests/Routing/RouteCollectorProxyTest.php
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
8 changes: 4 additions & 4 deletions tests/Routing/RouteTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public function createRoute($methods = 'GET', string $pattern = '/', $callable =

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

$streamProphecy = $this->prophesize(StreamInterface::class);
Expand Down Expand Up @@ -280,7 +280,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 +410,7 @@ public function testControllerMethodAsStringResolvesWithContainer()
$callable = 'CallableTest:toCall';

$callableResolverProphecy
->resolve($callable)
->resolve(Argument::is($callable))
->willReturn(function (
ServerRequestInterface $request,
ResponseInterface $response
Expand All @@ -425,7 +425,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 c853037

Please sign in to comment.