Public Member Functions | |
FOUnitTest ($testCaseRoot_) | |
Constructor. | |
writeTestSuiteGui () | |
Write the test suite GUI. | |
getOnlyReportFailes () | |
If true, the GUI should only report failes. | |
getReportFailDetails () | |
If true, the GUI should report more details on failed tests. | |
getCurrentTestCase () | |
The test case that should be executed. | |
getNumOfTestCases () | |
Total number of test case classes/files. | |
getTestCaseFiles () | |
Get all test case classes/files. | |
Private Member Functions | |
_retriveURLArguments () | |
Get arguments from the URL, set default values if not used on url. | |
_initializeSkin () | |
Create an object instance for the GUI Skin. | |
_runAllTests () | |
Will run all unit tests. | |
_runTest ($testCaseNumber_) | |
Will run one test in the $this->_testCaseFilesArr specified by the $testCaseNumber_. | |
_doRetriveAllTestCases () | |
Will retrive all the test case classes in the $this->_testCaseRoot directory. | |
_fillWithFilesFromDir (&$files_InOut, $path_, $addFiles_=FALSE) | |
Fill $files_InOut with all .php files in the $path including subdirectories. | |
_begin () | |
Will write a webpage header for the test. | |
_end () | |
Will write a webpage footer for the test. | |
_writeGuiResult (&$testResult_) | |
Will write a html result out from a UnitTest result. | |
Private Attributes | |
$_skin | |
Choosen skin class used by the GUI. | |
$_skinObj | |
Instance of skin object. | |
$_testCaseRoot | |
Root in which all testcases are located. | |
$_testCaseFilesArr | |
Array with all test case classes. | |
$_numOfTestCases | |
Total number of test case classes/files. | |
$_currentTestCase | |
The number of the current test case choosen with the gui navigator. | |
$_bOnlyReportFailes | |
Will only report failed tests. | |
$_bReportFailDetails | |
Will report a detailed result for failed tests. | |
$_bRunAllTests | |
Run all tests. |
These can be executed in a batch, or be viewed one by one in the integrated GUI.
include_once('FareOfficeLib/FareOfficeLib.php'); $testSuite = &new foUnitTest('./'); $testSuite->writeTestSuiteGui();
Definition at line 20 of file FOUnitTest.class.php.
FOUnitTest::_begin | ( | ) | [private] |
Will write a webpage header for the test.
Definition at line 246 of file FOUnitTest.class.php.
Referenced by writeTestSuiteGui().
FOUnitTest::_doRetriveAllTestCases | ( | ) | [private] |
Will retrive all the test case classes in the $this->_testCaseRoot directory.
Definition at line 191 of file FOUnitTest.class.php.
References _fillWithFilesFromDir().
Referenced by writeTestSuiteGui().
00192 { 00193 $files = array(); 00194 $this->_fillWithFilesFromDir($files, $this->_testCaseRoot); 00195 00196 if (!empty($files)) 00197 { 00198 asort($files); 00199 00200 $testCase = count($this->_testCaseFilesArr); 00201 foreach($files as $file) 00202 { 00203 $testCase++; 00204 $pathParts = pathinfo($file); 00205 00206 $this->_testCaseFilesArr[$testCase] = array 00207 ( 00208 'package' => $pathParts['dirname'], 00209 'path' => $file, 00210 'class_name' => substr($pathParts['basename'], 0, strpos($pathParts['basename'], '.')) 00211 ); 00212 $this->_numOfTestCases++; 00213 } 00214 } 00215 }
FOUnitTest::_end | ( | ) | [private] |
Will write a webpage footer for the test.
Definition at line 254 of file FOUnitTest.class.php.
Referenced by writeTestSuiteGui().
FOUnitTest::_fillWithFilesFromDir | ( | &$ | files_InOut, | |
$ | path_, | |||
$ | addFiles_ = FALSE | |||
) | [private] |
Fill $files_InOut with all .php files in the $path including subdirectories.
Definition at line 220 of file FOUnitTest.class.php.
Referenced by _doRetriveAllTestCases().
00221 { 00222 if (is_dir($path_)) 00223 { 00224 $result = dir($path_); 00225 00226 while($entry = $result->read()) 00227 { 00228 if (is_file($path_.$entry) && $addFiles_) 00229 { 00230 if (strtolower(substr($entry,-4)) == '.php') 00231 { 00232 $files_InOut[] = $path_.$entry; 00233 } 00234 } 00235 elseif(is_dir($path_.'/'.$entry) && $entry != '.' && $entry != '..') 00236 { 00237 $this->_fillWithFilesFromDir($files_InOut, $path_ . $entry . '/', TRUE); 00238 } 00239 } 00240 } 00241 }
FOUnitTest::_initializeSkin | ( | ) | [private] |
Create an object instance for the GUI Skin.
Definition at line 148 of file FOUnitTest.class.php.
Referenced by FOUnitTest().
00149 { 00150 $this->_skin = 'Standard'; 00151 include('Skins/'.$this->_skin.'.class.php'); 00152 $this->_skinObj = & new $this->_skin; 00153 $this->_skinObj->setParent($this); 00154 }
FOUnitTest::_retriveURLArguments | ( | ) | [private] |
Get arguments from the URL, set default values if not used on url.
Definition at line 104 of file FOUnitTest.class.php.
Referenced by FOUnitTest().
00105 { 00106 // Default will be false 00107 if ($_GET['formOnlyReportFailes'] == '1') 00108 { 00109 $this->_bOnlyReportFailes = true; 00110 } 00111 else 00112 { 00113 $this->_bOnlyReportFailes = false; 00114 } 00115 00116 // Default will be true 00117 if ($_GET['formEchoDetails'] == '1' || !array_key_exists('formEchoDetails', $_GET)) 00118 { 00119 $this->_bReportFailDetails = true; 00120 } 00121 else 00122 { 00123 $this->_bReportFailDetails = false; 00124 } 00125 00126 // Default will be false 00127 if ($_GET['formRunAllTests'] == '1') 00128 { 00129 $this->_bRunAllTests = true; 00130 } 00131 else 00132 { 00133 $this->_bRunAllTests = false; 00134 } 00135 00136 // Default will be 0 00137 $this->_currentTestCase = $_GET['formTestCase']; 00138 00139 if (empty($this->_currentTestCase)) 00140 { 00141 $this->_currentTestCase = 0; 00142 } 00143 }
FOUnitTest::_runAllTests | ( | ) | [private] |
Will run all unit tests.
Definition at line 159 of file FOUnitTest.class.php.
References _runTest().
Referenced by writeTestSuiteGui().
00160 { 00161 foreach($this->_testCaseFilesArr as $key => $row) 00162 { 00163 $this->_runTest($key); 00164 } 00165 }
FOUnitTest::_runTest | ( | $ | testCaseNumber_ | ) | [private] |
Will run one test in the $this->_testCaseFilesArr specified by the $testCaseNumber_.
$testCaseNumber_ | - mixed - The number of the unit test in the unitTestFileArr |
Definition at line 174 of file FOUnitTest.class.php.
References _writeGuiResult().
Referenced by _runAllTests(), and writeTestSuiteGui().
00175 { 00176 if ($testCaseNumber_ > 0) 00177 { 00178 include_once($this->_testCaseFilesArr[$testCaseNumber_]['path']); 00179 $obj = &new $this->_testCaseFilesArr[$testCaseNumber_]['class_name']; 00180 $obj->doTest(); 00181 00182 $this->_writeGuiResult($obj->getTestResult()); 00183 unset($obj); 00184 } 00185 }
FOUnitTest::_writeGuiResult | ( | &$ | testResult_ | ) | [private] |
Will write a html result out from a UnitTest result.
Definition at line 262 of file FOUnitTest.class.php.
Referenced by _runTest().
FOUnitTest::FOUnitTest | ( | $ | testCaseRoot_ | ) |
Constructor.
$testCaseRoot_ | - mixed - The root for which all the testcases are located in. This is a file server location. |
Definition at line 30 of file FOUnitTest.class.php.
References _initializeSkin(), and _retriveURLArguments().
00031 { 00032 $this->_retriveURLArguments(); 00033 $this->_initializeSkin(); 00034 00035 $this->_testCaseFilesArr = array(); 00036 $this->_testCaseRoot = $testCaseRoot_; 00037 }
FOUnitTest::getCurrentTestCase | ( | ) |
The test case that should be executed.
If returning 0, no test case to should be executed.
Definition at line 80 of file FOUnitTest.class.php.
FOUnitTest::getNumOfTestCases | ( | ) |
FOUnitTest::getOnlyReportFailes | ( | ) |
FOUnitTest::getReportFailDetails | ( | ) |
If true, the GUI should report more details on failed tests.
Definition at line 70 of file FOUnitTest.class.php.
FOUnitTest::getTestCaseFiles | ( | ) |
FOUnitTest::writeTestSuiteGui | ( | ) |
Write the test suite GUI.
Definition at line 42 of file FOUnitTest.class.php.
References _begin(), _doRetriveAllTestCases(), _end(), _runAllTests(), and _runTest().
00043 { 00044 $this->_doRetriveAllTestCases(); 00045 00046 $this->_begin(); 00047 if ($this->_bRunAllTests) 00048 { 00049 $this->_runAllTests(); 00050 } 00051 else 00052 { 00053 $this->_runTest($this->_currentTestCase); 00054 } 00055 00056 $this->_end(); 00057 }
FOUnitTest::$_bOnlyReportFailes [private] |
FOUnitTest::$_bReportFailDetails [private] |
Will report a detailed result for failed tests.
Definition at line 306 of file FOUnitTest.class.php.
FOUnitTest::$_bRunAllTests [private] |
FOUnitTest::$_currentTestCase [private] |
The number of the current test case choosen with the gui navigator.
Definition at line 296 of file FOUnitTest.class.php.
FOUnitTest::$_numOfTestCases [private] |
FOUnitTest::$_skin [private] |
FOUnitTest::$_skinObj [private] |
FOUnitTest::$_testCaseFilesArr [private] |
FOUnitTest::$_testCaseRoot [private] |