Skip to content

Commit

Permalink
Merge pull request #3017 from pawel-slowik/fix-request-creator-factor…
Browse files Browse the repository at this point in the history
…y-test

Fix request creator factory test
  • Loading branch information
l0gicgate committed Nov 10, 2020
2 parents a65c364 + 2dd2293 commit 2974dc3
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion tests/Factory/ServerRequestCreatorFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,9 @@ public function testSetPsr17FactoryProvider()
$this->assertInstanceOf(SlimServerRequest::class, $serverRequestCreator->createServerRequestFromGlobals());
}

public function testSetServerRequestCreator()
public function testSetServerRequestCreatorWithoutDecorators()
{
ServerRequestCreatorFactory::setSlimHttpDecoratorsAutomaticDetection(false);
$serverRequestProphecy = $this->prophesize(ServerRequestInterface::class);

$serverRequestCreatorProphecy = $this->prophesize(ServerRequestCreatorInterface::class);
Expand All @@ -106,4 +107,22 @@ public function testSetServerRequestCreator()

$this->assertSame($serverRequestProphecy->reveal(), $serverRequestCreator->createServerRequestFromGlobals());
}

public function testSetServerRequestCreatorWithDecorators()
{
ServerRequestCreatorFactory::setSlimHttpDecoratorsAutomaticDetection(true);
$serverRequestProphecy = $this->prophesize(ServerRequestInterface::class);

$serverRequestCreatorProphecy = $this->prophesize(ServerRequestCreatorInterface::class);
$serverRequestCreatorProphecy
->createServerRequestFromGlobals()
->willReturn($serverRequestProphecy->reveal())
->shouldBeCalledOnce();

ServerRequestCreatorFactory::setServerRequestCreator($serverRequestCreatorProphecy->reveal());

$serverRequestCreator = ServerRequestCreatorFactory::create();

$this->assertInstanceOf(ServerRequest::class, $serverRequestCreator->createServerRequestFromGlobals());
}
}

0 comments on commit 2974dc3

Please sign in to comment.