var $test;
|
// initialise class and confirmed its setup correctly.
|
function TestMyClass() {
|
- $this->test = new MyClass();
|
- Assert::equalsTrue(isset($this->test), 'Error during initialisation');
|
+ $this->test = new MyClass(); |
+ Assert::equalsTrue(isset($this->test), 'Error during initialisation'); |
}
|
// check if the initial value is 'not-set'
|
function testGetInitialValue() {
|
- Assert::equalsTrue($this->test->getText() == "not-set", 'Default value is not correct');
|
+ Assert::equalsTrue($this->test->getText() == "not-set", 'Default value is not correct'); |
}
|
// set value and test that it sets
|
function testSetValue() {
|
- $this->test->setText("some test");
|
- Assert::equalsTrue($this->test->getText() == "some text", 'Value is not set');
|
+ $this->test->setText("some test"); |
+ Assert::equalsTrue($this->test->getText() == "some text", 'Value is not set'); |
}
|
}
|
-?>{CODE}
|
+?>{/CODE} |
As you can see, its really not too hard. By browsing to the __index.php__ file, each of the Test* files and classes will be initialised and their results presented on the screen.
|
|
The next steps to this test class could be:
|
* what if you tried to set the text to NULL?
|
-* what if you tried to set the text to ""? |
+* what if you tried to set the text to ""? |
+ |
+!The ))PrePostFilter(( tester |
+A new class was added to the testing framework in |
+order to test smarty filters. The class can actually test all filters that has the signature |
+{CODE source=php}$output = filtername ($input){/CODE} |
+The class could be modified with more |
+to handle other kind of input-output test, but |
+currently only pre- and postfilters are |
+handleled. |
+ |
+!!Input Output tester manual |
+This is a description how to set up tescases for (Smarty)filters. |
+The 'TestBitSmartyFilter.php' is an input - output tester that feeds |
+the contents of a file to the function to be tested (in the first parameter) |
+and compares what the function returns with another file. |
+ |
+Right now the tester is only set up to test smarty filters in the ../kernel/smarty_tiki |
+directory, but testing in other directories could be aded by refactoring the code. |
+ |
+Follow these steps to set up a new test: |
+ |
+# Create a directory (if not allready present) that is named analogously to the filter you want to test: ''filtertype''.''filtername'', e.g. prefilter.tr in the 'smarty_filter_tests' directory |
+# 'chmod' this directory so that it is writeable by your webserver, otherwise creation of the error file, useful for debugging, will not be possible. |
+# Create a file in the created directory that should be used as input for the test. Name it ''arbitraryname''.input |
+# Run the tests by directing your browser to http://''bitweaver_root''/kernel/test |
+# The test will fail, since there is no ''arbitraryname''.output file. Instead a file named ''arbitraryname''.error will be generated. ''arbitraryname'' is the same name as in point 3. |
+# Inspect the ''arbitraryname''.error file. If the output is the expected, you should rename the ''arbitraryname''.error to ''arbitraryname''.output. Running the test again (reloading the browser, should now be succesful). If the output is not the expected, correct the filter and continue from step 4. |
+ |
+You can add more test by creating more files in the directory created in 1. |
+ |
+Happy testing. |
+ |