Projet

Général

Profil

Révision 6eb8d15f

Ajouté par Assos Assos il y a presque 10 ans

Weekly update of contrib modules

Voir les différences:

drupal7/sites/all/modules/views/tests/handlers/views_handler_field_date.test
34 34
        'relationship' => 'none',
35 35
        // c is iso 8601 date format @see http://php.net/manual/en/function.date.php
36 36
        'custom_date_format' => 'c',
37
        'second_date_format' => 'custom',
38
        'second_date_format_custom' => 'c',
37 39
      ),
38 40
    ));
39 41
    $time = gmmktime(0, 0, 0, 1, 1, 2000);
......
51 53
        'medium' => format_date($time, 'medium', '', $timezone),
52 54
        'large' => format_date($time, 'large', '', $timezone),
53 55
        'custom' => format_date($time, 'custom', 'c', $timezone),
56
        'today time ago custom' => format_date($time, 'custom', 'c', $timezone),
57
        'today time ago' => t('%time ago', array('%time' => format_interval(120, 2))),
54 58
      );
55 59
      $this->assertRenderedDatesEqual($view, $dates, $timezone);
56 60
    }
......
67 71

  
68 72
  protected function assertRenderedDatesEqual($view, $map, $timezone = NULL) {
69 73
    foreach ($map as $date_format => $expected_result) {
74
      $check_result_number = 0;
75

  
76
      // If it's "today time ago" format we have to check the 6th element.
77
      if ($date_format == 'today time ago') {
78
        $check_result_number = 5;
79
      }
80

  
81
      // Correct the date format.
82
      if ($date_format == 'today time ago custom') {
83
        $date_format = 'today time ago';
84
      }
70 85
      $view->field['created']->options['date_format'] = $date_format;
71 86
      $t_args = array(
72 87
        '%value' => $expected_result,
......
80 95
      else {
81 96
        $message = t('Value %value in %format format matches.', $t_args);
82 97
      }
83
      $actual_result = $view->field['created']->advanced_render($view->result[0]);
98
      $actual_result = $view->field['created']->advanced_render($view->result[$check_result_number]);
84 99
      $this->assertEqual($expected_result, $actual_result, $message);
85 100
    }
86 101
  }
102

  
103
  /**
104
   * Appends dataSet() with a data row for "today time ago" format testing.
105
   */
106
  protected function dataSet() {
107
    $data = parent::dataSet();
108
    $data[] = array(
109
      'name' => 'David',
110
      'age' => 25,
111
      'job' => 'Singer',
112
      'created' => REQUEST_TIME - 120,
113
    );
114

  
115
    return $data;
116
  }
87 117
}

Formats disponibles : Unified diff