test_main.php 1.88 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
<?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
    }

nepski's avatar
nepski committed
46 47 48 49 50 51 52 53 54 55 56 57
    function test_main_get_feedbackform_return_categories_array() {
        $this->f3->mock('GET /feedback/');
        $this->test->expect(
            is_array($this->f3->get('feedback_categories')),
            "Do not get a categories array"
        );
        $this->f3->clear('ERROR');  // clear any errors
    }

    function test_main_get_feedbackform_return_contact_id() {
        $this->f3->mock('GET /feedback/');
        $this->test->expect(
nepski's avatar
nepski committed
58
            !is_nan($this->f3->get('contact_id')),
nepski's avatar
nepski committed
59 60 61 62
            "Do not get a numeric contact id"
        );
        $this->f3->clear('ERROR');  // clear any errors
    }
63 64 65 66 67
}

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