Skip to content

Commit

Permalink
fix: mail api
Browse files Browse the repository at this point in the history
  • Loading branch information
papac committed Jan 26, 2025
1 parent 1c2fbfa commit 308dc47
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
9 changes: 6 additions & 3 deletions src/Mail/Adapters/NativeAdapter.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,14 +48,14 @@ public function __construct(array $config = [])
*/
public function on(string $from): NativeAdapter
{
if (!isset($this->config["froms"][$from])) {
if (!isset($this->config["from"][$from])) {
throw new MailException(
"There are not entry for [$from]",
E_USER_ERROR
);
}

$this->from = $this->config["froms"][$from];
$this->from = $this->config["from"][$from];

return $this;
}
Expand Down Expand Up @@ -86,7 +86,10 @@ public function send(Envelop $envelop): bool

$envelop->setDefaultHeader();

foreach ($envelop->getTo() as $value) {
foreach ($envelop->getTo() as $key => $value) {
if ($key > 0) {
$to .= ', ';
}
if ($value[0] !== null) {
$to .= $value[0] . ' <' . $value[1] . '>';
} else {
Expand Down
2 changes: 1 addition & 1 deletion src/Mail/Mail.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ public static function raw(string|array $to, string $subject, string $data, arra

$envelop = new Envelop();

$envelop->toList($to)->subject($subject)->setMessage($data);
$envelop->to($to)->subject($subject)->setMessage($data);

foreach ($headers as $key => $value) {
$envelop->addHeader($key, $value);
Expand Down
8 changes: 5 additions & 3 deletions tests/Queue/MessagingQueueTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,17 +44,19 @@ protected function setUp(): void
{
parent::setUp();

$this->context = new TestNotifiableModel();
$this->context = $this->createMock(TestNotifiableModel::class);
$this->message = $this->createMock(TestMessage::class);
}

public function test_can_send_message_synchronously(): void
{
$context = new TestNotifiableModel();

$this->message->expects($this->once())
->method('process')
->with($this->context);
->with($context);

$this->context->sendMessage($this->message);
$context->sendMessage($this->message);
}

public function test_can_send_message_to_queue(): void
Expand Down

0 comments on commit 308dc47

Please sign in to comment.