diff --git a/scheduler.test.32 b/scheduler.test index 28df94f..251feb4 100644 --- a/scheduler.test.32 +++ b/scheduler.test @@ -141,10 +141,15 @@ class SchedulerTestCase extends DrupalWebTestCase { // Define test scenarios with expected results. $test_cases = array( - // 1. Test scenarios that require scheduled publishing. + // The 1-10 numbering used below matches the test cases described in + // http://drupal.org/node/1198788#comment-7816119 + + // A. Test scenarios that require scheduled publishing. + // When creating a new published node it is required to enter a // publication date. The node will be unpublished on form submit. array( + 'id' => 2, 'required' => 'publish', 'operation' => 'add', 'status' => 1, @@ -155,6 +160,7 @@ class SchedulerTestCase extends DrupalWebTestCase { // When creating a new unpublished node it is required to enter a // publication date. array( + 'id' => 1, 'required' => 'publish', 'operation' => 'add', 'status' => 0, @@ -165,6 +171,7 @@ class SchedulerTestCase extends DrupalWebTestCase { // When editing a published node it is not needed to enter a publication // date since the node is already published. array( + 'id' => 3, 'required' => 'publish', 'operation' => 'edit', 'scheduled' => 0, @@ -176,6 +183,7 @@ class SchedulerTestCase extends DrupalWebTestCase { // When editing an unpublished node that is scheduled for publication it // is required to enter a publication date. array( + 'id' => 4, 'required' => 'publish', 'operation' => 'edit', 'scheduled' => 1, @@ -188,6 +196,7 @@ class SchedulerTestCase extends DrupalWebTestCase { // it is not required to enter a publication date since this means that // the node has already gone through a publication > unpublication cycle. array( + 'id' => 5, 'required' => 'publish', 'operation' => 'edit', 'scheduled' => 0, @@ -196,10 +205,12 @@ class SchedulerTestCase extends DrupalWebTestCase { 'message' => 'When scheduled publishing is required and an existing unpublished, unscheduled node is edited, entering a date in the publish on field is not required.', ), - // 2. Test scenarios that require scheduled unpublishing. + // B. Test scenarios that require scheduled unpublishing. + // When creating a new published node it is required to enter an // unpublication date. array( + 'id' => 7, 'required' => 'unpublish', 'operation' => 'add', 'status' => 1, @@ -211,6 +222,7 @@ class SchedulerTestCase extends DrupalWebTestCase { // unpublication date since it is to be expected that the node will be // published at some point and should subsequently be unpublished. array( + 'id' => 6, 'required' => 'unpublish', 'operation' => 'add', 'status' => 0, @@ -221,6 +233,7 @@ class SchedulerTestCase extends DrupalWebTestCase { // When editing a published node it is required to enter an unpublication // date. array( + 'id' => 8, 'required' => 'unpublish', 'operation' => 'edit', 'scheduled' => 0, @@ -232,6 +245,7 @@ class SchedulerTestCase extends DrupalWebTestCase { // When editing an unpublished node that is scheduled for publication it // it is required to enter an unpublication date. array( + 'id' => 9, 'required' => 'unpublish', 'operation' => 'edit', 'scheduled' => 1, @@ -244,6 +258,7 @@ class SchedulerTestCase extends DrupalWebTestCase { // it is not required to enter an unpublication date since this means that // the node has already gone through a publication - unpublication cycle. array( + 'id' => 10, 'required' => 'unpublish', 'operation' => 'edit', 'scheduled' => 0, @@ -258,8 +273,21 @@ class SchedulerTestCase extends DrupalWebTestCase { variable_set('scheduler_publish_required_page', $test_case['required'] == 'publish'); variable_set('scheduler_unpublish_required_page', $test_case['required'] == 'unpublish'); + // Set the default node status, used when creating a new node. + $node_options_page = !empty($test_case['status']) ? array('status') : array(); + variable_set('node_options_page', $node_options_page); + // If the test case requires editing a node, we need to create one first. - $title = $this->randomString(); + // To assist viewing and analysing the generated test result pages create + // a string holding the options, for use as the title. Start with the full + // $test_case array, remove the message key, then compress it into a + // string, and remove 'Array' and ( ) and reduce multiple whitespace. + $title_data = $test_case; + unset($title_data['message']); + $title = print_r($title_data, TRUE); + $title = preg_replace('/Array|\(|\)/', ' ', $title); + $title = trim(preg_replace('/\s+/', ' ', $title)); + if ($test_case['operation'] == 'edit') { $options = array( 'title' => $title, @@ -291,16 +319,15 @@ class SchedulerTestCase extends DrupalWebTestCase { switch ($test_case['expected']) { case 'required': $string = t('!name field is required.', array('!name' => ucfirst($test_case['required']) . ' on')); - $this->assertRaw($string, $test_case['message']); + $this->assertRaw($string, $test_case['id'] . '. ' . $test_case['message']); break; case 'not required': $string = '@type %title has been ' . ($test_case['operation'] == 'add' ? 'created' : 'updated') . '.'; $args = array('@type' => 'Basic page', '%title' => $title); - $this->assertRaw(t($string, $args), $test_case['message']); + $this->assertRaw(t($string, $args), $test_case['id'] . '. ' . $test_case['message']); break; } } } - }