function test_if_case_provided_in_construct_autoruns() { ob_start(); $CLI_runner = new TestRunnerCLI(new TestingTestCase()); $result = ob_get_contents(); ob_end_clean(); $test_results = $CLI_runner->get_results(); $this->assert_equals(2, sizeof($test_results["TestingTestCase"])); }
<?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();
<?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 { }
<?php require_once dirname(__FILE__) . "/.." . DIRECTORY_SEPARATOR . "LiteTestPHP.php"; $test_runner = new TestRunnerCLI(); require_once dirname(__FILE__) . "/battery.php"; $test_runner->print_results();