Skip to content

Commit

Permalink
Merge pull request #316 from gacela-project/fix/flacky-tests
Browse files Browse the repository at this point in the history
Fix flacky feature static facade tests
  • Loading branch information
Chemaclass authored Aug 11, 2024
2 parents 23ec9d0 + 2aebbee commit 68f663c
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions tests/Feature/Framework/StaticFacade/FeatureTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
use GacelaTest\Feature\Framework\StaticFacade\ModuleA\Factory as StaticFactory;
use GacelaTest\Feature\Framework\StaticFacade\ModuleB\Facade as TestObjectFacade;
use GacelaTest\Feature\Framework\StaticFacade\ModuleB\Factory as ObjectFactory;
use PHPUnit\Framework\Attributes\PreserveGlobalState;
use PHPUnit\Framework\Attributes\RunInSeparateProcess;
use PHPUnit\Framework\TestCase;

final class FeatureTest extends TestCase
Expand All @@ -18,41 +20,53 @@ protected function setUp(): void
Gacela::bootstrap(__DIR__);
}

#[RunInSeparateProcess]
#[PreserveGlobalState(false)]
public function test_unknown_static_facade_method(): void
{
$this->expectExceptionMessage("Method unknown: 'unknown'");

TestStaticFacade::unknown();
}

#[RunInSeparateProcess]
#[PreserveGlobalState(false)]
public function test_unknown_object_factory_method(): void
{
$this->expectExceptionMessage("Method unknown: 'unknown'");

(new TestObjectFacade())->unknown();
}

#[RunInSeparateProcess]
#[PreserveGlobalState(false)]
public function test_unknown_static_factory_method(): void
{
$this->expectExceptionMessage("Method unknown: 'innerUnknownFacadeMethod'");

TestStaticFacade::unknownFacadeMethod();
}

#[RunInSeparateProcess]
#[PreserveGlobalState(false)]
public function test_module_a_static_facade(): void
{
$actual = TestStaticFacade::createString();

self::assertSame(StaticFactory::STR, $actual);
}

#[RunInSeparateProcess]
#[PreserveGlobalState(false)]
public function test_module_a_object_facade(): void
{
$actual = (new TestObjectFacade())->createString();

self::assertSame(ObjectFactory::STR, $actual);
}

#[RunInSeparateProcess]
#[PreserveGlobalState(false)]
public function test_factory_static_facade_method(): void
{
$actual = TestStaticFacade::getFactory()->createString();
Expand Down

0 comments on commit 68f663c

Please sign in to comment.