1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 |
- <?php
- /**
- * @file
- * Tests for FeedsDateTime class.
- */
- /**
- * Test FeedsDateTime class.
- *
- * Using DrupalWebTestCase as DrupalUnitTestCase is broken in SimpleTest 2.8.
- * Not inheriting from Feeds base class as ParserCSV should be moved out of
- * Feeds at some time.
- */
- class FeedsDateTimeTest extends FeedsWebTestCase {
- protected $profile = 'testing';
- public static function getInfo() {
- return array(
- 'name' => 'FeedsDateTime unit tests',
- 'description' => 'Unit tests for Feeds date handling.',
- 'group' => 'Feeds',
- );
- }
- public function setUp() {
- parent::setUp();
- module_load_include('inc', 'feeds' , 'plugins/FeedsParser');
- }
- /**
- * Dispatch tests, only use one entry point method testX to save time.
- */
- public function test() {
- $date = new FeedsDateTime('2010-20-12');
- $this->assertTrue(is_numeric($date->format('U')));
- $date = new FeedsDateTime('created');
- $this->assertTrue(is_numeric($date->format('U')));
- $date = new FeedsDateTime('12/3/2009 20:00:10');
- $this->assertTrue(is_numeric($date->format('U')));
- // Check that years above 2000 work correctly.
- $date1 = new FeedsDateTime(2012);
- $date2 = new FeedsDateTime('January 2012');
- $this->assertEqual($date1->format('U'), $date2->format('U'));
- // Check that years before 1902 work correctly.
- $early_date_string = '01/02/1901';
- $date = new FeedsDateTime($early_date_string);
- $this->assertEqual($date->format('m/d/Y'), $early_date_string);
- }
- }
|