-
-
Notifications
You must be signed in to change notification settings - Fork 77
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: apply WithStory attribute at class level
- Loading branch information
Showing
2 changed files
with
55 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
tests/Integration/Attribute/WithStory/WithStoryOnClassTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Integration\Attribute\WithStory; | ||
|
||
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase; | ||
use Zenstruck\Foundry\Attribute\WithStory; | ||
use Zenstruck\Foundry\Test\Factories; | ||
use Zenstruck\Foundry\Test\ResetDatabase; | ||
use Zenstruck\Foundry\Tests\Fixture\Factories\Entity\GenericEntityFactory; | ||
use Zenstruck\Foundry\Tests\Fixture\Stories\EntityPoolStory; | ||
use Zenstruck\Foundry\Tests\Fixture\Stories\EntityStory; | ||
|
||
#[WithStory(EntityStory::class)] | ||
final class WithStoryOnClassTest extends KernelTestCase | ||
{ | ||
use Factories, ResetDatabase; | ||
|
||
/** | ||
* @test | ||
*/ | ||
public function can_use_story_in_attribute(): void | ||
{ | ||
GenericEntityFactory::assert()->count(2); | ||
|
||
// ensure state is accessible | ||
$this->assertSame('foo', EntityStory::get('foo')->getProp1()); | ||
} | ||
|
||
/** | ||
* @test | ||
*/ | ||
#[WithStory(EntityStory::class)] | ||
public function can_use_story_in_attribute_multiple_times(): void | ||
{ | ||
GenericEntityFactory::assert()->count(2); | ||
} | ||
|
||
/** | ||
* @test | ||
*/ | ||
#[WithStory(EntityPoolStory::class)] | ||
public function can_use_another_story_at_level_class(): void | ||
{ | ||
GenericEntityFactory::assert()->count(5); | ||
} | ||
} |