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
|
public static function getInfo() {
|
19
|
return array(
|
20
|
'name' => 'FeedsDateTime unit tests',
|
21
|
'description' => 'Unit tests for Feeds date handling.',
|
22
|
'group' => 'Feeds',
|
23
|
);
|
24
|
}
|
25
|
|
26
|
public function setUp() {
|
27
|
parent::setUp();
|
28
|
module_load_include('inc', 'feeds' , 'plugins/FeedsParser');
|
29
|
}
|
30
|
|
31
|
/**
|
32
|
* Dispatch tests, only use one entry point method testX to save time.
|
33
|
*/
|
34
|
public function test() {
|
35
|
$date = new FeedsDateTime('2010-20-12');
|
36
|
$this->assertTrue(is_numeric($date->format('U')));
|
37
|
$date = new FeedsDateTime('created');
|
38
|
$this->assertTrue(is_numeric($date->format('U')));
|
39
|
$date = new FeedsDateTime('12/3/2009 20:00:10');
|
40
|
$this->assertTrue(is_numeric($date->format('U')));
|
41
|
|
42
|
// Check that years above 2000 work correctly.
|
43
|
$date1 = new FeedsDateTime(2012);
|
44
|
$date2 = new FeedsDateTime('January 2012');
|
45
|
$this->assertEqual($date1->format('U'), $date2->format('U'));
|
46
|
|
47
|
// Check that years before 1902 work correctly.
|
48
|
$early_date_string = '01/02/1901';
|
49
|
$date = new FeedsDateTime($early_date_string);
|
50
|
$this->assertEqual($date->format('m/d/Y'), $early_date_string);
|
51
|
}
|
52
|
|
53
|
}
|