Skip to content

Commit

Permalink
Merge pull request #3024 from pawel-slowik/randomize-tests
Browse files Browse the repository at this point in the history
Randomize tests
  • Loading branch information
l0gicgate committed Nov 22, 2020
2 parents 9f6a54f + 7df5918 commit 40c1fff
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 0 deletions.
1 change: 1 addition & 0 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
processIsolation="false"
stopOnFailure="false"
bootstrap="tests/bootstrap.php"
executionOrder="random"
>
<testsuites>
<testsuite name="Slim Test Suite">
Expand Down
16 changes: 16 additions & 0 deletions tests/Factory/AppFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,9 @@ public function testDetermineResponseFactoryReturnsDecoratedFactory()
$this->assertInstanceOf(DecoratedResponseFactory::class, $app->getResponseFactory());
}

/**
* @runInSeparateProcess - Psr17FactoryProvider::setFactories breaks other tests
*/
public function testDetermineResponseFactoryThrowsRuntimeException()
{
$this->expectException(RuntimeException::class);
Expand All @@ -103,6 +106,9 @@ public function testSetPsr17FactoryProvider()
$this->assertInstanceOf(SlimResponseFactory::class, AppFactory::determineResponseFactory());
}

/**
* @runInSeparateProcess - Psr17FactoryProvider::setFactories breaks other tests
*/
public function testResponseFactoryIsStillReturnedIfStreamFactoryIsNotAvailable()
{
Psr17FactoryProvider::setFactories([MockPsr17FactoryWithoutStreamFactory::class]);
Expand All @@ -113,6 +119,9 @@ public function testResponseFactoryIsStillReturnedIfStreamFactoryIsNotAvailable(
$this->assertInstanceOf(SlimResponseFactory::class, $app->getResponseFactory());
}

/**
* @runInSeparateProcess - AppFactory::setResponseFactory breaks other tests
*/
public function testAppIsCreatedWithInstancesFromSetters()
{
$responseFactoryProphecy = $this->prophesize(ResponseFactoryInterface::class);
Expand Down Expand Up @@ -166,6 +175,10 @@ public function testAppIsCreatedWithInstancesFromSetters()
);
}

/**
* @runInSeparateProcess - AppFactory::create saves $responseFactory into static::$responseFactory,
* this breaks other tests
*/
public function testAppIsCreatedWithInjectedInstancesFromFunctionArguments()
{
$responseFactoryProphecy = $this->prophesize(ResponseFactoryInterface::class);
Expand Down Expand Up @@ -213,6 +226,9 @@ public function testAppIsCreatedWithInjectedInstancesFromFunctionArguments()
);
}

/**
* @runInSeparateProcess - AppFactory::setResponseFactory breaks other tests
*/
public function testResponseAndStreamFactoryIsBeingInjectedInDecoratedResponseFactory()
{
$responseProphecy = $this->prophesize(ResponseInterface::class);
Expand Down
6 changes: 6 additions & 0 deletions tests/Factory/Psr17/Psr17FactoryProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@

class Psr17FactoryProviderTest extends TestCase
{
/**
* @runInSeparateProcess - Psr17FactoryProvider::setFactories breaks other tests
*/
public function testGetSetFactories()
{
Psr17FactoryProvider::setFactories([]);
Expand All @@ -23,6 +26,9 @@ public function testGetSetFactories()
}


/**
* @runInSeparateProcess - Psr17FactoryProvider::setFactories breaks other tests
*/
public function testAddFactory()
{
Psr17FactoryProvider::setFactories(['Factory 1']);
Expand Down
9 changes: 9 additions & 0 deletions tests/Factory/ServerRequestCreatorFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@ public function testDetermineServerRequestCreatorReturnsDecoratedServerRequestCr
$this->assertInstanceOf(ServerRequest::class, $serverRequestCreator->createServerRequestFromGlobals());
}

/**
* @runInSeparateProcess - Psr17FactoryProvider::setFactories breaks other tests
*/
public function testDetermineServerRequestCreatorThrowsRuntimeException()
{
$this->expectException(RuntimeException::class);
Expand All @@ -90,6 +93,9 @@ public function testSetPsr17FactoryProvider()
$this->assertInstanceOf(SlimServerRequest::class, $serverRequestCreator->createServerRequestFromGlobals());
}

/**
* @runInSeparateProcess - ServerRequestCreatorFactory::setServerRequestCreator breaks other tests
*/
public function testSetServerRequestCreatorWithoutDecorators()
{
ServerRequestCreatorFactory::setSlimHttpDecoratorsAutomaticDetection(false);
Expand All @@ -108,6 +114,9 @@ public function testSetServerRequestCreatorWithoutDecorators()
$this->assertSame($serverRequestProphecy->reveal(), $serverRequestCreator->createServerRequestFromGlobals());
}

/**
* @runInSeparateProcess - ServerRequestCreatorFactory::setServerRequestCreator breaks other tests
*/
public function testSetServerRequestCreatorWithDecorators()
{
ServerRequestCreatorFactory::setSlimHttpDecoratorsAutomaticDetection(true);
Expand Down

0 comments on commit 40c1fff

Please sign in to comment.