Browse Source

fix tests

euromark 12 years ago
parent
commit
d84b9be717
2 changed files with 21 additions and 26 deletions
  1. 4 1
      Test/Case/Lib/WeatherLibTest.php
  2. 17 25
      Test/Case/View/Helper/WeatherHelperTest.php

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

@@ -5,7 +5,10 @@ App::uses('MyCakeTestCase', 'Tools.TestSuite');
 class WeatherLibTest extends MyCakeTestCase {
 
 	public function setUp() {
-		Configure::write('Weather.key', '598dfbdaeb121715111208');
+		parent::setUp();
+		if (!Configure::read('Weather.key')) {
+			Configure::write('Weather.key', '598dfbdaeb121715111208');
+		}
 
 		App::uses('WeatherLib', 'Tools.Lib');
 		$this->Weather = new WeatherLib();

+ 17 - 25
Test/Case/View/Helper/WeatherHelperTest.php

@@ -3,16 +3,19 @@
 App::uses('WeatherHelper', 'Tools.View/Helper');
 App::uses('HtmlHelper', 'View/Helper');
 App::uses('View', 'View');
+App::uses('MyCakeTestCase', 'Tools.TestSuite');
 
 /**
  * 2010-06-24 ms
  */
-class WeatherHelperTest extends CakeTestCase {
+class WeatherHelperTest extends MyCakeTestCase {
 
-/**
- * setUp method
- */
 	public function setUp() {
+		parent::setUp();
+		if (!Configure::read('Weather.key')) {
+		Configure::write('Weather.key', '598dfbdaeb121715111208');
+		}
+
 		$this->Weather = new WeatherHelper(new View(null));
 		$this->Weather->Html = new HtmlHelper(new View(null));
 	}
@@ -20,46 +23,35 @@ class WeatherHelperTest extends CakeTestCase {
 	/** TODO **/
 
 	public function testDisplay() {
-
 		$res = $this->Weather->get('51.0872,13.8028');
-		$res = $this->_display($res);
-		pr($res);
+		$res = $this->_displayForecast($res);
+		$this->out($res);
 		$this->assertTrue(!empty($res));
 
-		echo BR.BR;
-
-
 		$res = $this->Weather->get('Berlin, Deutschland');
-		$res = $this->_display($res);
-		pr($res);
+		$res = $this->_displayForecast($res);
+		$this->out($res);
 		$this->assertTrue(!empty($res));
 
-		echo BR.BR;
-
 		$res = $this->Weather->get('Schwäbisch Hall, Deutschland');
-		$res = $this->_display($res);
-		pr($res);
+		$res = $this->_displayForecast($res);
+		$this->out($res);
 		$this->assertTrue(!empty($res));
 
 		$res = $this->Weather->get('xxxxx');
-		$res = $this->_display($res);
-		pr($res);
+		$res = $this->_displayForecast($res);
 		$this->assertTrue(empty($res));
-
-		echo BR.BR;
-
 	}
 
-
-	public function _display($w) {
+	public function _displayForecast($w) {
 		$res = '';
-		if (empty($w['Request'])) {
+		if (empty($w['request'])) {
 			return $res;
 		}
 
 		$res .= '<table><tr>';
 		for ($i = 2; $i < 5; $i++) {
-			$weather = $w['Weather'][$i];
+			$weather = $w['weather'][$i];
 
 			$res .= '<td>';
 			$res .= '<h1>'.date('D', strtotime($weather['date'])).'</h1>';