$contentType1 = $response->getContentType(); $headers1 = $response->getHttpHeaders(); $b->get('/cache/action')->isStatusCode(200)->isRequestParameter('module', 'cache')->isRequestParameter('action', 'action')->isCached(true); $b->test()->is(sfConfig::get('ACTION_EXECUTED', false), false, 'action is not executed when in cache'); $response = $b->getResponse(); $content2 = $response->getContent(); $contentType2 = $response->getContentType(); $headers2 = $response->getHttpHeaders(); $b->test()->is($content1, $content2, 'response content is the same'); $b->test()->is($contentType1, $contentType2, 'response content type is the same'); $b->test()->is($headers1, $headers2, 'response http headers are the same'); } } $b = new myTestBrowser(); // non HTML cache $image = file_get_contents(dirname(__FILE__) . '/fixtures/apps/cache/modules/cache/data/ok48.png'); sfConfig::set('sf_web_debug', true); $b->get('/cache/imageWithLayoutCacheWithLayout')->isCached(true, true)->checkResponseContent($image, 'image (with layout/page cache) in cache is not decorated when web_debug is on')->get('/cache/imageWithLayoutCacheWithLayout')->isCached(true, true)->checkResponseContent($image, 'image (with layout/page cache) in cache is not decorated when web_debug is on')->get('/cache/imageWithLayoutCacheNoLayout')->isCached(true)->checkResponseContent($image, 'image (with layout/action cache) in cache is not decorated when web_debug is on')->get('/cache/imageWithLayoutCacheNoLayout')->isCached(true)->checkResponseContent($image, 'image (with layout/action cache) in cache is not decorated when web_debug is on')->get('/cache/imageNoLayoutCacheWithLayout')->isCached(true, true)->checkResponseContent($image, 'image (no layout/page cache) in cache is not decorated when web_debug is on')->get('/cache/imageNoLayoutCacheWithLayout')->isCached(true, true)->checkResponseContent($image, 'image (no layout/page cache) in cache is not decorated when web_debug is on')->get('/cache/imageNoLayoutCacheNoLayout')->isCached(true)->checkResponseContent($image, 'image (no layout/action cache) in cache is not decorated when web_debug is on')->get('/cache/imageNoLayoutCacheNoLayout')->isCached(true)->checkResponseContent($image, 'image (no layout/action cache) in cache is not decorated when web_debug is on'); sfConfig::set('sf_web_debug', false); // check stylesheets, javascripts inclusions sfToolkit::clearDirectory(sfConfig::get('sf_app_cache_dir')); $b->get('/cache/multiBis')->isStatusCode(200)->isRequestParameter('module', 'cache')->isRequestParameter('action', 'multiBis')->checkResponseElement('link[href*="/main_css"]')->checkResponseElement('script[src*="/main_js"]')->checkResponseElement('link[href*="/partial_css"]')->checkResponseElement('script[src*="/partial_js"]')->checkResponseElement('link[href*="/another_partial_css"]')->checkResponseElement('script[src*="/another_partial_js"]')->checkResponseElement('link[href*="/component_css"]')->checkResponseElement('script[src*="/component_js"]')->checkResponseElement('#partial_slot_content', 'Partial')->checkResponseElement('#another_partial_slot_content', 'Another Partial')->checkResponseElement('#component_slot_content', 'Component')->get('/cache/multiBis')->checkResponseElement('link[href*="/main_css"]')->checkResponseElement('script[src*="/main_js"]')->checkResponseElement('link[href*="/partial_css"]')->checkResponseElement('script[src*="/partial_js"]')->checkResponseElement('link[href*="/another_partial_css"]')->checkResponseElement('script[src*="/another_partial_js"]')->checkResponseElement('link[href*="/component_css"]')->checkResponseElement('script[src*="/component_js"]')->checkResponseElement('#partial_slot_content', 'Partial')->checkResponseElement('#another_partial_slot_content', 'Another Partial')->checkResponseElement('#component_slot_content', 'Component'); $b->get('/cache/partial')->isStatusCode(200)->isRequestParameter('module', 'cache')->isRequestParameter('action', 'partial')->checkResponseElement('link[href*="/main_css"]', false)->checkResponseElement('script[src*="/main_js"]', false)->checkResponseElement('link[href*="/partial_css"]')->checkResponseElement('script[src*="/partial_js"]')->checkResponseElement('link[href*="/another_partial_css"]')->checkResponseElement('script[src*="/another_partial_js"]')->checkResponseElement('link[href*="/component_css"]', false)->checkResponseElement('script[src*="/component_js"]', false)->checkResponseElement('#partial_slot_content', 'Partial')->checkResponseElement('#another_partial_slot_content', 'Another Partial')->checkResponseElement('#component_slot_content', '')->get('/cache/anotherPartial')->isStatusCode(200)->isRequestParameter('module', 'cache')->isRequestParameter('action', 'anotherPartial')->checkResponseElement('link[href*="/main_css"]', false)->checkResponseElement('script[src*="/main_js"]', false)->checkResponseElement('link[href*="/partial_css"]', false)->checkResponseElement('script[src*="/partial_js"]', false)->checkResponseElement('link[href*="/another_partial_css"]')->checkResponseElement('script[src*="/another_partial_js"]')->checkResponseElement('link[href*="/component_css"]', false)->checkResponseElement('script[src*="/component_js"]', false)->checkResponseElement('#partial_slot_content', '')->checkResponseElement('#another_partial_slot_content', 'Another Partial')->checkResponseElement('#component_slot_content', '')->get('/cache/component')->isStatusCode(200)->isRequestParameter('module', 'cache')->isRequestParameter('action', 'component')->checkResponseElement('link[href*="/main_css"]', false)->checkResponseElement('script[src*="/main_js"]', false)->checkResponseElement('link[href*="/partial_css"]', false)->checkResponseElement('script[src*="/partial_js"]', false)->checkResponseElement('link[href*="/another_partial_css"]', false)->checkResponseElement('script[src*="/another_partial_js"]', false)->checkResponseElement('link[href*="/component_css"]')->checkResponseElement('script[src*="/component_js"]')->checkResponseElement('#partial_slot_content', '')->checkResponseElement('#another_partial_slot_content', '')->checkResponseElement('#component_slot_content', 'Component'); // test with sfFileCache class (default) $b->launch(); // test with sfSQLiteCache class if (extension_loaded('SQLite')) { sfConfig::set('sf_factory_view_cache', 'sfSQLiteCache'); sfConfig::set('sf_factory_view_cache_parameters', array('database' => sfConfig::get('sf_template_cache_dir') . DIRECTORY_SEPARATOR . 'cache.db')); $b->launch(); }