Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Randomize tests #3024

Merged
merged 5 commits into from
Nov 22, 2020
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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