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

Fix flacky feature static facade tests #316

Merged
merged 1 commit into from
Aug 11, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading