diff --git a/tests/workbench_moderation.test b/tests/workbench_moderation.test index 199da46..c7142d2 100644 --- a/tests/workbench_moderation.test +++ b/tests/workbench_moderation.test @@ -10,7 +10,7 @@ class WorkbenchModerationTestCase extends DrupalWebTestCase { protected $moderator_user; function setUp($modules = array()) { - $modules = array_merge($modules, array('drafty', 'workbench_moderation')); + $modules = array_merge($modules, array('drafty', 'workbench_moderation', 'workbench_moderation_test')); parent::setUp($modules); // Create a new content type and enable moderation on it. @@ -152,7 +152,7 @@ class WorkbenchModerationDraftTabTestCase extends WorkbenchModerationTestCase { $body_name = 'body[' . LANGUAGE_NONE . '][0]'; $edit = array( 'title' => $this->randomName(), - "{$body_name}[value]" => $this->randomString(128), + "{$body_name}[value]" => $this->randomName(128), "{$body_name}[format]" => filter_default_format(), ); $this->drupalPost("node/add/{$this->content_type}", $edit, t('Save')); @@ -169,13 +169,20 @@ class WorkbenchModerationDraftTabTestCase extends WorkbenchModerationTestCase { $this->assertTrue($node->status, t('Content is published')); // Create a new draft. - $edit = array('title' => $this->randomName(10) . '_revision1'); + $edit = array( + 'title' => $this->randomName(10) . '_revision1', + "{$body_name}[value]" => $this->randomName(128) . '_revision1', + ); $this->drupalPost("node/{$node->nid}/edit", $edit, t('Save')); // Can we get to the 'draft' tab? $this->drupalGet("node/{$node->nid}/draft"); $this->assertResponse(200, t('Draft tab is accessible')); + // Ensure the new draft content is visible. + $this->assertText($edit['title']); + $this->assertText($edit["{$body_name}[value]"]); + // Moderate the content to a non-draft, non-published state. $middle_state = current(array_diff(array_keys(workbench_moderation_states()), array(workbench_moderation_state_none(), workbench_moderation_state_published()))); $edit = array('state' => $middle_state); diff --git a/tests/workbench_moderation_test/workbench_moderation_test.module b/tests/workbench_moderation_test/workbench_moderation_test.module index db57e61..24c1885 100644 --- a/tests/workbench_moderation_test/workbench_moderation_test.module +++ b/tests/workbench_moderation_test/workbench_moderation_test.module @@ -20,6 +20,21 @@ function workbench_moderation_test_menu() { } /** + * Implements hook_menu_alter(). + */ +function workbench_moderation_test_menu_alter(&$items) { + // This menu altering replicates what restws_menu_alter() does. + // @see https://www.drupal.org/node/1838640 + array_unshift($items['node/%node']['page arguments'], 'additional parameter', $items['node/%node']['page callback']); + $items['node/%node']['page callback'] = 'workbench_moderation_test_menu_node_callback'; +} + +function workbench_moderation_test_menu_node_callback($ignored_parameter, $page_callback) { + $args = func_get_args(); + return call_user_func_array($page_callback, array_slice($args, 2)); +} + +/** * Page callback. Publishes, unpublishes or resaves the given node. * * @param object $node