Projet

Général

Profil

Paste
Télécharger (2,47 ko) Statistiques
| Branche: | Révision:

root / drupal7 / sites / all / modules / date / tests / DateUiTestCase.test @ 599a39cd

1
<?php
2

    
3
/**
4
 * @file
5
 * Test date UI.
6
 */
7
/**
8
 *
9
 */
10
class DateUiTestCase extends DateFieldTestBase {
11

    
12
  /**
13
   * @todo.
14
   */
15
  public static function getInfo() {
16
    return array(
17
      'name' => 'Field UI',
18
      'description' => 'Test creation of various date fields and widgets using Field UI.',
19
      'group' => 'Date',
20
    );
21
  }
22

    
23
  /**
24
   * @todo.
25
   */
26
  public function setUp(array $modules = array()) {
27
    parent::setUp($modules);
28

    
29
    variable_set('date_format_long', 'D, m/d/Y - H:i');
30
  }
31

    
32
  /**
33
   * @todo.
34
   */
35
  public function testFieldUI() {
36
    $label = 'Test';
37
    $current_year = date('Y');
38

    
39
    // Test widgets with default settings using every widget and field type.
40
    foreach (array('date', 'datestamp', 'datetime') as $field_type) {
41
      // @todo Add back 'date_popup'.
42
      foreach (array('date_select', 'date_text') as $widget_type) {
43
        $this->createDateField(
44
          array(
45
            'label' => $label,
46
            'field_type' => $field_type,
47
            'widget_type' => $widget_type,
48
          )
49
        );
50
        $this->dateForm('blah', 'blah', $widget_type);
51
        $this->assertText(format_string('10/07/!year - 10:30', array('!year' => $current_year)), 'Found the correct date for a date field using the ' . $widget_type . ' widget.');
52
        $this->deleteDateField($label);
53
      }
54
    }
55
  }
56

    
57
  /**
58
   * {@inheritdoc}
59
   */
60
  function dateForm($field_name, $field_type, $widget_type, $todate = TRUE) {
61
    // Tests that date field functions properly.
62
    $edit = array();
63
    $edit['title'] = $this->randomName(8);
64
    $edit['body[und][0][value]'] = $this->randomName(16);
65
    $current_year = date('Y');
66

    
67
    if ($widget_type == 'date_select') {
68
      $edit['field_test[und][0][value][year]'] = $current_year;
69
      $edit['field_test[und][0][value][month]'] = '10';
70
      $edit['field_test[und][0][value][day]'] = '7';
71
      $edit['field_test[und][0][value][hour]'] = '10';
72
      $edit['field_test[und][0][value][minute]'] = '30';
73
    }
74
    elseif ($widget_type == 'date_text') {
75
      $edit['field_test[und][0][value][date]'] = format_string('10/07/!year - 10:30', array('!year' => $current_year));
76
    }
77
    elseif ($widget_type == 'date_popup') {
78
      $edit['field_test[und][0][value][date]'] = format_string('10/07/!year', array('!year' => $current_year));
79
      $edit['field_test[und][0][value][time]'] = '10:30';
80
    }
81
    $this->drupalPost('node/add/story', $edit, t('Save'));
82
    $this->assertText($edit['body[und][0][value]'], 'Test node has been created');
83
  }
84

    
85
}