Skip to content

Commit

Permalink
feat(faker): display faker seed after test finished
Browse files Browse the repository at this point in the history
  • Loading branch information
nikophil committed Feb 5, 2025
1 parent dd8c733 commit 5f188c6
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
17 changes: 17 additions & 0 deletions src/PHPUnit/DisplayFakerSeedOnTestSuiteFinished.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php

declare(strict_types=1);

namespace Zenstruck\Foundry\PHPUnit;

use PHPUnit\Event\TestRunner\Finished;
use PHPUnit\Event\TestRunner\FinishedSubscriber;
use Zenstruck\Foundry\Configuration;

final class DisplayFakerSeedOnTestSuiteFinished implements FinishedSubscriber
{
public function notify(Finished $event): void
{
echo "\n\nFaker seed: ". Configuration::fakerSeed(); // @phpstan-ignore ekinoBannedCode.expression
}
}
2 changes: 1 addition & 1 deletion src/PHPUnit/FoundryExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public function bootstrap(
Configuration::shutdown();
}

$subscribers = [new BuildStoryOnTestPrepared()];
$subscribers = [new BuildStoryOnTestPrepared(), new DisplayFakerSeedOnTestSuiteFinished()];

if (ConstraintRequirement::from('>=11.4')->isSatisfiedBy(Runner\Version::id())) {
// those deal with data provider events which can be useful only if PHPUnit >=11.4 is used
Expand Down

0 comments on commit 5f188c6

Please sign in to comment.