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
|
<?php
class Swift_Plugins_Reporters_HtmlReporterTest extends \PHPUnit\Framework\TestCase
{
private $html;
private $message;
protected function setUp(): void
{
$this->html = new Swift_Plugins_Reporters_HtmlReporter();
$this->message = $this->createMock('Swift_Mime_SimpleMessage');
}
public function testReportingPass()
{
ob_start();
$this->html->notify($this->message, 'foo@bar.tld',
Swift_Plugins_Reporter::RESULT_PASS
);
$html = ob_get_clean();
$this->assertMatchesRegularExpression('~ok|pass~i', $html, '%s: Reporter should indicate pass');
$this->assertMatchesRegularExpression('~foo@bar\.tld~', $html, '%s: Reporter should show address');
}
public function testReportingFail()
{
ob_start();
$this->html->notify($this->message, 'zip@button',
Swift_Plugins_Reporter::RESULT_FAIL
);
$html = ob_get_clean();
$this->assertMatchesRegularExpression('~fail~i', $html, '%s: Reporter should indicate fail');
$this->assertMatchesRegularExpression('~zip@button~', $html, '%s: Reporter should show address');
}
public function testMultipleReports()
{
ob_start();
$this->html->notify($this->message, 'foo@bar.tld',
Swift_Plugins_Reporter::RESULT_PASS
);
$this->html->notify($this->message, 'zip@button',
Swift_Plugins_Reporter::RESULT_FAIL
);
$html = ob_get_clean();
$this->assertMatchesRegularExpression('~ok|pass~i', $html, '%s: Reporter should indicate pass');
$this->assertMatchesRegularExpression('~foo@bar\.tld~', $html, '%s: Reporter should show address');
$this->assertMatchesRegularExpression('~fail~i', $html, '%s: Reporter should indicate fail');
$this->assertMatchesRegularExpression('~zip@button~', $html, '%s: Reporter should show address');
}
}
|