From 75a022a0ab8e734a4548eb3cf141bc33cab1885a Mon Sep 17 00:00:00 2001 From: Nicholas Thompson Date: Thu, 29 Dec 2011 11:19:48 +0000 Subject: [PATCH] Improving the test output and cleaning up the path options array code. --- globalredirect.test | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/globalredirect.test b/globalredirect.test index f9713dd..16814f4 100644 --- a/globalredirect.test +++ b/globalredirect.test @@ -1,7 +1,9 @@ Expected Path: !expected_path
Expected Status Code: !expected_status
Location: !location
Status: !status'); +define('ERROR_MESSAGE', 'ERROR
Expected Path: !expected_path
Expected Status Code: !expected_status
Location: !location
Status: !status'); define('SUCCESS_MESSAGE', 'SUCCESS
Expected Path: !expected_path
Expected Status Code: !expected_status
Location: !location
Status: !status'); +define('INFO_MESSAGE', 'Running Test: !id
Requesting URL@ !url'); + /** * @file @@ -229,15 +231,28 @@ class GlobalRedirectTestCase extends DrupalWebTestCase { // Foreach of the above, lets check they redirect correctly foreach ($test_paths as $id => $path) { - $this->pass(t('Running Test: !id', array('!id' => $id))); + // Overlay some defaults onto the path. This ensures 'options' is set as an array. + $path += array( + 'options' => array(), + ); - $path['options'] = isset($path['options']) ? $path['options'] + array('absolute' => TRUE) : array('absolute' => TRUE); + // If the path doesn't have an absolute or alias setting, set them to TRUE. + $path['options'] += array( + 'absolute' => TRUE, + 'alias' => TRUE, + ); - $request_path = url($path['request'], $path['options'] + array('alias' => TRUE)); + // Build a URL from the path + $request_path = url($path['request'], $path['options']); - // Display a message tellingthe user what we're testing - $this->pass(t('Requesting: !path', array('!path' => $request_path))); + // Display a message telling the user what we're testing + $info = array( + '!id' => $id, + '!url' => $request_path, + ); + $this->pass(t(INFO_MESSAGE, $info), 'GlobalRedirect'); + // Do a HEAD request (don't care about the body). The alias=>TRUE is to tell Drupal not to lookup the alias - this is a raw request. $this->drupalHead($request_path, array('alias' => TRUE));