PostfixAdmin - web based virtual user administration interface for Postfix mail servers https://postfixadmin.github.io/postfixadmin/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

61 lines
2.0 KiB

  1. <?php
  2. /**
  3. * Test for Postfixadmin - remote vacation stuff
  4. *
  5. * @package tests
  6. */
  7. require_once('RemoteTest.php');
  8. class RemoteVacationTest extends RemoteTest {
  9. /**
  10. * Adds the test recipient data to the database.
  11. */
  12. public function setUp(): void {
  13. // Ensure config.inc.php is vaguely correct.
  14. global $CONF;
  15. if ($CONF['vacation'] != 'YES' || $CONF['vacation_control'] != "YES") {
  16. $this->markTestSkipped("Cannot run tests; vacation not enabled - see config.inc.php");
  17. }
  18. if ($CONF['vacation_domain'] != 'autoreply.example.com') {
  19. $this->markTestSkipped("Cannot run tests; vacation_domain is not set to autoreply.example.com - see config.inc.php");
  20. }
  21. parent::setUp();
  22. }
  23. public function testIsVacationSupported() {
  24. $this->assertTrue($this->vacation->isVacationSupported());
  25. }
  26. public function testCheckVacation() {
  27. $this->assertFalse($this->vacation->checkVacation());
  28. }
  29. public function testGetDetails() {
  30. $details = $this->vacation->getDetails();
  31. $this->assertFalse($details); // empty by default (thanks to tearDown/setUp);
  32. }
  33. public function testSetAway() {
  34. $this->assertFalse($this->vacation->checkVacation());
  35. $this->assertTrue($this->vacation->setAway('zzzz', 'aaaa'));
  36. $this->assertTrue($this->vacation->checkVacation());
  37. $details = $this->vacation->getDetails();
  38. $this->assertEquals($details['subject'], 'zzzz');
  39. $this->assertEquals($details['body'], 'aaaa');
  40. $this->vacation->remove();
  41. $details = $this->vacation->getDetails();
  42. $this->assertEquals($details['subject'], 'zzzz');
  43. $this->assertEquals($details['body'], 'aaaa');
  44. $this->vacation->setAway('subject', 'body');
  45. $details = $this->vacation->getDetails();
  46. $this->assertEquals($details['subject'], 'subject');
  47. $this->assertEquals($details['body'], 'body');
  48. }
  49. }
  50. /* vim: set expandtab softtabstop=4 tabstop=4 shiftwidth=4: */