feeds_date_time.test 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <?php
  2. /**
  3. * @file
  4. * Tests for FeedsDateTime class.
  5. */
  6. /**
  7. * Test FeedsDateTime class.
  8. *
  9. * Using DrupalWebTestCase as DrupalUnitTestCase is broken in SimpleTest 2.8.
  10. * Not inheriting from Feeds base class as ParserCSV should be moved out of
  11. * Feeds at some time.
  12. */
  13. class FeedsDateTimeTest extends FeedsWebTestCase {
  14. protected $profile = 'testing';
  15. public static function getInfo() {
  16. return array(
  17. 'name' => 'FeedsDateTime unit tests',
  18. 'description' => 'Unit tests for Feeds date handling.',
  19. 'group' => 'Feeds',
  20. );
  21. }
  22. public function setUp() {
  23. parent::setUp();
  24. module_load_include('inc', 'feeds' , 'plugins/FeedsParser');
  25. }
  26. /**
  27. * Dispatch tests, only use one entry point method testX to save time.
  28. */
  29. public function test() {
  30. $date = new FeedsDateTime('2010-20-12');
  31. $this->assertTrue(is_numeric($date->format('U')));
  32. $date = new FeedsDateTime('created');
  33. $this->assertTrue(is_numeric($date->format('U')));
  34. $date = new FeedsDateTime('12/3/2009 20:00:10');
  35. $this->assertTrue(is_numeric($date->format('U')));
  36. // Check that years above 2000 work correctly.
  37. $date1 = new FeedsDateTime(2012);
  38. $date2 = new FeedsDateTime('January 2012');
  39. $this->assertEqual($date1->format('U'), $date2->format('U'));
  40. // Check that years before 1902 work correctly.
  41. $early_date_string = '01/02/1901';
  42. $date = new FeedsDateTime($early_date_string);
  43. $this->assertEqual($date->format('m/d/Y'), $early_date_string);
  44. }
  45. }