Files
FOSSBilling/tests/library/Box/Box_MailTest.php
T
Belle Aerni 3011c8a4b0 Move PHPStan to it's own action & bump the scanning level (#629)
* Move PHPStan to it's own action

* Bump PHPStan to level 1

* This fix it?

* Update Box_MailTest.php

* And fix a typo in the action

* Update phpstan.yml

* Update phpstan.yml

* Test
2022-12-28 04:32:17 -08:00

100 lines
2.3 KiB
PHP

<?php
/**
* @group Core
*/
class Box_MailTest extends PHPUnit\Framework\TestCase
{
public function testsend_TransportSendMail()
{
$transport = 'sendmail';
$mailMock = $this->getMockBuilder(Box_Mail::class)
->setMethods(array('_sendMail'))
->getMock();
$mailMock->expects($this->once())
->method('_sendMail');
$mailMock->send($transport);
}
public function testsend_TransportSmtp()
{
$transport = 'smtp';
$mailMock = $this->getMockBuilder('Box_Mail')
->setMethods(array('_sendSmtpMail'))
->getMock();
$mailMock->expects($this->once())
->method('_sendSmtpMail')
->with(array());
$mailMock->send($transport);
}
public function testsend_TransportUnknown()
{
$transport = 'mailServer';
$mail = new Box_Mail();
$this->expectException(\Box_Exception::class);
$this->expectExceptionMessage(sprintf('Unknown mail transport: %s', $transport));
$mail->send($transport);
}
public function testsetBodyHtml()
{
$context = 'Mail body';
$mail = new Box_Mail();
$result = $mail->setBodyHtml($context);
$this->assertInstanceOf(Box_Mail::class, $result);
$result = $mail->getBody();
$this->assertEquals($context, $result);
}
public function testsetFrom()
{
$context = 'jobs@fossbilling.org';
$mail = new Box_Mail();
$result = $mail->setFrom($context);
$this->assertInstanceOf(Box_Mail::class, $result);
}
public function testsetSubject()
{
$context = 'Mail title';
$mail = new Box_Mail();
$result = $mail->setSubject($context);
$this->assertInstanceOf(Box_Mail::class, $result);
$result = $mail->getSubject();
$this->assertEquals($context, $result);
}
public function testsetReplyTo()
{
$context = 'do-not-reply@fossbilling.org';
$mail = new Box_Mail();
$result = $mail->setReplyTo($context);
$this->assertInstanceOf(Box_Mail::class, $result);
}
public function testaddTo()
{
$context = 'bcc@fossbilling.org';
$mail = new Box_Mail();
$result = $mail->addTo($context);
$this->assertInstanceOf(Box_Mail::class, $result);
}
}