Skip to content

Commit fbf3bd2

Browse files
committed
[Notifier] Inject Mailer instead of service locator for FakeSms and FakeChat
1 parent f0929d2 commit fbf3bd2

File tree

2 files changed

+69
-0
lines changed

2 files changed

+69
-0
lines changed

Tests/Fixtures/TestOptions.php

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <[email protected]>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Component\Notifier\Tests\Fixtures;
13+
14+
use Symfony\Component\Notifier\Message\MessageInterface;
15+
use Symfony\Component\Notifier\Message\MessageOptionsInterface;
16+
17+
final class TestOptions implements MessageOptionsInterface
18+
{
19+
private $options;
20+
21+
public function __construct(array $options = [])
22+
{
23+
$this->options = $options;
24+
}
25+
26+
public function getRecipientId(): ?string
27+
{
28+
return $this->options['recipient_id'];
29+
}
30+
31+
public function toArray(): array
32+
{
33+
return $this->options;
34+
}
35+
}

Tests/Mailer/DummyMailer.php

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <[email protected]>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespace Symfony\Component\Notifier\Tests\Mailer;
13+
14+
use Symfony\Component\Mailer\Envelope;
15+
use Symfony\Component\Mailer\MailerInterface;
16+
use Symfony\Component\Mime\RawMessage;
17+
18+
/**
19+
* @author Oskar Stark <[email protected]>
20+
*/
21+
class DummyMailer implements MailerInterface
22+
{
23+
private $sentMessage = null;
24+
25+
public function send(RawMessage $message, Envelope $envelope = null): void
26+
{
27+
$this->sentMessage = $message;
28+
}
29+
30+
public function getSentEmail(): RawMessage
31+
{
32+
return $this->sentMessage;
33+
}
34+
}

0 commit comments

Comments
 (0)