예제 #1
0
파일: Runner.php 프로젝트: tpc2/phprack
 /**
  * Get full list of tests, in array
  *
  * This method builds a list of phpRack_Test class instances, collecting
  * them from integration 1) tests and 2) suites. They both are located in
  * the same directory (pre-configured in $phpRackConfig), but differ only
  * in file name suffix. Integration test ends with "...Test.php" and integration
  * suite ends with "...Suite.php".
  *
  * Suite is an integration of tests, that allows you to use library tests
  * and suites. The majority of testing tasks are similar from server to server.
  * If you want to avoid manual development of tests for every application, just
  * use our library suites, and taylor them for your application needs.
  *
  * @return phpRack_Test[]
  * @see index.phtml
  */
 public function getTests()
 {
     $tests = array();
     $dir = $this->getDir();
     foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator($dir)) as $file) {
         $label = substr($file->getRealPath(), strlen($dir) + 1);
         switch (true) {
             case preg_match(self::TEST_PATTERN, $label):
                 $tests[] = phpRack_Test::factory($label, $this);
                 break;
             case preg_match(self::SUITE_PATTERN, $label):
                 $suite = phpRack_Suite::factory($label, $this);
                 foreach ($suite->getTests() as $test) {
                     $tests[] = $test;
                 }
                 break;
             default:
                 // just ignore the file and move on
                 continue;
         }
     }
     return $tests;
 }
예제 #2
0
 /**
  * Get full list of tests, in array
  *
  * This method builds a list of phpRack_Test class instances, collecting
  * them from integration 1) tests and 2) suites. They both are located in 
  * the same directory (pre-configured in $phpRackConfig), but differ only
  * in file name suffix. Integration test ends with "...Test.php" and integration
  * suite ends with "...Suite.php".
  *
  * Suite is an integration of tests, that allows you to use library tests
  * and suites. The majority of testing tasks are similar from server to server.
  * If you want to avoid manual development of tests for every application, just
  * use our library suites, and taylor them for your application needs.
  *
  * @return phpRack_Test[]
  * @see index.phtml
  */
 public function getTests()
 {
     $tests = array();
     foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator($this->getDir())) as $file) {
         switch (true) {
             case preg_match(self::TEST_PATTERN, $file->getFilename()):
                 $tests[] = phpRack_Test::factory(strval($file), $this);
                 break;
             case preg_match(self::SUITE_PATTERN, $file->getFilename()):
                 $suite = phpRack_Suite::factory(strval($file), $this);
                 foreach ($suite->getTests() as $test) {
                     $tests[] = $test;
                 }
                 break;
         }
     }
     return $tests;
 }