Changeset 2972

Show
Ignore:
Timestamp:
10/02/08 14:49:09 (7 weeks ago)
Author:
felix
Message:

basic implementation for flowtests.
- setup code
- dispatch
- hack to disable routing (must be removed at some point)

Location:
branches/felix-testing-implementation
Files:
1 added
4 modified

Legend:

Unmodified
Added
Removed
  • branches/felix-testing-implementation/samples/test/config/suites.xml

    r2961 r2972  
    99          <testfile>fragment/SearchEngineSpamSuccessViewTest.php</testfile> 
    1010          <testfile>fragment/LoginSuccessViewTest.php</testfile> 
     11          <testfile>flow/LoginFlowTest.php</testfile> 
    1112        </testfiles> 
    1213      </suite> 
  • branches/felix-testing-implementation/src/routing/AgaviRouting.class.php

    r2550 r2972  
    9494    )); 
    9595  } 
    96  
     96   
     97  public function disable() 
     98  { 
     99    $this->enabled = false; 
     100  } 
     101   
    97102  /** 
    98103   * Initialize the routing instance. 
  • branches/felix-testing-implementation/src/testing/AgaviFlowTestCase.class.php

    r2869 r2972  
    3131abstract class AgaviFlowTestCase extends PHPUnit_Framework_TestCase implements AgaviIFlowTestCase 
    3232{ 
     33  protected $arguments; 
     34   
     35  protected $acionName; 
     36   
     37  protected $moduleName; 
     38   
     39  protected $response; 
     40   
     41  protected $method; 
     42   
    3343  /** 
    3444   * Constructs a test case with the given name. 
     
    4353    $this->setRunTestInSeparateProcess(true); 
    4454  } 
     55   
     56  public function dispatch() 
     57  { 
     58    $context = AgaviContext::getInstance(); 
     59     
     60    $ro = $context->getRouting(); 
     61    $ro->disable(); 
     62     
     63    $rq = $context->getRequest(); 
     64    $rq->setMethod($this->method); 
     65    $ma = $rq->getParameter('module_accessor'); 
     66    $aa = $rq->getParameter('action_accessor'); 
     67     
     68    $this->arguments->setParameter($ma, $this->moduleName); 
     69    $this->arguments->setParameter($aa, $this->actionName); 
     70   
     71    $ctrl = $context->getController(); 
     72    $ctrl->setParameter('send_response', false); 
     73    $this->response = $ctrl->dispatch(); 
     74  } 
     75   
     76  public function setRequestMethod($method) 
     77  { 
     78    $this->method = $method; 
     79  } 
     80   
     81  public function assertValidationFailed($message = '') 
     82  { 
     83     
     84  } 
     85   
     86  public function assertResponseHasTag($matcher, $message = '', $isHtml = true) 
     87  { 
     88    $this->assertTag($matcher, $this->response->getContent(), $message, $isHtml); 
     89  } 
     90   
     91  public function assertResponseHasNotTag($matcher, $message = '', $isHtml = true) 
     92  { 
     93    $this->assertNotTag($matcher, $this->response->getContent(), $message, $isHtml); 
     94  } 
    4595 
     96  protected function setArguments(AgaviRequestDataHolder $arguments) 
     97  { 
     98    $this->arguments = $arguments; 
     99  } 
     100 
     101  /** 
     102   * create a requestDataHolder with the given arguments and type 
     103   *  
     104   * arguments need to be passed in the way {@see AgaviRequestDataHolder} accepts them 
     105   *  
     106   * array(AgaviRequestDataHolder::SOURCE_PARAMETERS => array('foo' => 'bar')) 
     107   *  
     108   * if no type is passed, the default for the configured request class will be used 
     109   *  
     110   * @param      array   a two-dimensional array with the arguments 
     111   * @param      string  the subclass of AgaviRequestDataHolder to create 
     112   *  
     113   * @return     AgaviRequestDataHolder 
     114   *  
     115   * @author     Felix Gilcher <felix.gilcher@bitextender.com> 
     116   * @since      1.0.0 
     117   */ 
     118  protected function createRequestDataHolder(array $arguments = array(), $type = null) 
     119  { 
     120    if(null === $type) { 
     121      $type = AgaviContext::getInstance()->getRequest()->getParameter('request_data_holder_class', 'AgaviRequestDataHolder'); 
     122    } 
     123     
     124    $class = new $type($arguments); 
     125    return $class; 
     126  } 
    46127} 
    47128 
  • branches/felix-testing-implementation/src/testing/AgaviIFlowTestCase.interface.php

    r2869 r2972  
    3030interface AgaviIFlowTestCase extends AgaviITestCase 
    3131{ 
    32   public function dispatch(AgaviITestCall $call); 
     32  public function dispatch(); 
    3333   
    34   public function assertValidationFailed(); 
     34  public function assertValidationFailed($message = ''); 
    3535} 
    3636