Changeset 11917
- Timestamp:
- 10/02/08 18:35:40 (5 years ago)
- Files:
-
- branches/1.2/UPGRADE_TO_1_2 (modified) (1 diff)
- branches/1.2/lib/autoload/sfCoreAutoload.class.php (modified) (1 diff)
- branches/1.2/lib/form/sfForm.class.php (modified) (1 diff)
- branches/1.2/lib/test/sfTestFunctional.class.php (modified) (1 diff)
- branches/1.2/lib/test/sfTestFunctionalBase.class.php (modified) (1 diff)
- branches/1.2/lib/test/sfTester.class.php (modified) (1 diff)
- branches/1.2/lib/test/sfTesterForm.class.php (added)
- branches/1.2/lib/test/sfTesterRequest.class.php (modified) (1 diff)
- branches/1.2/lib/test/sfTesterResponse.class.php (modified) (2 diffs)
- branches/1.2/lib/test/sfTesterUser.class.php (modified) (1 diff)
- branches/1.2/lib/test/sfTesterViewCache.class.php (modified) (1 diff)
- branches/1.2/lib/util/sfBrowser.class.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/1.2/UPGRADE_TO_1_2
r11907 r11917 833 833 with JavaScript. 834 834 835 ### Forms 836 837 If you use the new form framework, you can now test the errors generated 838 by the submitted form: 839 840 [php] 841 $browser-> 842 click('save', array(...))-> 843 with('form')->begin()-> 844 hasErrors()-> 845 isError('name', 'Required.')-> 846 isError('name', '/Required/')-> 847 isError('name', '!/Invalid/')-> 848 isError('name')-> 849 isError('name', 1)-> 850 end() 851 ; 852 853 You can also debug a form with the `debug()` method: 854 855 [php] 856 $browser-> 857 click('save', array(...))-> 858 with('form')->debug()-> 859 // some tests that won't be executed 860 ; 861 862 It will output the submitted values and all the errors if any. 863 835 864 YAML 836 865 ---- branches/1.2/lib/autoload/sfCoreAutoload.class.php
r11898 r11917 375 375 'sfTestFunctionalBase' => 'test', 376 376 'sfTester' => 'test', 377 'sfTesterForm' => 'test', 377 378 'sfTesterRequest' => 'test', 378 379 'sfTesterResponse' => 'test', branches/1.2/lib/form/sfForm.class.php
r11814 r11917 233 233 234 234 /** 235 * Returns the submitted tainted values. 236 * 237 * @return array An array of tainted values 238 */ 239 public function getTaintedValues() 240 { 241 if (!$this->isBound) 242 { 243 return array(); 244 } 245 246 return $this->taintedValues; 247 } 248 249 /** 235 250 * Returns true if the form is valid. 236 251 * branches/1.2/lib/test/sfTestFunctional.class.php
r11898 r11917 28 28 { 29 29 $testers['view_cache'] = 'sfTesterViewCache'; 30 $testers['form'] = 'sfTesterForm'; 30 31 31 32 parent::__construct($browser, $lime, $testers); branches/1.2/lib/test/sfTestFunctionalBase.class.php
r11908 r11917 234 234 $this->test()->comment(sprintf('%s %s', strtolower($method), $uri)); 235 235 236 foreach ($this->testers as $tester) 237 { 238 $tester->prepare(); 239 } 240 236 241 $this->browser->call($uri, $method, $parameters, $changeStack); 237 242 branches/1.2/lib/test/sfTester.class.php
r11898 r11917 35 35 $this->tester = $tester; 36 36 } 37 38 /** 39 * Prepares the tester. 40 */ 41 abstract public function prepare(); 37 42 38 43 /** branches/1.2/lib/test/sfTesterRequest.class.php
r11898 r11917 20 20 { 21 21 protected $request; 22 23 /** 24 * Prepares the tester. 25 */ 26 public function prepare() 27 { 28 } 22 29 23 30 /** branches/1.2/lib/test/sfTesterResponse.class.php
r11907 r11917 25 25 26 26 /** 27 * Prepares the tester. 28 */ 29 public function prepare() 30 { 31 } 32 33 /** 27 34 * Initializes the tester. 28 35 */ … … 189 196 } 190 197 198 /** 199 * Outputs some debug information about the current response. 200 */ 191 201 public function debug() 192 202 { 203 print $this->tester->error('Response debug'); 204 193 205 printf("HTTP/1.X %s\n", $this->response->getStatusCode()); 194 206 branches/1.2/lib/test/sfTesterUser.class.php
r11898 r11917 20 20 { 21 21 protected $user; 22 23 /** 24 * Prepares the tester. 25 */ 26 public function prepare() 27 { 28 } 22 29 23 30 /** branches/1.2/lib/test/sfTesterViewCache.class.php
r11898 r11917 23 23 $response = null, 24 24 $routing = null; 25 26 /** 27 * Prepares the tester. 28 */ 29 public function prepare() 30 { 31 } 25 32 26 33 /** branches/1.2/lib/util/sfBrowser.class.php
r11467 r11917 20 20 { 21 21 protected 22 $context = null; 22 $listeners = array(), 23 $context = null; 23 24 24 25 /** … … 68 69 $currentConfiguration = $this->context->getConfiguration(); 69 70 $configuration = ProjectConfiguration::getApplicationConfiguration($currentConfiguration->getApplication(), $currentConfiguration->getEnvironment(), $currentConfiguration->isDebug()); 70 $configuration->getEventDispatcher()->connect('application.throw_exception', array($this, 'ListenToException'));71 71 $this->context = sfContext::createInstance($configuration); 72 72 unset($currentConfiguration); … … 76 76 $this->context = sfContext::getInstance(); 77 77 $this->context->initialize($this->context->getConfiguration()); 78 $this->context->getEventDispatcher()->connect('application.throw_exception', array($this, 'ListenToException')); 78 } 79 80 $this->context->getEventDispatcher()->connect('application.throw_exception', array($this, 'ListenToException')); 81 foreach ($this->listeners as $name => $listener) 82 { 83 $this->context->getEventDispatcher()->connect($name, $listener); 79 84 } 80 85 } 81 86 82 87 return $this->context; 88 } 89 90 public function addListener($name, $listener) 91 { 92 $this->listeners[$name] = $listener; 83 93 } 84 94