function test_prints_results()
 {
     $CLI_runner = new TestRunnerCLI();
     $CLI_runner->time_precision = 0;
     $CLI_runner->add_test_case(new TestingTestCase());
     ob_start();
     $CLI_runner->print_results();
     $result = ob_get_contents();
     ob_end_clean();
     $prove = explode("\n", $result);
     $clear_screen = urldecode("%1B%5BH%1B%5B2J");
     //$this->assert_equals($clear_screen, $prove[0]);
     $failed_test = "[FAIL] [0 ms] [TestingTestCase] test_one line 9";
     $this->assert_equals($failed_test, $prove[1]);
     $passed_test = "\\[\\x1b\\[0;32mPASS\\x1b\\[m\\] \\[0 ms\\] \\[TestingTestCase\\] test_two";
     $this->assert_true(preg_match("/" . $passed_test . "/", $result) == 1);
     $summary = "Cases: 1  Passed tests: 2  Failed tests: 1  Total assertions: 3  Running time: 0 ms";
     $this->assert_true(preg_match("/" . $summary . "/", $result) == 1);
 }
예제 #2
0
<?php

error_reporting(E_ALL ^ E_NOTICE);
ini_set('display_errors', '1');
require_once "LiteTestPHP.php";
require_once "TestMatrix.class.php";
$test_runner = new TestRunnerCLI();
$test_runner->add_test_case(new TestMatrix());
$test_runner->print_results();
예제 #3
0
<?php

// 1. Include Lite Test PHP
require_once dirname(__FILE__) . "/../LiteTestPHP.php";
// 2. Create a TestCase and add some tests. Test functions must have a test_ prefix
class TestCaseMyClass extends TestCase
{
    function test_my_class()
    {
        $my_class = new MyClass();
        $this->assert_true($my_class instanceof MyClass);
    }
}
// 3. Choose a TestRunner and add your TestCase (CLI runner in this case)
$runner = new TestRunnerCLI();
$runner->add_test_case(new TestCaseMyClass());
// 4. Run your tests
$runner->print_results();
class MyClass
{
}