? jquery.timers.js
Index: clock.test
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/clock/clock.test,v
retrieving revision 1.5
diff -u -p -r1.5 clock.test
--- clock.test	18 Feb 2010 04:58:51 -0000	1.5
+++ clock.test	3 May 2010 17:53:28 -0000
@@ -1,9 +1,9 @@
 <?php
-// $Id: clock.test,v 1.5 2010/02/18 04:58:51 tstoeckler Exp $
+// $Id: clock.test,v 1.4.2.2 2010/05/03 16:39:40 tstoeckler Exp $
 
 /**
  * @file
- * Tests for the clock module.
+ * Tests for Clock module.
  */
 
 class ClockBlockTestCase extends DrupalWebTestCase {
@@ -11,7 +11,7 @@ class ClockBlockTestCase extends DrupalW
   public static function getInfo() {
     return array(
       'name' => t('Clock module tests'),
-      'description' => t('Ensure that clock module functions properly.'),
+      'description' => t('Ensure that the clock block functions properly.'),
       'group' => t('Clock'),
     );
   }
@@ -22,81 +22,64 @@ class ClockBlockTestCase extends DrupalW
     // Save the test user's uid to access the user edit page later.
     variable_set('test_user_id', $privileged_user->uid);
     $this->drupalLogin($privileged_user);
-    $edit = array();
     // Enable the clock block in the right sidebar.
     $edit = array();
-    $edit['clock_clock[region]'] = 'sidebar_seconds';
+    $edit['clock_clock[region]'] = 'right';
     $this->drupalPost('admin/structure/block', $edit, 'Save blocks');
   }
 
   public function testClockBlockDefault() {
-    $date_format = _clock_get_date_format();
-    $clock = date_format_date(date_now('UTC'), $type = 'custom', $format = $date_format);
+    $clock = date_format_date(date_now('UTC'), 'short');
     $this->assertText($clock, t('Ensure that the clock is correctly displayed by default.'));
+    $edit['timezone'] = '3';
+    $this->drupalPost('admin/structure/block/manage/clock/clock/configure', $edit, 'Save block');
+    $this->assertText($clock, t('Ensure that the clock falls back to the site time with Local time zone enabled and without JavaScript.'));
   }
 
   public function testClockBlockUserTimezone() {
     // Set the user's time zone to something different from the site default.
     $edit = array();
-    $edit['timezone'] = 'Pacific/Fiji';
+    $edit['timezone_name'] = 'Pacific/Fiji';
     $this->drupalPost('user/' . variable_get('test_user_id', '1') . '/edit', $edit, 'Save');
     // Set the clock block to display the user time zone.
     $edit = array();
     $edit['timezone'] = '2';
     $this->drupalPost('admin/structure/block/manage/clock/clock/configure', $edit, 'Save block');
-    $date_format = _clock_get_date_format();
-    $clock = date_format_date(date_now('Pacific/Fiji'), $type = 'custom', $format = $date_format);
+    $clock = date_format_date(date_now('Pacific/Fiji'), 'short');
     $this->assertText($clock, t('Ensure that the clock is correctly displayed in the user time zone.'));
   }
 
   public function testClockBlockCustomTimezone() {
     // Set the clock block to display a custom time zone.
     $edit = array();
-    $edit['timezone'] = '3';
+    $edit['timezone'] = '4';
     $edit['custom_timezone'] = 'Africa/Timbuktu';
     $this->drupalPost('admin/structure/block/manage/clock/clock/configure', $edit, 'Save block');
-    $date_format = _clock_get_date_format();
-    $clock = date_format_date(date_now('Africa/Timbuktu'), $type = 'custom', $format = $date_format);
+    $clock = date_format_date(date_now('Africa/Timbuktu'), 'short');
     $this->assert($clock, t('Ensure that the clock is correctly displayed in a custom date format.'));
   }
 
-  public function testClockBlockMediumDateFormat() {
-    // Set the clock block to display the medium date format.
-    $edit = array();
-    $edit['date_format'] = 'medium';
-    $this->drupalPost('admin/structure/block/manage/clock/clock/configure', $edit, 'Save block');
-    $date_format = _clock_get_date_format();
-    $clock = date_format_date(date_now(), $type = 'custom', $format = $date_format);
-    $this->assert($clock, t('Ensure that the clock is correctly displayed in the medium date format.'));
-  }
-
-  public function testClockBlockShortDateFormat() {
-    // Set the clock block to display the long date format.
+  public function testClockBlockDateFormat() {
+    // Configure a custom date format.
     $edit = array();
-    $edit['date_format'] = 'short';
-    $this->drupalPost('admin/structure/block/manage/clock/clock/configure', $edit, 'Save block');
-    $date_format = _clock_get_date_format();
-    $clock = date_format_date(date_now(), $type = 'custom', $format = $date_format);
-    $this->assert($clock, t('Ensure that the clock is correctly displayed in the short date format.'));
-  }
-
-  public function testClockBlockCustomDateFormat() {
-    // Create a custom date format.
-    $edit = array();
-    $edit['date_format'] = 'aABcdDeFgGhHiIjlmMnOPrsStTUwWYyzZ';
+    $edit['date_format'] = 'aABcdDeFgGhHiIjlmMnNoOPrsStTuUwWYyzZ'
     $this->drupalPost('admin/config/regional/date-time/formats/add', $edit, 'Add format');
-    // Create a custom format type.
+    // Configure a custom format type with the custom date format.
     $edit = array();
-    $edit['date_type'] = 'Custom';
-    $edit['machine_name'] = 'custom';
-    $edit['date_format'] = 'aABcdDeFgGhHiIjlmMnOPrsStTUwWYyzZ';
+    $edit['date_type'] = $this->randomName();
+    $edit['date_format'] = 'aABcdDeFgGhHiIjlmMnNoOPrsStTuUwWYyzZ'
     $this->drupalPost('admin/config/regional/date-time/types/add', $edit, 'Add date type');
-    // Set the clock block to display the custom format.
-    $edit = array();
-    $edit['date_format'] = 'custom';
-    $this->drupalPost('admin/structure/block/manage/clock/clock/configure', $edit, 'Save block');
-    $clock = date_format_date(date_now(), 'custom', 'aABcdDeFgGhHiIjlmMnOPrsStTUwWYyzZ');
-    $this->assertText($clock, t('Ensure that the clock is correctly displayed in a custom format.'));
+    // Test the clock block in each configured format type.
+    foreach (system_get_date_types() as $date_type => $info) {
+      if (!$date_format = variable_get('date_format' . $type, '') {
+        $date_format = array_shift(system_get_date_formats($type));
+      }
+      $edit = array();
+      $edit['date_format'] = $date_type;
+      $this->drupalPost('admin/structure/block/manage/clock/clock/configure', $edit, 'Save block');
+      $clock = date_format_date(date_now(), 'custom', $date_format);
+      $this->assert($clock, t('Ensure that the clock is correctly displayed in the @type date format type.', array('@type' => $info['title'])));
+    }
   }
 
 }
@@ -106,13 +89,13 @@ class ClockConfigureTestCase extends Dru
   public static function getInfo() {
     return array(
       'name' => t('Clock interface tests'),
-      'description' => t('Ensure that the configure user interface functions correctly.'),
+      'description' => t('Ensure that the user interface functions correctly.'),
       'group' => t('Clock'),
     );
   }
 
   public function setUp() {
-    parent::setUp('block', 'date_api', 'clock');
+    parent::setUp('block' 'date_api', 'clock');
     $privileged_user = $this->drupalCreateUser(array('administer blocks', 'administer site configuration'));
     $this->drupalLogin($privileged_user);
   }
@@ -120,7 +103,6 @@ class ClockConfigureTestCase extends Dru
   public function testClockInterfaceUserTimezone() {
     $this->drupalGet('admin/structure/block/manage/clock/clock/configure');
     $this->assertText(t('User time zone'), t('Make sure the "User time zone" setting is available when user time zones are enabled.'));
-    // Disable user-configurable timezones.
     $edit = array();
     $edit['configurable_timezones'] = '0';
     $this->drupalPost('admin/config/regional/settings', $edit, 'Save configuration');
