You are here

public function FunctionsTest::testFunctionWeatherGetLinkForGeoId in Weather 2.0.x

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

Test _weather_get_link_for_geoid().

Throws

\ReflectionException

File

tests/src/Functional/FunctionsTest.php, line 35

Class

FunctionsTest
Tests functions of weather.module.

Namespace

Drupal\Tests\weather\Functional

Code

public function testFunctionWeatherGetLinkForGeoId() {

  // Fill database tables with test data.
  $this
    ->weatherFillWeatherSchema();

  // Test different numbers for system-wide displays.
  $link = $this
    ->weatherGetInformationAboutGeoid('geonames_2911298')['link'];
  $this
    ->assertEquals('Hamburg/Hamburg', $link);

  // Test different numbers for yr.no links.
  $link = $this
    ->weatherGetLinkForGeoId('geonames_2911298', 'yr.no');
  $this
    ->assertEquals('https://www.yr.no/place/Germany/Hamburg/Hamburg/', $link);
  $link = $this
    ->weatherGetLinkForGeoId('geonames_2911298', 'system-wide');
  $this
    ->assertEquals('weather/Germany/Hamburg/Hamburg/1', $link);
  $link = $this
    ->weatherGetLinkForGeoId('geonames_2911298', 'default');
  $this
    ->assertEquals('weather/Germany/Hamburg/Hamburg', $link);
  $link = $this
    ->weatherGetLinkForGeoId('geonames_2911298', 'user');
  $this
    ->assertEquals('weather/Germany/Hamburg/Hamburg/u', $link);
  $link = $this
    ->weatherGetLinkForGeoId('geonames_2911298', 'yr');
  $this
    ->assertEquals('https://www.yr.no/place/Germany/Hamburg/Hamburg/forecast.xml', $link);
}