1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Copyright Zikula Foundation 2014 - Zikula Application Framework |
4
|
|
|
* |
5
|
|
|
* This work is contributed to the Zikula Foundation under one or more |
6
|
|
|
* Contributor Agreements and licensed to You under the following license: |
7
|
|
|
* |
8
|
|
|
* @license GNU/LGPv3 (or at your option any later version). |
9
|
|
|
* @package OpenWeatherMap-PHP-Api |
10
|
|
|
* |
11
|
|
|
* Please see the NOTICE file distributed with this source code for further |
12
|
|
|
* information regarding copyright and licensing. |
13
|
|
|
*/ |
14
|
|
|
|
15
|
|
|
namespace Cmfcmf\OpenWeatherMap\Tests\OpenWeatherMap; |
16
|
|
|
|
17
|
|
|
use Cmfcmf\OpenWeatherMap\Tests\FakeData; |
18
|
|
|
use \Cmfcmf\OpenWeatherMap\WeatherForecast; |
19
|
|
|
|
20
|
|
|
class WeatherForecastTest extends \PHPUnit_Framework_TestCase |
21
|
|
|
{ |
22
|
|
|
/** |
23
|
|
|
* @var string |
24
|
|
|
*/ |
25
|
|
|
protected $fakeXml; |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* @var WeatherForecast |
29
|
|
|
*/ |
30
|
|
|
protected $forecast; |
31
|
|
|
|
32
|
|
|
protected function setUp() |
33
|
|
|
{ |
34
|
|
|
$this->fakeXml = new \SimpleXMLElement(FakeData::forecastXML()); |
|
|
|
|
35
|
|
|
$this->forecast = new WeatherForecast($this->fakeXml, 'Berlin', 2); |
36
|
|
|
} |
37
|
|
|
|
38
|
|
|
public function testRewind() |
39
|
|
|
{ |
40
|
|
|
$forecast = new WeatherForecast($this->fakeXml, 'metric', 2); |
41
|
|
|
$expectIndex = 0; |
42
|
|
|
$forecast->rewind(); |
43
|
|
|
$position = $forecast->key(); |
44
|
|
|
|
45
|
|
|
$this->assertSame($expectIndex, $position); |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
public function testCurrent() |
49
|
|
|
{ |
50
|
|
|
$forecast = $this->forecast; |
51
|
|
|
$forecast->rewind(); |
52
|
|
|
$current = $forecast->current(); |
53
|
|
|
|
54
|
|
|
$this->assertInternalType('object', $current); |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
public function testNext() |
58
|
|
|
{ |
59
|
|
|
$forecast = $this->forecast; |
60
|
|
|
$forecast->rewind(); |
61
|
|
|
$forecast->next(); |
62
|
|
|
$result = $forecast->valid(); |
63
|
|
|
|
64
|
|
|
$this->assertFalse($result); |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
public function testValid() |
68
|
|
|
{ |
69
|
|
|
$forecast = $this->forecast; |
70
|
|
|
$forecast->rewind(); |
71
|
|
|
$forecast->next(); |
72
|
|
|
$result = $forecast->valid(); |
73
|
|
|
|
74
|
|
|
$this->assertFalse($result); |
75
|
|
|
} |
76
|
|
|
} |
77
|
|
|
|
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..