File: test.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 (38 lines) | stat: -rw-r--r-- 1,802 bytes parent folder | download | duplicates (2)
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
<?php
    // $Id: test.php,v 1.1 2006/11/29 13:17:01 pp11 Exp $

    require_once(dirname(__FILE__) . '/../array_reporter.php');
    require_once(dirname(__FILE__) . '/../../unit_tester.php');
    require_once(dirname(__FILE__) . '/../../reporter.php');

    class TestOfArrayReporter extends UnitTestCase {
        
        function testContentOfArrayReporterWithOnePassAndOneFailure() {
            $test = &new GroupTest();
            $test->addTestFile(dirname(__FILE__) . '/sample_test.php');
            $result = $test->run(new ArrayReporter());
            $this->assertEqual(count($result), 2);
            
            $this->assertEqual(count($result[0]), 4);
            $this->assertPattern("/".substr(time(), 9)."/", $result[0]['time']);
            $this->assertEqual($result[0]['status'], "Passed");
            $this->assertPattern("/test\.php->SampleTestForArrayReporter->testTrueIsTrue/", $result[0]['test']);
            $this->assertPattern("/ at \[.*array_reporter\/sample_test\.php line 7\]/", $result[0]['message']);

            $this->assertEqual(count($result[1]), 4);
            $this->assertPattern("/".substr(time(), 9)."/", $result[1]['time']);
            $this->assertEqual($result[1]['status'], "Failed");
            $this->assertPattern("/test\.php->SampleTestForArrayReporter->testFalseIsTrue/", $result[1]['test']);
            $this->assertPattern("/Expected false, got \[Boolean: true\] at \[.*array_reporter\/sample_test\.php line 11\]/", $result[1]['message']);
        }
    }
    
    $test = &new GroupTest('Tests for the "array reporter"');
	$test->addTestClass('TestOfArrayReporter');
    if (SimpleReporter::inCli()) {
        $result = $test->run(new TextReporter());
        return ($result ? 0 : 1);
    }
    $test->run(new HtmlReporter());
    
?>