浏览代码

Fix tests

Mark Scherer 10 年之前
父节点
当前提交
5d09de03c9
共有 1 个文件被更改,包括 17 次插入4 次删除
  1. 17 4
      Test/Case/Lib/WeatherLibTest.php

+ 17 - 4
Test/Case/Lib/WeatherLibTest.php

@@ -13,11 +13,16 @@ class WeatherLibTest extends MyCakeTestCase {
 	}
 
 	public function testUrl() {
-		$res = $this->Weather->_url('x.xml');
-		$this->assertEquals('http://api.worldweatheronline.com/free/v1/x.xml', $res);
+		$Weather = new ReflectionMethod('WeatherLib', '_url');
+		$Weather->setAccessible(true);
 
-		$res = $this->Weather->_url('x.xml', ['y' => 'z']);
-		$this->assertEquals('http://api.worldweatheronline.com/free/v1/x.xml?y=z', $res);
+		$res = $Weather->invoke($this->Weather, 'x.xml');
+		//$res = $this->Weather->_url('x.xml');
+		$this->assertEquals(WeatherLib::API_URL_FREE . 'x.xml', $res);
+
+		$res = $Weather->invoke($this->Weather, 'x.xml', ['y' => 'z']);
+		//$res = $this->Weather->_url('x.xml', ['y' => 'z']);
+		$this->assertEquals(WeatherLib::API_URL_FREE . 'x.xml?y=z', $res);
 	}
 
 	public function testWeatherConditions() {
@@ -27,9 +32,17 @@ class WeatherLibTest extends MyCakeTestCase {
 	}
 
 	public function testWeather() {
+		$res = $this->Weather->get('Berlin');
+		$this->debug($res);
+		$this->assertTrue(!empty($res));
+		$this->assertSame('City', $res['request']['type']);
+	}
+
+	public function testWeatherCoords() {
 		$res = $this->Weather->get('48.2,11.1');
 		$this->debug($res);
 		$this->assertTrue(!empty($res));
+		$this->assertSame('LatLon', $res['request']['type']);
 	}
 
 }