Skip to content

Commit

Permalink
fix: fix deprecation message for Factories trait
Browse files Browse the repository at this point in the history
  • Loading branch information
nikophil committed Feb 3, 2025
1 parent 636cedd commit 4f1ecd6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/Exception/FactoriesTraitNotUsed.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,8 @@ public static function throwIfClassDoesNotHaveFactoriesTrait(string $class): voi
trigger_deprecation(
'zenstruck/foundry',
'2.4',
'In order to use Foundry, you must use the trait "%s" in your "%s" tests. This will throw an exception in 3.0.',
KernelTestCase::class,
'In order to use Foundry correctly, you must use the trait "%s" in your "%s" tests. This will throw an exception in 3.0.',
Factories::class,
$class
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public function not_using_foundry_should_not_throw_even_when_container_is_used()
#[IgnoreDeprecations]
public function using_foundry_without_trait_should_throw(): void
{
$this->expectUserDeprecationMessageMatches('/In order to use Foundry, you must use the trait/');
$this->assertDeprecation();

Object1Factory::createOne();
}
Expand All @@ -53,7 +53,7 @@ public function using_foundry_without_trait_should_throw(): void
#[IgnoreDeprecations]
public function using_foundry_without_trait_should_throw_even_when_kernel_is_booted(): void
{
$this->expectUserDeprecationMessageMatches('/In order to use Foundry, you must use the trait/');
$this->assertDeprecation();

self::getContainer()->get('.zenstruck_foundry.configuration');

Expand All @@ -65,7 +65,7 @@ public function using_foundry_without_trait_should_throw_even_when_kernel_is_boo
#[IgnoreDeprecations]
public function using_a_story_without_factories_trait_should_throw(): void
{
$this->expectUserDeprecationMessageMatches('/In order to use Foundry, you must use the trait/');
$this->assertDeprecation();

ObjectStory::load();
}
Expand All @@ -88,4 +88,9 @@ public static function _shutdownFoundry(): void
{
Configuration::shutdown();
}

private function assertDeprecation(): void
{
$this->expectUserDeprecationMessageMatches('/In order to use Foundry correctly, you must use the trait "Zenstruck\\\\Foundry\\\\Test\\\\Factories/');
}
}

0 comments on commit 4f1ecd6

Please sign in to comment.