The feed links, the notification email, the webmaster address and the cookie domain now use it.
46 lines
2.0 KiB
PHP
46 lines
2.0 KiB
PHP
<?php
|
|
namespace Xxx\Tests\Unit;
|
|
|
|
use Xxx\Tests\Support\Mail;
|
|
use Xxx\Tests\Support\TestCase;
|
|
|
|
// send_email() in publish/post.lib.php
|
|
class EmailTest extends TestCase {
|
|
private function send(string $title, string $author, string $story): array {
|
|
$result = Mail::run('send_email(' . var_export($title, TRUE) . ', ' . var_export($author, TRUE) . ', ' . var_export($story, TRUE) . ');');
|
|
$this->assertSame(0, $result['status'], $result['stderr']);
|
|
$this->assertCount(1, $result['mails'], $result['stderr']);
|
|
$this->assertSame('', $result['log']);
|
|
return $result['mails'][0];
|
|
}
|
|
|
|
public function testGoesToTheEditorsFromTheQueue(): void {
|
|
$mail = $this->send('A title', 'Ann', '<p>Hello.</p>');
|
|
$this->assertSame('editor@site.test', $mail['headers']['to']);
|
|
$this->assertSame('x.x.x Queue <editor@site.test>', $mail['headers']['from']);
|
|
$this->assertSame('New submission: A title', $mail['subject']);
|
|
}
|
|
|
|
public function testSubjectKeepsNonAsciiTitles(): void {
|
|
$this->assertSame('New submission: Ōmega café', $this->send('Ōmega café', 'Ann', '<p>x</p>')['subject']);
|
|
}
|
|
|
|
public function testBodyIsPlainTextOfTheStory(): void {
|
|
$mail = $this->send('T', 'Ann', "<p>First & <strong>bold</strong>.</p>\n<p>Line one<br />line two</p><p></p><p><b> is text “quoted”</p>");
|
|
$this->assertSame("Please review the queue. Ann has sent the following new submission:\n\n"
|
|
. "First & bold.\n\nLine one\nline two\n\n<b> is text “quoted”"
|
|
. "\n\nhttps://site.test/publish/edit", trim($mail['body']));
|
|
}
|
|
|
|
public function testLongLinesAreWrapped(): void {
|
|
$body = $this->send('T', 'Ann', '<p>' . str_repeat('word ', 40) . '</p>')['body'];
|
|
foreach (explode("\n", trim($body)) as $line)
|
|
$this->assertLessThanOrEqual(75, strlen($line));
|
|
}
|
|
|
|
public function testImageSubmissionSaysSo(): void {
|
|
$body = $this->send('T', 'Ann', '')['body'];
|
|
$this->assertStringContainsString("new submission:\n\n<Submission is an image. Review on the site.>", $body);
|
|
}
|
|
}
|