From 318539232acac992c36dd94998a1db2d6df496a8 Mon Sep 17 00:00:00 2001 From: Derek Jones Date: Wed, 5 Oct 2011 15:34:21 -0500 Subject: fixed code block samples for Unit Testing lib --- user_guide_src/source/libraries/unit_testing.rst | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/user_guide_src/source/libraries/unit_testing.rst b/user_guide_src/source/libraries/unit_testing.rst index 8a80ab228..03819b27c 100644 --- a/user_guide_src/source/libraries/unit_testing.rst +++ b/user_guide_src/source/libraries/unit_testing.rst @@ -34,7 +34,13 @@ Where test is the result of the code you wish to test, expected result is the data type you expect, test name is an optional name you can give your test, and notes are optional notes. Example:: - $test = 1 + 1; $expected_result = 2; $test_name = 'Adds one plus one'; $this->unit->run($test, $expected_result, $test_name); + $test = 1 + 1; + + $expected_result = 2; + + $test_name = 'Adds one plus one'; + + $this->unit->run($test, $expected_result, $test_name); The expected result you supply can either be a literal match, or a data type match. Here's an example of a literal:: @@ -127,12 +133,13 @@ default: You can customize which of these items get displayed by using $this->unit->set_items(). For example, if you only wanted the test name and the result displayed: + Customizing displayed tests --------------------------- :: - $this->unit->set_test_items(array('test_name', 'result')); + $this->unit->set_test_items(array('test_name', 'result')); Creating a Template ------------------- @@ -141,7 +148,17 @@ If you would like your test results formatted differently then the default you can set your own template. Here is an example of a simple template. Note the required pseudo-variables:: - $str = '     {rows}                                         {/rows}
{item}{result}
'; $this->unit->set_template($str); + $str = ' + + {rows} + + + + + {/rows} +
{item}{result}
'; + + $this->unit->set_template($str); .. note:: Your template must be declared **before** running the unit test process. -- cgit v1.2.3-24-g4f1b