| 1 |
<?php |
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
namespace MediaWiki\Tests\Integration\Mail; |
| 22 |
|
| 23 |
use MailAddress; |
| 24 |
use MediaWiki\Mail\Emailer; |
| 25 |
use MediaWikiIntegrationTestCase; |
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
class EmailerTest extends MediaWikiIntegrationTestCase { |
| 33 |
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
public function testSend( $to, MailAddress $from, string $subject, string $bodyText, ?string $bodyHtml = null, |
| 39 |
array $options = [] ) { |
| 40 |
$emailer = new Emailer(); |
| 41 |
$status = $emailer->send( $to, $from, $subject, $bodyText, $bodyHtml, $options ); |
| 42 |
|
| 43 |
$this->assertTrue( $status->isGood() ); |
| 44 |
} |
| 45 |
|
| 46 |
public function testSendWithBadAddress() { |
| 47 |
|
| 48 |
$emailer = new Emailer(); |
| 49 |
|
| 50 |
$status = $emailer->send( |
| 51 |
new MailAddress( ' ', 'Sender', 'Real name' ), |
| 52 |
new MailAddress( ' ', 'Recipient', 'Real name' ), |
| 53 |
'', |
| 54 |
'', |
| 55 |
); |
| 56 |
|
| 57 |
$this->assertFalse( $status->isGood() ); |
| 58 |
} |
| 59 |
|
| 60 |
public function provideSend(): array { |
| 61 |
$from = new MailAddress( '[email protected]', 'UserName', 'Real name' ); |
| 62 |
$to = new MailAddress( '[email protected]', 'UserName', 'Real name' ); |
| 63 |
$bodyHtml = '<p>Hello, World!</p>'; |
| 64 |
return [ |
| 65 |
[ $to, $from, 'Test subject', 'Hello, World!' ], |
| 66 |
[ $to, $from, 'Test subject', 'Hello, World!', $bodyHtml ], |
| 67 |
[ $to, $from, 'Test subject', 'Hello, World!', $bodyHtml, [ 'cc' => [ $from ] ] ], |
| 68 |
]; |
| 69 |
} |
| 70 |
} |