Index: server/pifr_server.test.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/project_issue_file_review/server/pifr_server.test.inc,v
retrieving revision 1.38
diff -u -r1.38 pifr_server.test.inc
--- server/pifr_server.test.inc	25 Sep 2009 00:49:24 -0000	1.38
+++ server/pifr_server.test.inc	25 Sep 2009 06:06:58 -0000
@@ -350,205 +350,282 @@
 
     $form = array();
 
-    $form['status'] = array(
-      '#type' => 'fieldset',
-      '#title' => t('Test status'),
-      '#attributes' => array('id' => 'pifr-status', 'class' => 'pifr-test'),
-      '#weight' => -10,
-    );
-    $form['status']['table'] = array(
-      '#type' => 'markup',
-      '#value' => theme('table', array(), $object->getTestTable()),
-    );
+    pifr_server_test_view_general($form, $test, $object);
 
-    $form['environment'] = array(
-      '#type' => 'fieldset',
-      '#title' => t('Environment status'),
-      '#attributes' => array('id' => 'pifr-environment', 'class' => 'pifr-test'),
-      '#weight' => -9,
-    );
-    $rows = $object->getEnvironmentTable();
-    $form['environment']['table'] = array(
-      '#type' => 'markup',
-      '#value' => $rows ? theme('table', array(), $rows) : '<em>' . t('No applicable environments.') . '</em>',
-    );
+    // Only display result related information if the test has results.
+    if ($test['status'] == PIFR_SERVER_TEST_STATUS_RESULT) {
+      pifr_server_test_view_result($form, $test);
+    }
 
-    $form['info'] = array(
-      '#type' => 'fieldset',
-      '#title' => t('@type information', array('@type' => $object->getType())),
-      '#attributes' => array('id' => 'pifr-info', 'class' => 'pifr-test'),
-      '#weight' => -8,
-    );
-    $form['info']['table'] = array(
-      '#type' => 'markup',
-      '#value' => theme('table', array(), $object->getInfoTable()),
-    );
+    return drupal_render($form);
+  }
 
-    $form['log'] = array(
-      '#type' => 'fieldset',
-      '#title' => t('Event log'),
-      '#attributes' => array('id' => 'pifr-log'),
-      '#collapsible' => TRUE,
-      '#collapsed' => TRUE,
-      '#weight' => -7,
-    );
+  drupal_set_message(t('Invalid test.'), 'error');
+  return '';
+}
 
-    $view = views_get_view('pifr_server_log');
-    $view->set_display('page_4');
-    $view->set_arguments(array($test_id));
-
-    $form['log']['table'] = array(
-      '#type' => 'markup',
-      '#value' => l(t('View entire log'), 'pifr/log/' . $test_id) . $view->render(),
-    );
+/**
+ * Generate general test information.
+ *
+ * @param array $form Reference to test view form.
+ * @param array $test Test information.
+ * @param object $object Specific test type object.
+ */
+function pifr_server_test_view_general(array &$form, array $test, $object) {
+  $form['status'] = array(
+    '#type' => 'fieldset',
+    '#title' => t('Test status'),
+    '#attributes' => array('id' => 'pifr-status', 'class' => 'pifr-test'),
+    '#weight' => -10,
+  );
+  $form['status']['table'] = array(
+    '#type' => 'markup',
+    '#value' => theme('table', array(), $object->getTestTable()),
+  );
+
+  $form['environment'] = array(
+    '#type' => 'fieldset',
+    '#title' => t('Environment status'),
+    '#attributes' => array('id' => 'pifr-environment', 'class' => 'pifr-test'),
+    '#weight' => -9,
+  );
+  $rows = $object->getEnvironmentTable();
+  $form['environment']['table'] = array(
+    '#type' => 'markup',
+    '#value' => $rows ? theme('table', array(), $rows) : '<em>' . t('No applicable environments.') . '</em>',
+  );
+
+  $form['info'] = array(
+    '#type' => 'fieldset',
+    '#title' => t('@type information', array('@type' => $object->getType())),
+    '#attributes' => array('id' => 'pifr-info', 'class' => 'pifr-test'),
+    '#weight' => -8,
+  );
+  $form['info']['table'] = array(
+    '#type' => 'markup',
+    '#value' => theme('table', array(), $object->getInfoTable()),
+  );
+
+  $form['log'] = array(
+    '#type' => 'fieldset',
+    '#title' => t('Event log'),
+    '#attributes' => array('id' => 'pifr-log'),
+    '#collapsible' => TRUE,
+    '#collapsed' => TRUE,
+    '#weight' => -7,
+  );
+
+  $view = views_get_view('pifr_server_log');
+  $view->set_display('page_4');
+  $view->set_arguments(array($test['test_id']));
+
+  $form['log']['table'] = array(
+    '#type' => 'markup',
+    '#value' => l(t('View entire log'), 'pifr/log/' . $test['test_id']) . $view->render(),
+  );
+}
 
-    $form['result'] = array(
-      '#type' => 'fieldset',
-      '#title' => t('Test results'),
-      '#attributes' => array('id' => 'pifr-result'),
-      '#weight' => -6,
+/**
+ * Generate test result information.
+ *
+ * @param array $form Reference to test view form.
+ * @param array $test Test information.
+ */
+function pifr_server_test_view_result(array &$form, array $test) {
+  $form['summary'] = array(
+    '#type' => 'fieldset',
+    '#title' => t('Summary'),
+    '#attributes' => array('id' => 'pifr-result-summary'),
+    '#weight' => -6,
+//    '#value' => pifr_server_result_get_summary($test['test_id'], TRUE),
+    '#value' => '<em>TODO</em>',
+  );
+
+  $form['detail'] = array(
+    '#type' => 'fieldset',
+    '#title' => t('Details'),
+    '#weight' => -5,
+  );
+  $form['detail']['environment'] = array(
+    '#type' => 'tabset',
+    '#attributes' => array('id' => 'pifr-result-details'),
+    '#weight' => -5,
+  );
+
+  // Generate the results for each environment.
+  $environments = pifr_server_environment_get_all_test($test['test_id']);
+  $results = pifr_server_result_get_all($test['test_id']);
+  foreach ($environments as $environment) {
+    $form['detail']['environment'][$environment['environment_id']] = array(
+      '#type' => 'tabpage',
+      '#title' => $environment['environment_key'],
     );
+    $tab = &$form['detail']['environment'][$environment['environment_id']];
 
-    $map = array(
-      'pass' => theme('image', 'misc/watchdog-ok.png'),
-      'fail' => theme('image', 'misc/watchdog-error.png'),
-      'exception' => theme('image', 'misc/watchdog-warning.png'),
-    );
+    // Only generate result details if there is a result for this environment.
+    if (!empty($results[$environment['environment_id']])) {
+      $tab['#content'] = pifr_server_test_view_result_detail($test, $environment, $results[$environment['environment_id']]);
+    }
+    else {
+      $tab['#content'] = '<em>' . t('No test results for this environment.') . '</em>';
+    }
+  }
+}
 
-    if ($test['type'] == PIFR_SERVER_TEST_TYPE_CLIENT) {
-      $header = array(t('Status'), t('Step'));
-      $rows = array();
+/**
+ * Generate test details.
+ *
+ * Details will include steps, test summaries, and assertions as applicable.
+ *
+ * @param array $test Test information.
+ * @param array $environment Environment information.
+ * @param array $result Test results.
+ * @return string HTML output.
+ */
+function pifr_server_test_view_result_detail(array $test, array $environment, array $result) {
+  $steps = pifr_server_test_view_result_step($test, $environment, $result);
+  $details = pifr_server_test_view_result_table($result);
+  return $steps . $details;
+}
 
-      for ($i = 1; $i <= PIFR_SERVER_TEST_RESULT_PASS; $i++) {
-        $row = array();
-        $row['status'] = $map['exception'];
-        $row['step'] = pifr_server_client_step($i);
+/**
+ * Generate a list of steps.
+ *
+ * The list will contain classes and additional details based on the test,
+ * environment, and results.
+ *
+ * @param array $test Test information.
+ * @param array $environment Environment information.
+ * @param array $result Test results.
+ * @return string HTML output.
+ */
+function pifr_server_test_view_result_step(array $test, array $environment, array $result) {
+  $is_client = $test['type'] == PIFR_SERVER_TEST_TYPE_CLIENT;
+  if ($is_client) {
+    $client = pifr_server_client_get_test($test['test_id']);
+    $status = pifr_server_client_confirmation_status($client);
+
+    // Since there is a result for this environment then it has been tested. If
+    // the client is enabled then the confirmation test passed and thus this
+    // environment must have passed. If the client is not enabled and the last
+    // environment the confirmation test ran in is not this one then it must
+    // have passed, otherwise the last environment to run is this one and it
+    // should be evaluated based on the stage it got to.
+    if ($client['status'] == PIFR_SERVER_CLIENT_STATUS_ENABLED || $status['environment_id'] != $environment['environment_id']) {
+      $code = PIFR_SERVER_TEST_RESULT_PASS;
+    }
+    else {
+      // $status['environment_id'] == $environment['environment_id']
+      $code = $status['stage'] + 1;
+    }
+  }
+  else {
+    // Since the test is not a client test it can be evaluated solely on the
+    // basis of the result code.
+    $code = $result['code'];
+  }
 
-        $rows[$i] = $row;
-      }
+  // Generate a list of the steps.
+  $steps = array();
+  for ($i = PIFR_SERVER_TEST_RESULT_SETUP; $i <= PIFR_SERVER_TEST_RESULT_PASS; $i++) {
+    $step = array(
+      'data' => ucfirst(pifr_server_client_step($i)),
+      'class' => array(),
+    );
 
-      $results = pifr_server_result_get_all($test_id);
-      foreach ($results as $type => $result) {
-        $row = &$rows[$type];
-        $pass = $result['code'] == $type;
-        $row['status'] = $pass ? $map['pass'] : $map['fail'];
-
-        if (!$pass) {
-          $row['step'] .= ' [reason: ' . pifr_server_result_get_summary($test_id, FALSE, $type) . ']';
-        }
+    // Add classes used to style the first three steps since they are unrelated
+    // to the item being tested.
+    if ($i <= PIFR_SERVER_TEST_RESULT_CVS) {
+      $step['class'][] = 'pifr-init';
+      if ($i == PIFR_SERVER_TEST_RESULT_CVS) {
+        $step['class'][] = 'pifr-last';
       }
+    }
 
-      if (isset($results[PIFR_SERVER_TEST_RESULT_FETCH])) {
-        $pass = $results[PIFR_SERVER_TEST_RESULT_FETCH]['code'] == PIFR_SERVER_TEST_RESULT_FETCH;
-        $rows[PIFR_SERVER_TEST_RESULT_SETUP]['status'] = $pass ? $map['pass'] : $map['fail'];
+    // If the step is less then the code then it has passed. If the step is
+    // equal to the code then it must be checked, otherwise ignore the step.
+    if ($i < $code) {
+      $step['class'][] = 'pifr-pass';
+    }
+    elseif ($i == $code) {
+      // If the step is the final step and the result has passed then mark as
+      // passed, otherwise the step is the one that failed.
+      if ($i == PIFR_SERVER_TEST_RESULT_PASS && $result['code'] == PIFR_SERVER_TEST_RESULT_PASS) {
+        $step['class'][] = 'pifr-pass';
       }
-
-      $form['result']['table'] = array(
-        '#type' => 'markup',
-        '#value' => theme('table', $header, $rows),
-        '#weight' => -11,
-      );
-
-      if ($rows[PIFR_SERVER_TEST_RESULT_PASS]['status'] == $map['fail']) {
-        // Overall summary.
-        $form['result']['summary'] = array(
-          '#type' => 'markup',
-          '#value' => pifr_server_result_get_summary($test_id, TRUE, PIFR_SERVER_TEST_RESULT_PASS),
-          '#attributes' => array('id' => 'pifr-summary'),
-          '#weight' => -10,
-        );
-
-        $form['result']['details'] = array(
-          '#type' => 'markup',
-          '#value' => pifr_server_test_result_table($test_id, PIFR_SERVER_TEST_RESULT_PASS),
-          '#weight' => -9,
-        );
+      else {
+        $step['class'][] = 'pifr-fail';
+        $step['data'] .= '<div>Client response: ' . t(pifr_server_result_get_summary_message_minimal($result['code'])) . '</div>';
+        $step['data'] .= '<div>' . t(pifr_server_client_step_description($i)) . '</div>';
       }
     }
-    else {
-      // Overall summary.
-      $form['result']['summary'] = array(
-        '#type' => 'markup',
-        '#value' => pifr_server_result_get_summary($test_id, TRUE),
-        '#attributes' => array('id' => 'pifr-summary'),
-        '#weight' => -10,
-      );
-
-      $form['result']['details'] = array(
-        '#type' => 'markup',
-        '#value' => pifr_server_test_result_table($test_id),
-        '#weight' => -9,
-      );
-    }
 
-    return drupal_render($form);
+    $step['class'] = implode(' ', $step['class']);
+    $steps[] = $step;
   }
-
-  drupal_set_message(t('Invalid test.'), 'error');
-  return '';
+  return theme('item_list', $steps, NULL, 'ol', array('id' => 'pifr-steps'));
 }
 
-function pifr_server_test_result_table($test_id, $display_type = FALSE) {
+/**
+ * Generate detailed display of test results.
+ *
+ * The display will provide test summaries and assertions as applicable.
+ *
+ * @param array $result Test results.
+ * @return string HTML output.
+ */
+function pifr_server_test_view_result_table(array $result) {
   $header = array(t('Test name'), t('Pass'), t('Fail'), t('Exception'));
   $rows = array();
 
-  $results = pifr_server_result_get_all($test_id);
-  $i = 0;
-  foreach ($results as $type => $result) {
-    // Cycle through the result for each environment type. If a failing
-    // result is found then display the detailed assertion information.
-    if (($display_type && $display_type == $type) ||
-        (!$display_type && $result['code'] != PIFR_SERVER_TEST_RESULT_PASS)) {
-      foreach ($result['result_details'] as $detail) {
-        // Display the summary of the test.
-        $row = array();
+  foreach ($result['result_details'] as $detail) {
+    // Display the summary of the test.
+    $row = array();
+
+    $row[] = $detail['test_name'];
+    $row[] = $detail['pass'];
+    $row[] = $detail['fail'];
+    $row[] = $detail['exception'];
+
+    $class = 'pass';
+    if ($detail['fail']) {
+      $class = 'fail';
+    }
+    elseif ($detail['exception']) {
+      $class = 'exception';
+    }
+    $rows[] = array(
+      'class' => 'pifr-' . $class,
+      'data' => $row,
+    );
 
-        $row[] = $detail['test_name'];
-        $row[] = $detail['pass'];
-        $row[] = $detail['fail'];
-        $row[] = $detail['exception'];
-
-        $class = 'pass';
-        if ($detail['fail']) {
-          $class = 'fail';
-        }
-        elseif ($detail['exception']) {
-          $class = 'exception';
-        }
-        $rows[] = array(
-          'class' => 'pifr-' . $class,
-          'data' => $row,
+    if ($detail['assertions']) {
+      $header_detail = array(t('Message'), t('Group'), t('Filename'), t('Line'), t('Function'), t('Status'));
+      $rows_detail = array();
+      foreach ($detail['assertions'] as $assertion) {
+        $row = array();
+        $row[] = $assertion['message'];
+        $row[] = $assertion['message_group'];
+        $row[] = $assertion['file'];
+        $row[] = $assertion['line'];
+        $row[] = $assertion['function'];
+        $row[] = $map[$assertion['status']];
+
+        $rows_detail[] = array(
+          'class' => 'pifr-' . $assertion['status'],
+          'data' => $row
         );
-
-        if ($detail['assertions']) {
-          $header_detail = array(t('Message'), t('Group'), t('Filename'), t('Line'), t('Function'), t('Status'));
-          $rows_detail = array();
-          foreach ($detail['assertions'] as $assertion) {
-            $row = array();
-            $row[] = $assertion['message'];
-            $row[] = $assertion['message_group'];
-            $row[] = $assertion['file'];
-            $row[] = $assertion['line'];
-            $row[] = $assertion['function'];
-            $row[] = $map[$assertion['status']];
-
-            $rows_detail[] = array(
-              'class' => 'pifr-' . $assertion['status'],
-              'data' => $row
-            );
-          }
-
-          $row = array();
-          $row[] = array(
-            'colspan' => 4,
-            'data' => theme('table', $header_detail, $rows_detail),
-          );
-          $rows[] = array(
-            'class' => 'pifr-assertion-wrapper',
-            'data' => $row,
-          );
-        }
       }
+
+      $row = array();
+      $row[] = array(
+        'colspan' => 4,
+        'data' => theme('table', $header_detail, $rows_detail),
+      );
+      $rows[] = array(
+        'class' => 'pifr-assertion-wrapper',
+        'data' => $row,
+      );
     }
   }
 
Index: server/pifr_server.css
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/project_issue_file_review/server/pifr_server.css,v
retrieving revision 1.2
diff -u -r1.2 pifr_server.css
--- server/pifr_server.css	24 Jul 2009 00:55:06 -0000	1.2
+++ server/pifr_server.css	25 Sep 2009 06:06:58 -0000
@@ -15,6 +15,39 @@
   padding: 5px;
 }
 
+#pifr-steps li {
+  margin-top: 0;
+  margin-bottom: 0;
+  padding: 1px 5px;
+  color: #cccccc;
+}
+
+#pifr-steps li.pifr-init {
+  background-color: #eeeeee;
+  border-left: 1px solid #cccccc;
+  border-right: 1px solid #cccccc;
+}
+
+#pifr-steps li.first {
+  border-top: 1px solid #cccccc;
+}
+
+#pifr-steps li.pifr-last {
+  border-bottom: 1px solid #cccccc;
+}
+
+#pifr-steps li.pifr-pass {
+  color: green;
+}
+
+#pifr-steps li.pifr-fail {
+  color: red;
+}
+
+#pifr-steps li div {
+  color: #494949;
+}
+
 .pifr-assertion-header {
   cursor: pointer;
 }
Index: server/pifr_server.client.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/project_issue_file_review/server/pifr_server.client.inc,v
retrieving revision 1.34
diff -u -r1.34 pifr_server.client.inc
--- server/pifr_server.client.inc	25 Sep 2009 04:17:37 -0000	1.34
+++ server/pifr_server.client.inc	25 Sep 2009 06:06:58 -0000
@@ -289,8 +289,7 @@
   }
   else {
     // Stages: PIFR_SERVER_TEST_RESULT_PATCH through PIFR_SERVER_TEST_RESULT_PASS.
-    $patches = array('patch', 'apply', 'syntax', 'install', 'test', 'fail', 'pass');
-    $patch = $patches[$stage - PIFR_SERVER_TEST_RESULT_PATCH];
+    $patch = pifr_server_client_confirmation_test_patch($stage);
     return array(
       'file_url' => url(file_directory_path() . '/pifr_server/' . $patch . '.patch', array('absolute' => TRUE)),
     );
@@ -298,6 +297,17 @@
 }
 
 /**
+ * Get the patch related to the stage.
+ *
+ * @param integer $stage Confirmation stage.
+ * @return string Patch name without the '.patch' suffix.
+ */
+function pifr_server_client_confirmation_test_patch($stage) {
+  $patches = array('patch', 'apply', 'syntax', 'install', 'test', 'fail', 'pass');
+  return $patches[$stage - PIFR_SERVER_TEST_RESULT_PATCH];
+}
+
+/**
  * Merge an array of changes with the default client confirmation test array.
  *
  * @param array $client Client information
@@ -468,28 +478,65 @@
   }
 }
 
-function pifr_server_client_step($type) {
+/**
+ * Get the client confirmation test step title.
+ *
+ * @param integer $step Step of test.
+ * @return string Title of step.
+ */
+function pifr_server_client_step($step) {
+  switch ($step) {
+    case PIFR_SERVER_TEST_RESULT_SETUP:
+      return t('setup environment');
+    case PIFR_SERVER_TEST_RESULT_FETCH:
+      return t('detect an invalid file URL');
+    case PIFR_SERVER_TEST_RESULT_CVS:
+      return t('detect invalid repository information');
+    case PIFR_SERVER_TEST_RESULT_PATCH:
+      return t('detect invalid patch format');
+    case PIFR_SERVER_TEST_RESULT_APPLY:
+      return t('detect a non-applicable patch');
+    case PIFR_SERVER_TEST_RESULT_SYNTAX:
+      return t('detect invalid PHP syntax');
+    case PIFR_SERVER_TEST_RESULT_INSTALL:
+      return t('detect a Drupal installation failure');
+    case PIFR_SERVER_TEST_RESULT_TEST:
+      return t('detect a test run failure');
+    case PIFR_SERVER_TEST_RESULT_FAIL:
+      return t('detect a failing test');
+    case PIFR_SERVER_TEST_RESULT_PASS:
+      return t('complete test suite with all tests passing');
+    default:
+      return 'Unknown';
+  }
+}
+
+/**
+ * Get the client confirmation test step description.
+ *
+ * @param integer $step Step of test.
+ * @return string Description of step.
+ */
+function pifr_server_client_step_description($type) {
+  $base_url = url(file_directory_path() . '/pifr_server/', array('absolute' => TRUE));
   switch ($type) {
     case PIFR_SERVER_TEST_RESULT_SETUP:
-      return t('Setup environment.');
+      return t('The client failed to setup the testing environment. Check the pifr_client INSTALL.txt.');
     case PIFR_SERVER_TEST_RESULT_FETCH:
-      return t('Detect invalid file URL.');
+      return t('The client failed to detect an invalid file URL that pointed to example.com.');
     case PIFR_SERVER_TEST_RESULT_CVS:
-      return t('Detect invalid repository information.');
+      return t('The client failed to detect invalid repository information that pointed to example.com.');
     case PIFR_SERVER_TEST_RESULT_PATCH:
-      return t('Detect invalid patch format.');
     case PIFR_SERVER_TEST_RESULT_APPLY:
-      return t('Detect non-applicable patch.');
     case PIFR_SERVER_TEST_RESULT_SYNTAX:
-      return 'Detect invalid PHP syntax.';
     case PIFR_SERVER_TEST_RESULT_INSTALL:
-      return 'Detect Drupal installation failure.';
     case PIFR_SERVER_TEST_RESULT_TEST:
-      return 'Detect test run failure.';
     case PIFR_SERVER_TEST_RESULT_FAIL:
-      return 'Detect failing test.';
+      $patch = pifr_server_client_confirmation_test_patch($type);
+      return t('The client failed to @type which is induced using the !patch.',
+        array('@type' => pifr_server_client_step($type), '!patch' => l($patch . '.patch', $base_url . $patch . '.patch')));
     case PIFR_SERVER_TEST_RESULT_PASS:
-      return 'Complete test suite with all tests passing.';
+      return t('Client failed to run the test suite with all tests passing.');
     default:
       return 'Unknown';
   }
Index: server/pifr_server.info
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/project_issue_file_review/server/pifr_server.info,v
retrieving revision 1.8
diff -u -r1.8 pifr_server.info
--- server/pifr_server.info	18 Jul 2009 07:19:53 -0000	1.8
+++ server/pifr_server.info	25 Sep 2009 06:06:58 -0000
@@ -21,3 +21,4 @@
 dependencies[] = pifr
 dependencies[] = chart
 dependencies[] = views
+dependencies[] = tabs
