Development

Changeset 7733

You must first sign up to be able to contribute.

Changeset 7733

Show
Ignore:
Timestamp:
03/04/08 11:22:41 (6 months ago)
Author:
FabianLange
Message:

added a removeJavascript and removeStylesheet method to sfWebResponse (including unit tests). fixes #1747

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/1.1/lib/response/sfWebResponse.class.php

    r7723 r7733  
    575575 
    576576  /** 
    577    * Adds an stylesheet to the current web response. 
     577   * Adds a stylesheet to the current web response. 
    578578   * 
    579579   * @param string Stylesheet 
     
    589589 
    590590  /** 
     591   * Removes a stylesheet from the current web response. 
     592   * 
     593   * @param string Stylesheet 
     594   * @param string Position 
     595   */ 
     596  public function removeStylesheet($css, $position = '') 
     597  { 
     598    $this->validatePosition($position); 
     599 
     600    unset($this->stylesheets[$position][$css]); 
     601  } 
     602 
     603  /** 
    591604   * Retrieves javascript code from the current web response. 
    592605   * 
     
    619632 
    620633    $this->javascripts[$position][$js] = $options; 
     634  } 
     635 
     636  /** 
     637   * Removes javascript code from the current web response. 
     638   * 
     639   * @param string Javascript code 
     640   * @param string Position 
     641   */ 
     642  public function removeJavascript($js, $position = '') 
     643  { 
     644    $this->validatePosition($position); 
     645 
     646    unset($this->javascripts[$position][$js]); 
    621647  } 
    622648 
  • branches/1.1/test/unit/response/sfWebResponseTest.php

    r7723 r7733  
    1111require_once(dirname(__FILE__).'/../../bootstrap/unit.php'); 
    1212 
    13 $t = new lime_test(68, new lime_output_color()); 
     13$t = new lime_test(70, new lime_output_color()); 
    1414 
    1515class myWebResponse extends sfWebResponse 
     
    208208$t->is($response->getStylesheets('last'), array('last' => array()), '->getStylesheets() takes a position as its first argument'); 
    209209 
     210$t->diag('->removeStylesheet()'); 
     211$response->removeStylesheet('foo'); 
     212$t->is($response->getStylesheets(), array('test' => array(), 'bar' => array('media' => 'print')), '->getStylesheets() does no longer contain removed stylesheets'); 
     213 
    210214// ->addJavascript() 
    211215$t->diag('->addJavascript()'); 
     
    236240$t->is($response->getJavascripts('last'), array('last_js' => array()), '->getJavascripts() takes a position as its first argument'); 
    237241 
     242$t->diag('->removeJavascript()'); 
     243$response->removeJavascript('test'); 
     244$t->is($response->getJavascripts(), array('foo' => array('raw_name' => true)), '->getJavascripts() does no longer contain removed javascripts'); 
     245 
    238246// ->setCookie() ->getCookies() 
    239247$t->diag('->setCookie() ->getCookies()');