-
Notifications
You must be signed in to change notification settings - Fork 0
/
AdapterTest.php
35 lines (26 loc) · 1.05 KB
/
AdapterTest.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
<?php
declare(strict_types=1);
namespace structural\adapter;
use app\structural\adapter\ThirdPartyEmailSenderAdapter;
use app\structural\adapter\ThirdPartyEmailClient;
use PHPUnit\Framework\TestCase;
final class AdapterTest extends TestCase
{
public function testThirdPartyEmailSenderAdapterAdapterUsesCorrectClient(): void
{
$emailClient = $this->createMock(ThirdPartyEmailClient::class);
$emailAdapter = new ThirdPartyEmailSenderAdapter($emailClient);
$emailClient->expects($this->once())
->method('sendEmail');
$emailAdapter->sendEmail(
'email@email.com',
'I love design patterns');
}
public function testThirdPartyClient(): void
{
$emailClient = new ThirdPartyEmailClient('apiKey', 'region');
$emailClient->sendEmail('email@email.com', 'I love design patterns');
$this->expectOutputRegex('/Using apiKey apiKey and region region/');
$this->expectOutputRegex('/Sending email to email@email.com and content I love design patterns/');
}
}