Skip to content

Commit

Permalink
Show host and port in header of EmailCollector
Browse files Browse the repository at this point in the history
  • Loading branch information
natanfelles committed Oct 2, 2022
1 parent bb0dfa8 commit 2926783
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/Debug/EmailCollector.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ public function getContents() : string
echo '<p>This collector has not been added to a Mailer instance.</p>';
return \ob_get_clean(); // @phpstan-ignore-line
}
echo $this->showHeader();
if ( ! $this->hasData()) {
echo '<p>No messages have been sent.</p>';
return \ob_get_clean(); // @phpstan-ignore-line
Expand Down Expand Up @@ -139,4 +140,15 @@ public function getContents() : string
endforeach;
return \ob_get_clean(); // @phpstan-ignore-line
}

protected function showHeader() : string
{
\ob_start();
$configs = $this->mailer->getConfigs();
?>
<p><strong>Host:</strong> <?= \htmlentities($configs['host']) ?></p>
<p><strong>Port:</strong> <?= \htmlentities((string) $configs['port']) ?></p>
<?php
return \ob_get_clean(); // @phpstan-ignore-line
}
}
8 changes: 8 additions & 0 deletions tests/Debug/EmailCollectorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,14 @@ public function testNoData() : void
);
}

public function testHeader() : void
{
$this->makeMailer();
$contents = $this->collector->getContents();
self::assertStringContainsString('Host:', $contents);
self::assertStringContainsString('Port:', $contents);
}

public function testMessagesSent() : void
{
$message = new Message();
Expand Down

0 comments on commit 2926783

Please sign in to comment.