Changeset 2980
- Timestamp:
- 12/08/06 21:02:11 (2 years ago)
- Files:
-
- trunk/lib/controller/sfFrontWebController.class.php (modified) (1 diff)
- trunk/lib/test/sfTestBrowser.class.php (modified) (1 diff)
- trunk/lib/util/sfBrowser.class.php (modified) (3 diffs)
- trunk/test/functional/backend/browseTest.php (modified) (1 diff)
- trunk/test/functional/crudTest.php (modified) (1 diff)
- trunk/test/functional/fixtures/project/apps/frontend/modules/exception (added)
- trunk/test/functional/fixtures/project/apps/frontend/modules/exception/actions (added)
- trunk/test/functional/fixtures/project/apps/frontend/modules/exception/actions/actions.class.php (added)
- trunk/test/functional/sfTestBrowserTest.php (added)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/lib/controller/sfFrontWebController.class.php
r2971 r2980 50 50 catch (sfException $e) 51 51 { 52 if (sfConfig::get('sf_test')) 53 { 54 throw $e; 55 } 56 52 57 $e->printStackTrace(); 53 58 } 54 59 catch (Exception $e) 55 60 { 61 if (sfConfig::get('sf_test')) 62 { 63 throw $e; 64 } 65 56 66 // wrap non symfony exceptions 57 67 $sfException = new sfException(); trunk/lib/test/sfTestBrowser.class.php
r2794 r2980 179 179 } 180 180 181 public function throwsException($class = null, $message = null) 182 { 183 $e = $this->getCurrentException(); 184 185 if (null === $e) 186 { 187 $this->test->fail('response returns an exception'); 188 } 189 else 190 { 191 if (null !== $class) 192 { 193 $this->test->ok($e instanceof $class, sprintf('response returns an exception of class "%s"', $class)); 194 } 195 196 if (null !== $message && preg_match('/^(!)?([^a-zA-Z0-9\\\\]).+?\\2[ims]?$/', $message, $match)) 197 { 198 if ($match[1] == '!') 199 { 200 $this->test->unlike($e->getMessage(), substr($message, 1), sprintf('response exception message does not match regex "%s"', $message)); 201 } 202 else 203 { 204 $this->test->like($e->getMessage(), $message, sprintf('response exception message matches regex "%s"', $message)); 205 } 206 } 207 else if (null !== $message) 208 { 209 $this->test->is($e->getMessage(), $message, sprintf('response exception message matches regex "%s"', $message)); 210 } 211 } 212 213 return $this; 214 } 215 181 216 public function isCached($boolean, $with_layout = false) 182 217 { trunk/lib/util/sfBrowser.class.php
r2971 r2980 20 20 { 21 21 protected 22 $context = null, 23 $hostname = null, 24 $remote = null, 25 $dom = null, 26 $stack = array(), 27 $stackPosition = -1, 28 $cookieJar = array(), 29 $fields = array(); 22 $context = null, 23 $hostname = null, 24 $remote = null, 25 $dom = null, 26 $stack = array(), 27 $stackPosition = -1, 28 $cookieJar = array(), 29 $fields = array(), 30 $currentException = null; 30 31 31 32 public function initialize($hostname = null, $remote = null, $options = array()) … … 129 130 sfConfig::set('sf_rendering_filter', array('sfFakeRenderingFilter', null)); 130 131 132 $this->currentException = null; 133 131 134 // dispatch our request 132 135 ob_start(); 133 $controller->dispatch(); 136 try 137 { 138 $controller->dispatch(); 139 } 140 catch (sfException $e) 141 { 142 $this->currentException = $e; 143 144 $e->printStackTrace(); 145 } 146 catch (Exception $e) 147 { 148 $this->currentException = $e; 149 150 $sfException = new sfException(); 151 $sfException->printStackTrace($e); 152 } 134 153 $retval = ob_get_clean(); 154 155 if ($this->currentException instanceof sfStopException) 156 { 157 $this->currentException = null; 158 } 135 159 136 160 // append retval to the response content … … 216 240 { 217 241 return $this->context->getRequest(); 242 } 243 244 public function getCurrentException() 245 { 246 return $this->currentException; 218 247 } 219 248 trunk/test/functional/backend/browseTest.php
r2935 r2980 25 25 isRequestParameter('module', 'error')-> 26 26 isRequestParameter('action', 'index')-> 27 responseContains('sfInitializationException')-> 28 responseContains('Unable to scaffold unexistant model') 27 throwsException('sfInitializationException', '/Unable to scaffold unexistant model/') 29 28 ; 30 29 trunk/test/functional/crudTest.php
r2935 r2980 24 24 isRequestParameter('module', 'error')-> 25 25 isRequestParameter('action', 'index')-> 26 responseContains('sfInitializationException')-> 27 responseContains('Unable to scaffold unexistant model') 26 throwsException('sfInitializationException', '/Unable to scaffold unexistant model/') 28 27 ; 29 28