You are here

public function WeatherConfigurationTestCase::testConfiguration in Weather 7.3

Same name and namespace in other branches
  1. 7.2 tests/configuration.test \WeatherConfigurationTestCase::testConfiguration()

Tests configuration of weather block.

File

tests/configuration.test, line 50
Test configuration of weather displays.

Class

WeatherConfigurationTestCase
Test class for configuration.

Code

public function testConfiguration() {

  // Set a fixed time for testing to 2013-10-07 20:00:00 UTC.
  variable_set('weather_time_for_testing', 1381176000);

  // This user may setup a system-wide weather block.
  $admin_user = $this
    ->drupalCreateUser(array(
    'access content',
    'administer custom weather block',
    'administer system-wide weather',
    'administer blocks',
  ));

  // Test with admin user.
  $this
    ->drupalLogin($admin_user);

  // Enable a system-wide weather block.
  $this
    ->drupalPost('admin/config/user-interface/weather/system-wide/add', array(), t('Save'));

  // Configure the default place.
  $this
    ->drupalPost('admin/config/user-interface/weather/system-wide/1/add', array(), t('Save'));

  // Enable block.
  $edit = array(
    'blocks[weather_system_1][region]' => 'sidebar_second',
  );
  $this
    ->drupalPost('admin/structure/block', $edit, t('Save blocks'));

  // Make sure that the weather block is displayed with correct test forecast data.
  $this
    ->drupalGet('node');
  $this
    ->assertRaw('<div class="weather">');
  $this
    ->assertLink('Hamburg');
  $this
    ->assertLinkByHref('weather/Germany/Hamburg/Hamburg/1');
  $this
    ->assertText('23:00-00:00');
  $this
    ->assertText(t('Clear sky'));
  $this
    ->assertRaw('9&thinsp;°C');
  $this
    ->assertText('12:00-18:00');
  $this
    ->assertText(t('Fair'));
  $this
    ->assertRaw('13&thinsp;°C');

  // Change temperature units to Fahrenheit.
  $edit = array(
    'config[temperature]' => 'fahrenheit',
  );
  $this
    ->drupalPost('admin/config/user-interface/weather/system-wide/1', $edit, t('Save'));

  // Make sure that the weather block now shows different temperatures.
  $this
    ->drupalGet('node');
  $this
    ->assertRaw('48&thinsp;°F');
  $this
    ->assertRaw('55&thinsp;°F');

  // Logout current user.
  $this
    ->drupalLogout();
}