Development

Changeset 3098

You must first sign up to be able to contribute.

Changeset 3098

Show
Ignore:
Timestamp:
12/19/06 23:09:30 (2 years ago)
Author:
fabien
Message:

fixed cache decoration in dev environment for non HTML contents (closes #1246)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/lib/filter/sfCacheFilter.class.php

    r2971 r3098  
    247247    if ($retval && sfConfig::get('sf_web_debug')) 
    248248    { 
    249       $tmp = unserialize($retval); 
    250       $tmp['content'] = sfWebDebug::getInstance()->decorateContentWithDebug($uri, $tmp['content'], false); 
    251       $retval = serialize($tmp); 
     249      $cache = unserialize($retval); 
     250      $this->response->mergeProperties($cache['response']); 
     251      $cache['content'] = sfWebDebug::getInstance()->decorateContentWithDebug($uri, $cache['content'], false); 
     252      $retval = serialize($cache); 
    252253    } 
    253254 
  • trunk/test/functional/cacheTest.php

    r2935 r3098  
    1717class myTestBrowser extends sfTestBrowser 
    1818{ 
     19  function checkResponseContent($content, $message) 
     20  { 
     21    $this->test()->ok($this->getResponse()->getContent() == $content, $message); 
     22 
     23    return $this; 
     24  } 
     25 
    1926  function getMultiAction($parameter = null) 
    2027  { 
     
    263270} 
    264271 
    265 // test with sfFileCache class (default) 
    266272$b = new myTestBrowser(); 
    267273$b->initialize(); 
     274 
     275// non HTML cache 
     276$image = file_get_contents($sf_symfony_data_dir.'/web/sf/sf_default/images/icons/ok48.png'); 
     277sfConfig::set('sf_web_debug', true); 
     278$b-> 
     279  get('/cache/imageWithLayoutCacheWithLayout')-> 
     280  isCached(true, true)-> 
     281  checkResponseContent($image, 'image (with layout/page cache) in cache is not decorated when web_debug is on')-> 
     282  get('/cache/imageWithLayoutCacheWithLayout')-> 
     283  isCached(true, true)-> 
     284  checkResponseContent($image, 'image (with layout/page cache) in cache is not decorated when web_debug is on')-> 
     285  get('/cache/imageWithLayoutCacheNoLayout')-> 
     286  isCached(true)-> 
     287  checkResponseContent($image, 'image (with layout/action cache) in cache is not decorated when web_debug is on')-> 
     288  get('/cache/imageWithLayoutCacheNoLayout')-> 
     289  isCached(true)-> 
     290  checkResponseContent($image, 'image (with layout/action cache) in cache is not decorated when web_debug is on')-> 
     291  get('/cache/imageNoLayoutCacheWithLayout')-> 
     292  isCached(true, true)-> 
     293  checkResponseContent($image, 'image (no layout/page cache) in cache is not decorated when web_debug is on')-> 
     294  get('/cache/imageNoLayoutCacheWithLayout')-> 
     295  isCached(true, true)-> 
     296  checkResponseContent($image, 'image (no layout/page cache) in cache is not decorated when web_debug is on')-> 
     297  get('/cache/imageNoLayoutCacheNoLayout')-> 
     298  isCached(true)-> 
     299  checkResponseContent($image, 'image (no layout/action cache) in cache is not decorated when web_debug is on')-> 
     300  get('/cache/imageNoLayoutCacheNoLayout')-> 
     301  isCached(true)-> 
     302  checkResponseContent($image, 'image (no layout/action cache) in cache is not decorated when web_debug is on') 
     303; 
     304sfConfig::set('sf_web_debug', false); 
     305 
     306// test with sfFileCache class (default) 
    268307$b->launch(); 
    269308 
  • trunk/test/functional/fixtures/project/apps/cache/modules/cache/actions/actions.class.php

    r2558 r3098  
    4747    sfConfig::set('ACTION_EXECUTED', true); 
    4848  } 
     49 
     50  public function executeImageWithLayoutCacheWithLayout() 
     51  { 
     52    $this->prepareImage(); 
     53    $this->setLayout('image'); 
     54  } 
     55 
     56  public function executeImageWithLayoutCacheNoLayout() 
     57  { 
     58    $this->prepareImage(); 
     59    $this->setLayout('image'); 
     60  } 
     61 
     62  public function executeImageNoLayoutCacheWithLayout() 
     63  { 
     64    $this->prepareImage(); 
     65    $this->setLayout(false); 
     66  } 
     67 
     68  public function executeImageNoLayoutCacheNoLayout() 
     69  { 
     70    $this->prepareImage(); 
     71    $this->setLayout(false); 
     72  } 
     73 
     74  protected function prepareImage() 
     75  { 
     76    $this->getResponse()->setContentType('image/png'); 
     77    $this->image = file_get_contents(sfConfig::get('sf_symfony_data_dir').'/web/sf/sf_default/images/icons/ok48.png'); 
     78    $this->setTemplate('image'); 
     79  } 
    4980} 
  • trunk/test/functional/fixtures/project/apps/cache/modules/cache/config/cache.yml

    r2794 r3098  
    4242page: 
    4343  with_layout: true 
     44 
     45imageWithLayoutCacheWithLayout: 
     46  with_layout: true 
     47 
     48imageWithLayoutCacheNoLayout: 
     49  with_layout: false 
     50 
     51imageNoLayoutCacheWithLayout: 
     52  with_layout: true 
     53 
     54imageNoLayoutCacheNoLayout: 
     55  with_layout: false