| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202 | 
							- <?php
 
- /**
 
-  * @file
 
-  * Timezone tests.
 
-  */
 
- class DateTimezoneTestCase extends DateFieldBasic {
 
-   /**
 
-    * @todo.
 
-    */
 
-   public static function getInfo() {
 
-     return array(
 
-       'name' => 'Timezone & Granularity',
 
-       'description' => 'Test combinations of date field timezone handling and granularity.',
 
-       'group' => 'Date',
 
-     );
 
-   }
 
-   /**
 
-    * @todo.
 
-    */
 
-   public function testTimezone() {
 
-     // Create a date fields with combinations of various timezone handling and
 
-     // granularity.
 
-     foreach (array('date', 'datestamp', 'datetime') as $field_type) {
 
-       foreach (array('site', 'none', 'date', 'user', 'utc') as $tz_handling) {
 
-         foreach (array('year', 'month', 'day', 'hour', 'minute', 'second') as $max_granularity) {
 
-           // Skip invalid combinations.
 
-           if (in_array($max_granularity, array('year', 'month', 'day')) && $tz_handling != 'none') {
 
-             continue;
 
-           }
 
-           $field_name = "field_test";
 
-           $label = 'Test';
 
-           $granularity = date_granularity_array_from_precision($max_granularity);
 
-           $options = array(
 
-             'label' => $label,
 
-             'widget_type' => 'date_text',
 
-             'field_name' => $field_name,
 
-             'field_type' => $field_type,
 
-             'input_format' => 'custom',
 
-             'input_format_custom' => 'm/d/Y - H:i:s',
 
-             'tz_handling' => $tz_handling,
 
-             'granularity' => $granularity,
 
-           );
 
-           $this->createDateField($options);
 
-           $this->dateForm($field_name, $field_type, $max_granularity, $tz_handling);
 
-           $this->deleteDateField($label);
 
-         }
 
-       }
 
-     }
 
-   }
 
-   /**
 
-    * Validates timezone handling with a multi-value date field.
 
-    */
 
-   public function testMultiUserTimezone() {
 
-     // Create date fields with combinations of various types and granularity
 
-     // using the "Date's Timezone" strategy.
 
-     $field_type = 'datetime';
 
-     $tz_handling = 'date';
 
-     $max_granularity = 'minute';
 
-     // Create date field
 
-     $field_name = "field_test";
 
-     $label = 'Test';
 
-     $options = array(
 
-       'label' => $label,
 
-       'widget_type' => 'date_text',
 
-       'field_name' => $field_name,
 
-       'field_type' => $field_type,
 
-       'input_format' => 'custom',
 
-       'input_format_custom' => 'm/d/Y - H:i:s T',
 
-       'cardinality' => 3,
 
-       'tz_handling' => $tz_handling,
 
-     );
 
-     $this->createMultiDateField($options);
 
-     // Submit a date field form with multiple values
 
-     $this->dateMultiValueForm($field_name, $field_type, $max_granularity, $tz_handling);
 
-     $this->deleteDateField($label);
 
-   }
 
-   /**
 
-    * Tests the submission of a date field's widget form when using unlimited
 
-    * cardinality
 
-    */
 
-   public function dateMultiValueForm($field_name, $field_type, $max_granularity, $tz_handling) {
 
-     variable_set('date_format_long', 'D, m/d/Y - H:i:s T');
 
-     $edit = array();
 
-     $should_be = array();
 
-     $edit['title'] = $this->randomName(8);
 
-     $timezones = array('America/Chicago', 'America/Los_Angeles', 'America/New_York');
 
-     switch ($max_granularity) {
 
-       case 'hour':
 
-         $edit[$field_name . '[und][0][value][date]'] = '10/07/2010 - 10:30';
 
-         $edit[$field_name . '[und][0][timezone][timezone]'] = 'America/Chicago';
 
-         $should_be[0] = 'Thu, 10/07/2010 - 10 CDT';
 
-         $edit[$field_name . '[und][1][value][date]'] = '10/07/2010 - 10:30';
 
-         $edit[$field_name . '[und][1][timezone][timezone]'] = 'America/Los_Angeles';
 
-         $should_be[1] = 'Thu, 10/07/2010 - 10 PDT';
 
-         $edit[$field_name . '[und][2][value][date]'] = '10/07/2010 - 10:30';
 
-         $edit[$field_name . '[und][2][timezone][timezone]'] = 'America/New_York';
 
-         $should_be[2] = 'Thu, 10/07/2010 - 10 EDT';
 
-         break;
 
-       case 'minute':
 
-         $edit[$field_name . '[und][0][value][date]'] = '10/07/2010 - 10:30';
 
-         $edit[$field_name . '[und][0][timezone][timezone]'] = 'America/Chicago';
 
-         $should_be[0] = 'Thu, 10/07/2010 - 10:30 CDT';
 
-         $edit[$field_name . '[und][1][value][date]'] = '10/07/2010 - 10:30';
 
-         $edit[$field_name . '[und][1][timezone][timezone]'] = 'America/Los_Angeles';
 
-         $should_be[1] = 'Thu, 10/07/2010 - 10:30 PDT';
 
-         $edit[$field_name . '[und][2][value][date]'] = '10/07/2010 - 10:30';
 
-         $edit[$field_name . '[und][2][timezone][timezone]'] = 'America/New_York';
 
-         $should_be[2] = 'Thu, 10/07/2010 - 10:30 EDT';
 
-         break;
 
-       case 'second':
 
-         $edit[$field_name . '[und][0][value][date]'] = '10/07/2010 - 10:30';
 
-         $edit[$field_name . '[und][0][timezone][timezone]'] = 'America/Chicago';
 
-         $should_be[0] = 'Thu, 10/07/2010 - 10:30:30 CDT';
 
-         $edit[$field_name . '[und][1][value][date]'] = '10/07/2010 - 10:30';
 
-         $edit[$field_name . '[und][1][timezone][timezone]'] = 'America/Los_Angeles';
 
-         $should_be[1] = 'Thu, 10/07/2010 - 10:30:30 PDT';
 
-         $edit[$field_name . '[und][2][value][date]'] = '10/07/2010 - 10:30';
 
-         $edit[$field_name . '[und][2][timezone][timezone]'] = 'America/New_York';
 
-         $should_be[2] = 'Thu, 10/07/2010 - 10:30:30 EDT';
 
-         break;
 
-     }
 
-     $this->drupalPost('node/add/story', $edit, t('Save'));
 
-     $this->assertText($edit['title'], "Node has been created");
 
-     foreach ($should_be as $assertion) {
 
-       $this->assertText($assertion, "Found the correct date for a $field_type field using $max_granularity granularity with $tz_handling timezone handling.");
 
-     }
 
-     // Goto the edit page and save the node again.
 
-     $node = $this->drupalGetNodeByTitle($edit['title']);
 
-     $this->drupalGet('node/' . $node->nid . '/edit');
 
-     // Re-assert the proper date timezones.
 
-     foreach ($timezones as $key => $timezone) {
 
-       $this->assertOptionSelected('edit-field-test-und-' . $key . '-timezone-timezone', $timezone, "Found the correct timezone $timezone for a $field_type field using $max_granularity granularity with $tz_handling timezone handling.");
 
-     }
 
-   }
 
-   /**
 
-    * @todo.
 
-    */
 
-   public function dateForm($field_name, $field_type, $max_granularity, $tz_handling) {
 
-     variable_set('date_format_long', 'D, m/d/Y - H:i:s');
 
-     $edit = array();
 
-     $edit['title'] = $this->randomName(8);
 
-     $edit[$field_name . '[und][0][show_todate]'] = '1';
 
-     switch ($max_granularity) {
 
-       case 'year':
 
-         $edit[$field_name . '[und][0][value][date]'] = '2010';
 
-         $edit[$field_name . '[und][0][value2][date]'] = '2011';
 
-         $should_be = '2010 to 2011';
 
-         break;
 
-       case 'month':
 
-         $edit[$field_name . '[und][0][value][date]'] = '07/2010';
 
-         $edit[$field_name . '[und][0][value2][date]'] = '08/2010';
 
-         $should_be = '07/2010 to 08/2010';
 
-         break;
 
-       case 'day':
 
-         $edit[$field_name . '[und][0][value][date]'] = '10/07/2010';
 
-         $edit[$field_name . '[und][0][value2][date]'] = '10/08/2010';
 
-         $should_be = 'Thu, 10/07/2010 to Fri, 10/08/2010';
 
-         break;
 
-       case 'hour':
 
-         $edit[$field_name . '[und][0][value][date]'] = '10/07/2010 - 10';
 
-         $edit[$field_name . '[und][0][value2][date]'] = '10/07/2010 - 11';
 
-         $should_be = 'Thu, 10/07/2010 - 10 to Thu, 10/07/2010 - 11';
 
-         break;
 
-       case 'minute':
 
-         $edit[$field_name . '[und][0][value][date]'] = '10/07/2010 - 10:30';
 
-         $edit[$field_name . '[und][0][value2][date]'] = '10/07/2010 - 11:30';
 
-         $should_be = 'Thu, 10/07/2010 - 10:30 to 11:30';
 
-         break;
 
-       case 'second':
 
-         $edit[$field_name . '[und][0][value][date]'] = '10/07/2010 - 10:30:30';
 
-         $edit[$field_name . '[und][0][value2][date]'] = '10/07/2010 - 11:30:30';
 
-         $should_be = 'Thu, 10/07/2010 - 10:30:30 to 11:30:30';
 
-         break;
 
-     }
 
-     $this->drupalPost('node/add/story', $edit, t('Save'));
 
-     $this->assertText($edit['title'], "Node has been created");
 
-     $this->assertText($should_be, "Found the correct date for a $field_type field using $max_granularity granularity with $tz_handling timezone handling.");
 
-   }
 
- }
 
 
  |