test_main.php 1.27 KB
Newer Older
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
<?php
/*
 * Tests for Main class of piphone
 */
include('BaseTest.php');

class Test_Main_Class extends BaseTest {
    function setup() {
        parent::setup();
        $this->f3->set('QUIET',TRUE);
    }

    function teardown() {
        parent::teardown();
        $this->f3->set('QUIET',FALSE);
    }

    function test_main_existence() {
        $this->test->expect(
            class_exists('Main'),
            'Main class is not defined'
        );
    }

    function test_main_get_campaign_return_array() {
        $this->f3->mock('GET /');
        $this->test->expect(
            is_array($this->f3->get('campaign')),
            'Do not get a campaign array'
        );
        $this->f3->clear('ERROR');  // clear any errors
    }

    function test_main_get_campaign_contains_known_fields() {
        $fields = array("title", "description", "start_date", "end_date", "default_language");
        $this->f3->mock('GET /');
        foreach ($fields as $field) {
            $this->test->expect(
                array_key_exists($field, $this->f3->get('campaign')),
                "Campaign should have a " . $field ." field"
            );
        }
        $this->f3->clear('ERROR');  // clear any errors
    }

}

// Launching tests
$tests = new Test_Main_Class();
$tests->run();