Development

Changeset 8460

You must first sign up to be able to contribute.

Changeset 8460

Show
Ignore:
Timestamp:
04/15/08 01:17:55 (5 months ago)
Author:
fabien
Message:

cleanup format functional tests to have a better example on how to customize them

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/1.1/test/functional/fixtures/project/apps/frontend/config/frontendConfiguration.class.php

    r7962 r8460  
    55  public function configure() 
    66  { 
     7    $this->dispatcher->connect('view.configure_format', 'configure_format_foo'); 
     8    $this->dispatcher->connect('request.filter_parameters', 'filter_parameters'); 
     9    $this->dispatcher->connect('view.configure_format', 'configure_iphone_format'); 
    710  } 
    811} 
  • branches/1.1/test/functional/fixtures/project/apps/frontend/modules/format/actions/actions.class.php

    r8227 r8460  
    1111class formatActions extends sfActions 
    1212{ 
    13   static protected $registered = false; 
    14  
    1513  public function executeIndex($request) 
    1614  { 
    17     if (!self::$registered) 
    18     { 
    19       // in real code, register view.configure_format events in ProjectConfiguration or XXXApplicationConfiguration, not here! 
    20       self::$registered = true; 
    21       $this->getContext()->getEventDispatcher()->connect('view.configure_format', array($this, 'configureFormat')); 
    22     } 
    23  
    2415    if ('xml' == $request->getRequestFormat()) 
    2516    { 
     
    4233    $this->setTemplate('index'); 
    4334  } 
    44  
    45   public function configureFormat(sfEvent $event) 
    46   { 
    47     if ('foo' != $event['format']) 
    48     { 
    49       return; 
    50     } 
    51  
    52     $event['response']->setHttpHeader('x-foo', 'true'); 
    53     $event->getSubject()->setExtension('.php'); 
    54   } 
    5535} 
  • branches/1.1/test/functional/formatTest.php

    r8227 r8460  
    8484$b->test()->is($b->getResponse()->getContent(), 'A js file', 'response content is ok'); 
    8585 
    86 $b->getContext()->getEventDispatcher()->connect('request.filter_parameters', 'filter_parameters'); 
    87 $b->getContext()->getEventDispatcher()->connect('view.configure_format', 'configure_iphone_format'); 
    8886$b-> 
    8987  setHttpHeader('User-Agent', 'Mozilla/5.0 (iPhone; U; CPU like Mac OS X; en) AppleWebKit/420+ (KHTML, like Gecko) Version/3.0 Mobile/1A543a Safari/419.3')-> 
     
    116114  } 
    117115} 
     116 
     117function configure_format_foo(sfEvent $event) 
     118{ 
     119  if ('foo' != $event['format']) 
     120  { 
     121    return; 
     122  } 
     123 
     124  $event['response']->setHttpHeader('x-foo', 'true'); 
     125  $event->getSubject()->setExtension('.php'); 
     126}