diff --git a/tests/workbench_moderation.test b/tests/workbench_moderation.test index 42d1665..f749f71 100644 --- a/tests/workbench_moderation.test +++ b/tests/workbench_moderation.test @@ -249,7 +249,6 @@ class WorkbenchModerationUnpublishTestCase extends WorkbenchModerationTestCase { function setUp($modules = array()) { parent::setUp($modules); - $this->drupalLogin($this->admin_user); } function testUnpublish() { @@ -262,16 +261,42 @@ class WorkbenchModerationUnpublishTestCase extends WorkbenchModerationTestCase { "{$body_name}[format]" => filter_default_format(), 'workbench_moderation_state_new' => workbench_moderation_state_published(), ); + $this->drupalLogin($this->admin_user); $this->drupalPost("node/add/{$this->content_type}", $edit, t('Save')); $node = $this->drupalGetNodeByTitle($edit['title']); + // Get the specific page as an anonymous visitor. + $this->drupalLogout(); + $this->drupalGet("node/{$node->nid}"); + // Assert that the node is published. + $this->assertResponse(200); + + // Log back in. + $this->drupalLogin($this->admin_user); + // Unpublish the node via the unpublish confirmation form. $this->drupalPost("node/{$node->nid}/moderation/{$node->vid}/unpublish", array(), t('Unpublish')); $unpublished_node = node_load($node->nid, FALSE, TRUE); $this->assertFalse($unpublished_node->status, t('The node is not published.')); $this->assertFalse(isset($unpublished_node->workbench_moderation['published']), t('Workbench moderation has no published revision.')); + + // Get the specific page as an anonymous visitor. + $this->drupalLogout(); + $this->drupalGet("node/{$node->nid}"); + // Assert that the node is unpublished. + $this->assertResponse(403); } + + function testUnpublishWithAnonymousPageCache() { + // Cache pages for anonymous users. + variable_set('cache', 1); + // Instruct Workbench Moderation to clear caches itself, instead of relying + // on another module. + variable_set('workbench_moderation_cache_clear_all', 1); + + $this->testUnpublish(); + } } /** diff --git a/workbench_moderation.install b/workbench_moderation.install index 8d68ed3..b623dba 100644 --- a/workbench_moderation.install +++ b/workbench_moderation.install @@ -23,6 +23,7 @@ function workbench_moderation_install() { function workbench_moderation_uninstall() { // Delete workbench_moderation variables. + variable_del('workbench_moderation_cache_clear_all'); variable_del('workbench_moderation_nodedraft_disabled'); variable_del('workbench_moderation_per_node_type'); variable_del('workbench_moderation_show_revision_navigation'); diff --git a/workbench_moderation.module b/workbench_moderation.module index 5a2ff16..f7f9e79 100644 --- a/workbench_moderation.module +++ b/workbench_moderation.module @@ -1772,6 +1772,15 @@ function workbench_moderation_store($node) { // Save the node. node_save($live_revision); + + // Clear caches just like it would have been done if the the node was edited + // through the node edit form. + // @see node_form_submit() + // Unless workbench_moderation_cache_clear_all evaluates to false. + if (variable_get('workbench_moderation_cache_clear_all', 0)) { + // Clear the page and block caches. + cache_clear_all(); + } } /**