Skip to content

Commit 5ecb0ce

Browse files
committed
refactor CacheEventHandlersCommandTest
1 parent 1a391f8 commit 5ecb0ce

File tree

3 files changed

+15
-23
lines changed

3 files changed

+15
-23
lines changed

composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
"pestphp/pest": "^1.22",
4444
"phpunit/phpunit": "^9.5.10",
4545
"spatie/fork": "^1.0",
46+
"spatie/pest-plugin-snapshots": "^1.1",
4647
"spatie/phpunit-snapshot-assertions": "^4.0"
4748
},
4849
"autoload": {

tests/Console/CacheEventHandlersCommandTest.php

Lines changed: 10 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -3,33 +3,20 @@
33
namespace Spatie\EventSourcing\Tests\Console;
44

55
use Spatie\EventSourcing\Projectionist;
6-
use Spatie\EventSourcing\Tests\TestCase;
76
use Spatie\EventSourcing\Tests\TestClasses\Projectors\BalanceProjector;
87
use Spatie\EventSourcing\Tests\TestClasses\Reactors\BrokeReactor;
9-
use Spatie\Snapshots\MatchesSnapshots;
8+
use function Spatie\Snapshots\assertMatchesSnapshot;
109

11-
class CacheEventHandlersCommandTest extends TestCase
12-
{
13-
use MatchesSnapshots;
10+
beforeEach(function () {
11+
$this->projectionist = app(Projectionist::class);
12+
});
1413

15-
protected Projectionist $projectionist;
14+
test('it can cache the registered projectors', function () {
15+
$this->projectionist->addProjector(BalanceProjector::class);
1616

17-
public function setUp(): void
18-
{
19-
parent::setUp();
17+
$this->projectionist->addReactor(BrokeReactor::class);
2018

21-
$this->projectionist = app(Projectionist::class);
22-
}
19+
$this->artisan('event-sourcing:cache-event-handlers')->assertExitCode(0);
2320

24-
/** @test */
25-
public function it_can_cache_the_registered_projectors()
26-
{
27-
$this->projectionist->addProjector(BalanceProjector::class);
28-
29-
$this->projectionist->addReactor(BrokeReactor::class);
30-
31-
$this->artisan('event-sourcing:cache-event-handlers')->assertExitCode(0);
32-
33-
$this->assertMatchesSnapshot(file_get_contents(config('event-sourcing.cache_path').'/event-handlers.php'));
34-
}
35-
}
21+
assertMatchesSnapshot(file_get_contents(config('event-sourcing.cache_path').'/event-handlers.php'));
22+
});
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<?php return array (
2+
'Spatie\\EventSourcing\\Tests\\TestClasses\\Projectors\\BalanceProjector' => 'Spatie\\EventSourcing\\Tests\\TestClasses\\Projectors\\BalanceProjector',
3+
'Spatie\\EventSourcing\\Tests\\TestClasses\\Reactors\\BrokeReactor' => 'Spatie\\EventSourcing\\Tests\\TestClasses\\Reactors\\BrokeReactor',
4+
);

0 commit comments

Comments
 (0)