WeatherLibTest.php 857 B

1234567891011121314151617181920212223242526272829303132333435
  1. <?php
  2. App::uses('WeatherLib', 'Tools.Lib');
  3. App::uses('MyCakeTestCase', 'Tools.TestSuite');
  4. class WeatherLibTest extends MyCakeTestCase {
  5. public function setUp() {
  6. parent::setUp();
  7. $this->Weather = new WeatherLib();
  8. $this->skipIf(!Configure::read('Weather.key'));
  9. }
  10. public function testUrl() {
  11. $res = $this->Weather->_url('x.xml');
  12. $this->assertEquals('http://api.worldweatheronline.com/free/v1/x.xml', $res);
  13. $res = $this->Weather->_url('x.xml', array('y' => 'z'));
  14. $this->assertEquals('http://api.worldweatheronline.com/free/v1/x.xml?y=z', $res);
  15. }
  16. public function testWeatherConditions() {
  17. $res = $this->Weather->conditions();
  18. $this->debug($res);
  19. $this->assertTrue(empty($res));
  20. }
  21. public function testWeather() {
  22. $res = $this->Weather->get('48.2,11.1');
  23. $this->debug($res);
  24. $this->assertTrue(!empty($res));
  25. }
  26. }