Skip to content

Commit 4f5cb60

Browse files
committed
feat(event-bus): wire mailer event bus into testing helpers
1 parent 41225f2 commit 4f5cb60

File tree

4 files changed

+8
-5
lines changed

4 files changed

+8
-5
lines changed

packages/event-bus/src/Testing/EventBusTester.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use Tempest\Container\Container;
88
use Tempest\EventBus\EventBus;
99
use Tempest\EventBus\EventBusConfig;
10+
use Tempest\Mail\Testing\MailTester;
1011
use Tempest\Support\Str;
1112

1213
final class EventBusTester
@@ -15,6 +16,7 @@ final class EventBusTester
1516

1617
public function __construct(
1718
private readonly Container $container,
19+
private readonly MailTester $mailTester,
1820
) {}
1921

2022
/**
@@ -24,6 +26,7 @@ public function preventEventHandling(): self
2426
{
2527
$this->fakeEventBus = new FakeEventBus($this->container->get(EventBusConfig::class));
2628
$this->container->singleton(EventBus::class, $this->fakeEventBus);
29+
$this->mailTester->mailer->eventBus = $this->container->get(EventBus::class);
2730

2831
return $this;
2932
}

packages/mail/src/Testing/MailTester.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ final class MailTester
2525
private ?SymfonyEmail $sentSymfonyEmail = null;
2626

2727
public function __construct(
28-
private readonly TestingMailer $mailer,
28+
public readonly TestingMailer $mailer,
2929
) {}
3030

3131
public function send(Email $email): self

packages/mail/src/Testing/TestingMailer.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
final class TestingMailer implements Mailer
1111
{
1212
public function __construct(
13-
private readonly ?EventBus $eventBus = null,
13+
public ?EventBus $eventBus = null,
1414
) {}
1515

1616
/**

src/Tempest/Framework/Testing/IntegrationTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -139,12 +139,12 @@ protected function setupTesters(): self
139139
{
140140
$this->http = new HttpRouterTester($this->container);
141141
$this->installer = new InstallerTester($this->container);
142-
$this->eventBus = new EventBusTester($this->container);
143-
$this->storage = new StorageTester($this->container);
144-
$this->cache = new CacheTester($this->container);
145142
$this->mailer = new MailTester(new TestingMailer(
146143
eventBus: $this->container->get(EventBus::class),
147144
));
145+
$this->eventBus = new EventBusTester($this->container, $this->mailer);
146+
$this->storage = new StorageTester($this->container);
147+
$this->cache = new CacheTester($this->container);
148148

149149
$this->process = $this->container->get(ProcessTester::class);
150150
$this->process->disableProcessExecution();

0 commit comments

Comments
 (0)