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 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109
|
<?php
namespace AsyncAws\Ses\Tests\Integration;
use AsyncAws\Core\Credentials\NullProvider;
use AsyncAws\Core\Test\TestCase;
use AsyncAws\Ses\Input\DeleteSuppressedDestinationRequest;
use AsyncAws\Ses\Input\GetSuppressedDestinationRequest;
use AsyncAws\Ses\Input\SendEmailRequest;
use AsyncAws\Ses\SesClient;
use AsyncAws\Ses\ValueObject\Body;
use AsyncAws\Ses\ValueObject\Content;
use AsyncAws\Ses\ValueObject\Destination;
use AsyncAws\Ses\ValueObject\EmailContent;
use AsyncAws\Ses\ValueObject\Message;
use AsyncAws\Ses\ValueObject\MessageTag;
use AsyncAws\Ses\ValueObject\RawMessage;
use AsyncAws\Ses\ValueObject\Template;
class SesClientTest extends TestCase
{
public function testDeleteSuppressedDestination(): void
{
$client = $this->getClient();
$input = new DeleteSuppressedDestinationRequest([
'EmailAddress' => 'test@example.com',
]);
$result = $client->deleteSuppressedDestination($input);
$result->resolve();
}
public function testGetSuppressedDestination(): void
{
$client = $this->getClient();
$input = new GetSuppressedDestinationRequest([
'EmailAddress' => 'test@example.com',
]);
$result = $client->getSuppressedDestination($input);
$result->resolve();
$dest = $result->getSuppressedDestination();
self::assertSame('test@example.com', $dest->getEmailAddress());
}
public function testSendEmail(): void
{
$client = $this->getClient();
$input = new SendEmailRequest([
'FromEmailAddress' => 'change me',
'Destination' => new Destination([
'ToAddresses' => ['change me'],
'CcAddresses' => ['change me'],
'BccAddresses' => ['change me'],
]),
'ReplyToAddresses' => ['change me'],
'FeedbackForwardingEmailAddress' => 'change me',
'Content' => new EmailContent([
'Simple' => new Message([
'Subject' => new Content([
'Data' => 'change me',
'Charset' => 'change me',
]),
'Body' => new Body([
'Text' => new Content([
'Data' => 'change me',
'Charset' => 'change me',
]),
'Html' => new Content([
'Data' => 'change me',
'Charset' => 'change me',
]),
]),
]),
'Raw' => new RawMessage([
'Data' => 'change me',
]),
'Template' => new Template([
'TemplateArn' => 'change me',
'TemplateData' => 'change me',
]),
]),
'EmailTags' => [new MessageTag([
'Name' => 'change me',
'Value' => 'change me',
])],
'ConfigurationSetName' => 'change me',
]);
$result = $client->SendEmail($input);
$result->resolve();
self::assertStringContainsString('change it', $result->getMessageId());
}
private function getClient(): SesClient
{
self::markTestSkipped('No Docker image for SES');
return new SesClient([
'endpoint' => 'http://localhost',
], new NullProvider());
}
}
|