-
Notifications
You must be signed in to change notification settings - Fork 145
Expand file tree
/
Copy pathMailerFactoryTest.php
More file actions
58 lines (49 loc) · 2.32 KB
/
Copy pathMailerFactoryTest.php
File metadata and controls
58 lines (49 loc) · 2.32 KB
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
<?php
declare(strict_types=1);
namespace Tests\PHPCensor\Helper;
use PHPCensor\Helper\MailerFactory;
use PHPUnit\Framework\TestCase;
/**
* Unit tests for the ProjectService class.
*
* @author Dan Cryer <dan@block8.co.uk>
*/
class MailerFactoryTest extends TestCase
{
public function testExecute_TestGetMailConfig(): void
{
$config = [
'smtp_address' => 'mail.example.com',
'smtp_port' => 225,
'smtp_encryption' => 'tls',
'smtp_username' => 'php-censor-user',
'smtp_password' => 'php-censor-password',
'default_mailto_address' => 'admin@php-censor.local',
];
$factory = new MailerFactory(['email_settings' => $config]);
self::assertEquals($config['smtp_address'], $factory->getMailConfig('smtp_address'));
self::assertEquals($config['smtp_port'], $factory->getMailConfig('smtp_port'));
self::assertEquals($config['smtp_encryption'], $factory->getMailConfig('smtp_encryption'));
self::assertEquals($config['smtp_username'], $factory->getMailConfig('smtp_username'));
self::assertEquals($config['smtp_password'], $factory->getMailConfig('smtp_password'));
self::assertEquals($config['default_mailto_address'], $factory->getMailConfig('default_mailto_address'));
}
public function testExecute_TestMailer(): void
{
$config = [
'smtp_address' => 'mail.example.com',
'smtp_port' => 225,
'smtp_encryption' => 'tls',
'smtp_username' => 'php-censor-user',
'smtp_password' => 'php-censor-password',
'default_mailto_address' => 'admin@php-censor.local',
];
$factory = new MailerFactory(['email_settings' => $config]);
$mailer = $factory->getSwiftMailerFromConfig();
self::assertEquals($config['smtp_address'], $mailer->getTransport()->getHost());
self::assertEquals($config['smtp_port'], $mailer->getTransport()->getPort());
self::assertEquals('tls', $mailer->getTransport()->getEncryption());
self::assertEquals($config['smtp_username'], $mailer->getTransport()->getUsername());
self::assertEquals($config['smtp_password'], $mailer->getTransport()->getPassword());
}
}