Index: modules/node/node.test =================================================================== RCS file: /cvs/drupal/drupal/modules/node/node.test,v retrieving revision 1.2 diff -u -p -r1.2 node.test --- modules/node/node.test 25 Apr 2008 18:26:01 -0000 1.2 +++ modules/node/node.test 9 May 2008 18:46:06 -0000 @@ -98,6 +98,57 @@ class NodeRevisionsTestCase extends Drup } } +class PageCacheTestCase extends DrupalWebTestCase { + protected $admin_user; + /** + * Implementation of getInfo(). + */ + function getInfo() { + return array( + 'name' => t('Page Cache'), + 'description' => t('Check caching in situations that used to be problematic.'), + 'group' => t('Node'), + ); + } + + function setUp() { + $this->admin_user = $this->drupalCreateUser(array('create page content', 'edit any page content', 'administer nodes')); + } + + function testPageCache() { + // Enable page caching. + variable_set('cache', CACHE_NORMAL); + // Set minimum cache lifetime to one hour. + variable_set('cache_lifetime', 3600); + + // Create an unpublished page. + $this->drupalLogin($this->admin_user); + $edit = array( + 'type' => 'page', + 'title' => $this->randomName(), + 'status' => 0, + ); + $node = $this->drupalCreateNode($edit); + $this->drupalLogout(); + + // Visit the page as an anonymous user. + $this->drupalGet('node/' . $node->nid); + $this->assertResponse(403, t('Unpublished page is not available.')); + $this->assertTrue(cache_get($this->getUrl(), 'cache_page'), t('Page has been cached')); + + // Publish the page. + $this->drupalLogin($this->admin_user); + $edit = array( + 'status' => 1, + ); + $this->drupalPost("node/$node->nid/edit", $edit, t('Save')); + $this->drupalLogout(); + + // Visit the page again as an anonymous user. + $this->drupalGet('node/' . $node->nid); + $this->assertResponse(200, t('The cache should have been cleared and the page should be available.')); + } +} class NodeTeaserTestCase extends DrupalWebTestCase { /**