Changeset 2295 for trunk/modules/unit_test/libraries/Unit_Test.php
- Timestamp:
- 03/12/2008 03:19:30 PM (8 months ago)
- Files:
-
- 1 modified
-
trunk/modules/unit_test/libraries/Unit_Test.php (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/modules/unit_test/libraries/Unit_Test.php
r2294 r2295 83 83 throw new Kohana_Exception('unit_test.test_class_extends', $class); 84 84 85 // Initialize setup and teardown method triggers 86 $setup = $teardown = FALSE; 87 88 // Look for valid setup and teardown methods 89 foreach (array('setup', 'teardown') as $method_name) 90 { 91 if ($reflector->hasMethod($method_name)) 92 { 93 $method = new ReflectionMethod($class, $method_name); 94 $$method_name = ($method->isPublic() AND ! $method->isStatic() AND $method->getNumberOfRequiredParameters() === 0); 95 } 96 } 97 85 98 // Initialize test class results and stats 86 99 $this->results[$class] = array(); … … 91 104 { 92 105 // Skip invalid test methods 93 if ( ! $method->isPublic() OR $method->isStatic() OR $method->getNumberOf Parameters() != 0)106 if ( ! $method->isPublic() OR $method->isStatic() OR $method->getNumberOfRequiredParameters() !== 0) 94 107 continue; 95 108 96 109 // Test methods should be suffixed with "_test" 97 if (substr($method_name = $method->getName(), -5) != '_test')110 if (substr($method_name = $method->getName(), -5) !== '_test') 98 111 continue; 99 112 … … 102 115 103 116 // Run setup method 104 if ($ reflector->hasMethod('setup'))117 if ($setup === TRUE) 105 118 { 106 119 $object->setup(); … … 130 143 131 144 // Run teardown method 132 if ($ reflector->hasMethod('teardown'))145 if ($teardown === TRUE) 133 146 { 134 147 $object->teardown();
