diff options
author | Derek Jones <derek.jones@ellislab.com> | 2011-10-05 22:34:21 +0200 |
---|---|---|
committer | Derek Jones <derek.jones@ellislab.com> | 2011-10-05 22:34:21 +0200 |
commit | 318539232acac992c36dd94998a1db2d6df496a8 (patch) | |
tree | 5aa30b9177654c8900f0f809bf6b1274eba67a6d /user_guide_src/source | |
parent | 87d152e034920094e53593bbd2308666ed909814 (diff) |
fixed code block samples for Unit Testing lib
Diffstat (limited to 'user_guide_src/source')
-rw-r--r-- | user_guide_src/source/libraries/unit_testing.rst | 23 |
1 files 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 = ' <table border="0" cellpadding="4" cellspacing="1"> {rows} <tr> <td>{item}</td> <td>{result}</td> </tr> {/rows} </table>'; $this->unit->set_template($str); + $str = ' + <table border="0" cellpadding="4" cellspacing="1"> + {rows} + <tr> + <td>{item}</td> + <td>{result}</td> + </tr> + {/rows} + </table>'; + + $this->unit->set_template($str); .. note:: Your template must be declared **before** running the unit test process. |