You are here

weather_es.test in Weather_es 7

Tests parsing of raw XML AEMET data.

Copyright (C) 2008-2013 José Mª Sirvent <drupal@hykrion.com>

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA

File

weather_es.test
View source
<?php

/**
 * @file
 * Tests parsing of raw XML AEMET data.
 *
 * Copyright (C) 2008-2013 José Mª Sirvent <drupal@hykrion.com>
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 */
class WeatherEsParserTestCase extends DrupalWebTestCase {
  public static function getInfo() {
    return array(
      'name' => 'Weather_es blocks and parser tests',
      'description' => 'Test the Weather_es blocks and XML parser for the AEMET data.',
      'group' => 'Weather_es',
    );
  }
  function setUp() {
    parent::setUp('weather_es');
    module_load_include('inc', 'weather_es', 'weather_es');
  }

  /**
   * Test creating a Weather_es block
   */
  function testBlockInfo() {
    $info = module_invoke('weather_es', 'block_info');
    $this
      ->assertEqual(2, count($info), t('Module defines two blocks: system and user blocks.'));
    $this
      ->assertTrue(isset($info['system']), t('Weather_es system block exists.'));
    $this
      ->assertTrue(isset($info['user']), t('Weather_es user block exists.'));
  }

  /**
   * Test the XML parser for AEMET data
   */
  function testParser() {

    // Try to load the Jijona/Xixona weather data
    $aemet = new weather_es_Aemet('03083');
    $this
      ->assertTrue($aemet
      ->isLoadOk(), t('Data loaded ok'));
    $this
      ->assertTrue(is_array($aemet
      ->getInfo()), t('Data loaded is an array'));
  }

}

Classes

Namesort descending Description
WeatherEsParserTestCase @file Tests parsing of raw XML AEMET data.