|
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\CurrentWeatherGroup; |
|
18
|
|
|
use Cmfcmf\OpenWeatherMap\Tests\FakeData; |
|
19
|
|
|
|
|
20
|
|
|
class CurrentWeatherGroupTest extends \PHPUnit_Framework_TestCase |
|
21
|
|
|
{ |
|
22
|
|
|
protected $fakeJson; |
|
23
|
|
|
protected $currentWeatherGroup; |
|
24
|
|
|
|
|
25
|
|
|
public function setUp() |
|
26
|
|
|
{ |
|
27
|
|
|
$this->fakeJson = json_decode(FakeData::WEATHER_GROUP_JSON); |
|
28
|
|
|
$this->currentWeatherGroup = new CurrentWeatherGroup($this->fakeJson, 'metric'); |
|
29
|
|
|
} |
|
30
|
|
|
|
|
31
|
|
|
public function testRewind() |
|
32
|
|
|
{ |
|
33
|
|
|
$expectIndex = 1851632; |
|
34
|
|
|
$currentWeatherGroup = $this->currentWeatherGroup; |
|
35
|
|
|
$currentWeatherGroup->rewind(); |
|
36
|
|
|
$position = $currentWeatherGroup->key(); |
|
37
|
|
|
|
|
38
|
|
|
$this->assertSame($expectIndex, $position); |
|
39
|
|
|
} |
|
40
|
|
|
|
|
41
|
|
|
public function testCurrent() |
|
42
|
|
|
{ |
|
43
|
|
|
$currentWeatherGroup = $this->currentWeatherGroup; |
|
44
|
|
|
$currentWeatherGroup->rewind(); |
|
45
|
|
|
$current = $currentWeatherGroup->current(); |
|
46
|
|
|
|
|
47
|
|
|
$this->assertInternalType('object', $current); |
|
48
|
|
|
} |
|
49
|
|
|
public function testNext() |
|
50
|
|
|
{ |
|
51
|
|
|
$expectIndex = 1851632; |
|
52
|
|
|
$currentWeatherGroup = $this->currentWeatherGroup; |
|
53
|
|
|
$currentWeatherGroup->next(); |
|
54
|
|
|
$position = $currentWeatherGroup->key(); |
|
55
|
|
|
|
|
56
|
|
|
$this->assertSame($expectIndex, $position); |
|
57
|
|
|
} |
|
58
|
|
|
|
|
59
|
|
|
public function testValid() |
|
60
|
|
|
{ |
|
61
|
|
|
$currentWeatherGroup = $this->currentWeatherGroup; |
|
62
|
|
|
$currentWeatherGroup->rewind(); |
|
63
|
|
|
$currentWeatherGroup->next(); |
|
64
|
|
|
$result = $currentWeatherGroup->valid(); |
|
65
|
|
|
|
|
66
|
|
|
$this->assertTrue($result); |
|
67
|
|
|
} |
|
68
|
|
|
} |
|
69
|
|
|
|