You are here

public function WeatherParserTestCase::testParsingOfInformation in Weather 7.2

Same name and namespace in other branches
  1. 7.3 tests/parser.test \WeatherParserTestCase::testParsingOfInformation()

Test parsing of information about a forecast.

File

tests/parser.test, line 64
Tests parsing of XML weather forecasts.

Class

WeatherParserTestCase
Test class for the parser.

Code

public function testParsingOfInformation() {

  // 2013-10-07 20:00:00 UTC
  $info = $this
    ->_getInfoAboutForecast(1381176000);

  // Check that the information has been parsed correctly.
  $this
    ->assertEqual($info->geoid, 'geonames_2911298');
  $this
    ->assertEqual($info->last_update, '2013-10-07 15:30:00');
  $this
    ->assertEqual($info->next_update, '2013-10-08 04:00:00');
  $this
    ->assertEqual($info->next_download_attempt, '2013-10-08 04:00:00');
  $this
    ->assertEqual($info->utc_offset, 120);

  // Set later times and check next download attempt.
  $info = $this
    ->_getInfoAboutForecast(1381204800);
  $this
    ->assertEqual($info->next_download_attempt, '2013-10-08 04:11:15');
  $info = $this
    ->_getInfoAboutForecast(1381205500);
  $this
    ->assertEqual($info->next_download_attempt, '2013-10-08 04:22:30');
  $info = $this
    ->_getInfoAboutForecast(1381215500);
  $this
    ->assertEqual($info->next_download_attempt, '2013-10-08 07:00:00');
  $info = $this
    ->_getInfoAboutForecast(1381247999);
  $this
    ->assertEqual($info->next_download_attempt, '2013-10-08 16:00:00');
  $info = $this
    ->_getInfoAboutForecast(1381248000);
  $this
    ->assertEqual($info->next_download_attempt, '2013-10-09 04:00:00');
  $info = $this
    ->_getInfoAboutForecast(1381248001);
  $this
    ->assertEqual($info->next_download_attempt, '2013-10-09 04:00:00');
  $info = $this
    ->_getInfoAboutForecast(1381291199);
  $this
    ->assertEqual($info->next_download_attempt, '2013-10-09 04:00:00');
  $info = $this
    ->_getInfoAboutForecast(1381291200);
  $this
    ->assertEqual($info->next_download_attempt, '2013-10-10 04:00:00');
  $info = $this
    ->_getInfoAboutForecast(1381291201);
  $this
    ->assertEqual($info->next_download_attempt, '2013-10-10 04:00:00');
  $info = $this
    ->_getInfoAboutForecast(1381294500);
  $this
    ->assertEqual($info->next_download_attempt, '2013-10-10 04:00:00');
  $info = $this
    ->_getInfoAboutForecast(1381380000);
  $this
    ->assertEqual($info->next_download_attempt, '2013-10-11 04:00:00');
}