FOUnitTest Class Reference
[FOUnitTest]

Will be used to gather a group of foUnitTestBase inherited classes. More...

List of all members.

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.


Detailed Description

Will be used to gather a group of foUnitTestBase inherited classes.

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();

Author:
Daniel Lindh <[email protected]>

Definition at line 20 of file FOUnitTest.class.php.


Member Function Documentation

FOUnitTest::_begin (  )  [private]

Will write a webpage header for the test.

Definition at line 246 of file FOUnitTest.class.php.

Referenced by writeTestSuiteGui().

00247   {
00248     $this->_skinObj->begin();
00249   }

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().

00255   {
00256     $this->_skinObj->end();
00257   }

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_.

Parameters:
$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().

00263   {
00264     $this->_skinObj->writeGuiResult($testResult_);
00265   }

FOUnitTest::FOUnitTest ( testCaseRoot_  ) 

Constructor.

Parameters:
$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.

00081   {
00082     return $this->_currentTestCase;
00083   }

FOUnitTest::getNumOfTestCases (  ) 

Total number of test case classes/files.

Definition at line 88 of file FOUnitTest.class.php.

00089   {
00090     return $this->_numOfTestCases;
00091   }

FOUnitTest::getOnlyReportFailes (  ) 

If true, the GUI should only report failes.

Definition at line 62 of file FOUnitTest.class.php.

00063   {
00064     return $this->_bOnlyReportFailes;
00065   }

FOUnitTest::getReportFailDetails (  ) 

If true, the GUI should report more details on failed tests.

Definition at line 70 of file FOUnitTest.class.php.

00071   {
00072     return $this->_bReportFailDetails;
00073   }

FOUnitTest::getTestCaseFiles (  ) 

Get all test case classes/files.

Definition at line 96 of file FOUnitTest.class.php.

00097   {
00098     return $this->_testCaseFilesArr;
00099   }

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   }


Member Data Documentation

FOUnitTest::$_bOnlyReportFailes [private]

Will only report failed tests.

Definition at line 301 of file FOUnitTest.class.php.

FOUnitTest::$_bReportFailDetails [private]

Will report a detailed result for failed tests.

Definition at line 306 of file FOUnitTest.class.php.

FOUnitTest::$_bRunAllTests [private]

Run all tests.

Definition at line 311 of file FOUnitTest.class.php.

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]

Total number of test case classes/files.

Definition at line 290 of file FOUnitTest.class.php.

FOUnitTest::$_skin [private]

Choosen skin class used by the GUI.

Definition at line 270 of file FOUnitTest.class.php.

FOUnitTest::$_skinObj [private]

Instance of skin object.

Definition at line 275 of file FOUnitTest.class.php.

FOUnitTest::$_testCaseFilesArr [private]

Array with all test case classes.

Definition at line 285 of file FOUnitTest.class.php.

FOUnitTest::$_testCaseRoot [private]

Root in which all testcases are located.

Definition at line 280 of file FOUnitTest.class.php.


The documentation for this class was generated from the following file:

Generated on Wed May 6 23:28:24 2009 for fareofficelib by  doxygen 1.5.8