Changeset 2273
- Timestamp:
- 03/10/2008 11:03:30 AM (9 months ago)
- Location:
- trunk/modules/unit_test
- Files:
-
- 2 modified
-
i18n/en_US/unit_test.php (modified) (1 diff)
-
libraries/Unit_Test.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/modules/unit_test/i18n/en_US/unit_test.php
r2267 r2273 3 3 $lang = array 4 4 ( 5 'invalid_test_path' => 'Failed to open test path: %s.', 6 'duplicate_test_class' => 'Duplicate test class named %s found in %s.', 7 'test_class_not_found' => 'No test class by the name of %s found in %s.', 8 'test_class_extends' => '%s must extend Unit_Test_Case.', 5 9 'passed' => 'Passed', 6 10 'failed' => 'Failed', -
trunk/modules/unit_test/libraries/Unit_Test.php
r2272 r2273 23 23 public function __construct() 24 24 { 25 // Normalize all given test paths25 // Loop over each given test path 26 26 foreach (func_get_args() as $path) 27 27 { 28 $this->paths[] = str_replace('\\', '/', realpath($path)); 29 } 30 31 // Recursively iterate over all test paths 32 foreach ($this->paths as $test_path) 33 { 28 // Normalize all given test paths and store them 29 $this->paths[] = $test_path = str_replace('\\', '/', realpath((string) $path)); 30 31 // Validate test path 32 if ( ! is_dir($test_path)) 33 throw new Kohana_Exception('unit_test.invalid_test_path', $test_path); 34 35 // Recursively iterate over each file in the test path 34 36 foreach 35 37 ( … … 48 50 $class = substr($path, strrpos($path, '/') + 1, -(strlen(EXT))); 49 51 52 // Check for duplicate test class name 53 if (class_exists($class, FALSE)) 54 throw new Kohana_Exception('unit_test.duplicate_test_class', $class, $path); 55 50 56 // Include the test class 51 57 include_once $path; 52 58 53 // Validate the class name59 // Check whether the test class has been found and loaded 54 60 if ( ! class_exists($class, FALSE)) 55 continue;61 throw new Kohana_Exception('unit_test.test_class_not_found', $class, $path); 56 62 57 63 // Reverse-engineer Test class … … 60 66 // Test classes must extend Unit_Test_Case 61 67 if ( ! $reflector->isSubclassOf(new ReflectionClass('Unit_Test_Case'))) 62 break;68 throw new Kohana_Exception('unit_test.test_class_extends', $class); 63 69 64 70 // Loop through all the class methods
