Show
Ignore:
Timestamp:
09/30/08 08:36:34 (3 months ago)
Author:
felix
Message:

added 'assertResponseHasCookie'

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • branches/felix-testing-implementation/src/testing/AgaviViewTestCase.class.php

    r2959 r2963  
    206206      $this->fail(sprintf($message . ' (response is not an AgaviWebResponse)', $expected)); 
    207207    } 
    208     $this->assertEquals($expected, $response->getHeader($expected), sprintf($message, $expected, $expectedValue)); 
     208    $this->assertEquals($expectedValue, $response->getHeader($expected), sprintf($message, $expected, $expectedValue)); 
     209  } 
     210   
     211  /** 
     212   * assert that the response has the given cookie and value 
     213   *  
     214   * this response only works on AgaviWebResponse and subclasses 
     215   *  
     216   * @param      string the name of the expected cookie 
     217   * @param      string the value of the expected header 
     218   * @param      string the message to emit on failure 
     219   * 
     220   * @author     Felix Gilcher <felix.gilcher@bitextender.com> 
     221   * @since      1.0.0 
     222   */ 
     223  protected function assertResponseHasCookie($expected, $expectedValue = null, $message = 'Failed asserting that the response has a cookie named <%1$s>') 
     224  { 
     225    $response = $this->container->getResponse(); 
     226     
     227    if(!($response instanceof AgaviWebResponse)) { 
     228      $this->fail(sprintf($message . ' (response is not an AgaviWebResponse)', $expected)); 
     229    } 
     230    $this->assertEquals($expectedValue, $response->getCookie($expected), sprintf($message, $expected)); 
    209231  } 
    210232