Projet

Général

Profil

Paste
Télécharger (1,54 ko) Statistiques
| Branche: | Révision:

root / drupal7 / sites / all / modules / feeds / tests / feeds_date_time.test @ ed9a13f1

1
<?php
2

    
3
/**
4
 * @file
5
 * Tests for FeedsDateTime class.
6
 */
7

    
8
/**
9
 * Test FeedsDateTime class.
10
 *
11
 * Using DrupalWebTestCase as DrupalUnitTestCase is broken in SimpleTest 2.8.
12
 * Not inheriting from Feeds base class as ParserCSV should be moved out of
13
 * Feeds at some time.
14
 */
15
class FeedsDateTimeTest extends FeedsWebTestCase {
16
  protected $profile = 'testing';
17

    
18
  /**
19
   * {@inheritdoc}
20
   */
21
  public static function getInfo() {
22
    return array(
23
      'name' => 'FeedsDateTime unit tests',
24
      'description' => 'Unit tests for Feeds date handling.',
25
      'group' => 'Feeds',
26
    );
27
  }
28

    
29
  /**
30
   * {@inheritdoc}
31
   */
32
  public function setUp() {
33
    parent::setUp();
34
    module_load_include('inc', 'feeds', 'plugins/FeedsParser');
35
  }
36

    
37
  /**
38
   * Dispatch tests, only use one entry point method testX to save time.
39
   */
40
  public function test() {
41
    $date = new FeedsDateTime('2010-20-12');
42
    $this->assertTrue(is_numeric($date->format('U')));
43
    $date = new FeedsDateTime('created');
44
    $this->assertTrue(is_numeric($date->format('U')));
45
    $date = new FeedsDateTime('12/3/2009 20:00:10');
46
    $this->assertTrue(is_numeric($date->format('U')));
47

    
48
    // Check that years above 2000 work correctly.
49
    $date1 = new FeedsDateTime(2012);
50
    $date2 = new FeedsDateTime('January 2012');
51
    $this->assertEqual($date1->format('U'), $date2->format('U'));
52

    
53
    // Check that years before 1902 work correctly.
54
    $early_date_string = '01/02/1901';
55
    $date = new FeedsDateTime($early_date_string);
56
    $this->assertEqual($date->format('m/d/Y'), $early_date_string);
57
  }
58

    
59
}