You are here

private function ParserTest::getInfoAboutForecast in Weather 2.0.x

Same name and namespace in other branches
  1. 8 tests/src/Functional/ParserTest.php \Drupal\Tests\weather\Functional\ParserTest::getInfoAboutForecast()

Internal helper function for getting information about a forecast.

1 call to ParserTest::getInfoAboutForecast()
ParserTest::testParsingOfInformation in tests/src/Functional/ParserTest.php
Test parsing of information about a forecast.

File

tests/src/Functional/ParserTest.php, line 487

Class

ParserTest
Tests parsing of XML weather forecasts.

Namespace

Drupal\Tests\weather\Functional

Code

private function getInfoAboutForecast($time) {

  // Set the testing time.
  $config = \Drupal::configFactory()
    ->getEditable('weather.settings');
  $config
    ->set('weather_time_for_testing', $time)
    ->save();

  // Fetch weather forecasts for Hamburg.
  $this
    ->weatherGetWeather('geonames_2911298', 1, FALSE);

  // Return the parsed information.
  $connection = \Drupal::database();
  $query = $connection
    ->select('weather_forecast_information', 'wfi');
  $query
    ->condition('wfi.geoid', 'geonames_2911298', '=');
  $query
    ->fields('wfi', [
    'geoid',
    'last_update',
    'next_update',
    'next_download_attempt',
    'utc_offset',
  ]);
  $query
    ->range(0, 50);
  $result = $query
    ->execute();
  return $result
    ->fetch();
}