File: RemoteVacationTest.php

package info (click to toggle)
postfixadmin 2.3.5-2%2Bdeb7u1
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 6,200 kB
  • sloc: php: 25,767; xml: 14,485; perl: 964; sh: 664; python: 169; makefile: 84
file content (83 lines) | stat: -rw-r--r-- 2,552 bytes parent folder | download | duplicates (3)
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
<?php
/**
 * Test for Postfixadmin - remote vacation stuff
 *
 * @package tests
 */

require_once('RemoteTest.php');

class RemoteVacationTest extends RemoteTest {
    
    public function __construct() {
        parent::__construct();
        global $CONF;

        // Ensure config.inc.php is vaguely correct.
        if($CONF['vacation'] != 'YES' || $CONF['vacation_control'] != "YES") {
            die("Cannot run tests; vacation not enabled - see config.inc.php");
        }
        if($CONF['vacation_domain'] != 'autoreply.example.com') {
            die("Cannot run tests; vacation_domain is not set to autoreply.example.com - see config.inc.php");
        } 
    }


    /**
     * Adds the test recipient data to the database.
     */
    public function setUp() {
        parent::setUp();
    }
    public function tearDown() {
        parent::tearDown();
    }

    public function testIsVacationSupported() {
        try {
            $this->assertTrue($this->vacation->isVacationSupported());
        }
        catch(Exception $e){ 
            var_dump($e);
            var_dump($this->xmlrpc_client->getHttpClient()->getLastResponse()->getBody());
            die("fail..");
        }
    }

    public function testCheckVacation() {
        $this->assertFalse($this->vacation->checkVacation());
    }


    public function testGetDetails() {
        $details = $this->vacation->getDetails();
        $this->assertFalse($details); // empty by default (thansk to tearDown/setUp);
    } 

    public function testSetAway() {
        try {
            $this->assertFalse($this->vacation->checkVacation());
            $this->assertTrue($this->vacation->setAway('zzzz', 'aaaa'));
            $this->assertTrue($this->vacation->checkVacation());
        }
        catch(Exception $e) {
            var_dump($this->xmlrpc_client->getHttpClient()->getLastResponse()->getBody());
        }
        $details = $this->vacation->getDetails();
        $this->assertEqual($details['subject'], 'zzzz');
        $this->assertEqual($details['body'], 'aaaa');

        $this->vacation->remove();
        $details = $this->vacation->getDetails();
        $this->assertEqual($details['subject'], 'zzzz');
        $this->assertEqual($details['body'], 'aaaa');

        $this->vacation->setAway('subject', 'body');
        $details = $this->vacation->getDetails();
        $this->assertEqual($details['subject'], 'subject');
        $this->assertEqual($details['body'], 'body');
    }
    
}

/* vim: set expandtab softtabstop=4 tabstop=4 shiftwidth=4: */