WeatherLibTest.php 944 B

12345678910111213141516171819202122232425262728293031323334353637
  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. if (!Configure::read('Weather.key')) {
  8. Configure::write('Weather.key', '598dfbdaeb121715111208');
  9. }
  10. App::uses('WeatherLib', 'Tools.Lib');
  11. $this->Weather = new WeatherLib();
  12. }
  13. public function testUrl() {
  14. $res = $this->Weather->_url('x.xml');
  15. $this->assertEquals('http://free.worldweatheronline.com/feed/x.xml', $res);
  16. $res = $this->Weather->_url('x.xml', array('y'=>'z'));
  17. $this->assertEquals('http://free.worldweatheronline.com/feed/x.xml?y=z', $res);
  18. }
  19. public function testWeatherConditions() {
  20. $res = $this->Weather->conditions();
  21. $this->out($res);
  22. $this->assertTrue(!empty($res));
  23. }
  24. public function testWeather() {
  25. $res = $this->Weather->get('48.2,11.1');
  26. $this->out($res);
  27. $this->assertTrue(!empty($res));
  28. }
  29. }