Completed
Push — peter279k-master ( fcaf21 )
by Christian
13:01
created

CurrentWeatherGroupTest::testCurrent()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
rs 9.4285
c 0
b 0
f 0
nc 1
cc 1
eloc 5
nop 0
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
19
class CurrentWeatherGroupTest extends \PHPUnit_Framework_TestCase
20
{
21
    protected $fakeJson;
22
    protected $currentWeatherGroup;
23
24
    public function setUp()
25
    {
26
        $this->fakeJson = '{
27
            "list":[{
28
                "id":1851632,
29
                "dt":1406106000,
30
                "coord":{"lon":138.933334,"lat":34.966671},
31
                "sys":{"type":3,"id":168940,"message":0.0297,"country":"US","sunrise":1427723751,"sunset":1427768967},
32
                "name":"Shuzenji",
33
                "main":{
34
                    "temp":298.77,
35
                    "temp_min":298.77,
36
                    "temp_max":298.774,
37
                    "pressure":1005.93,
38
                    "sea_level":1018.18,
39
                    "grnd_level":1005.93,
40
                    "humidity":87
41
                },
42
                "weather":[{"id":804,"main":"Clouds","description":"overcast clouds","icon":"04d"}],
43
                "clouds":{"all":88},
44
                "wind":{"speed":5.71,"deg":229.501},
45
                "dt_txt":"2014-07-23 09:00:00"
46
            },{
47
                "id":1851632,
48
                "dt":1406106000,
49
                "coord":{"lon":138.933334,"lat":34.966671},
50
                "sys":{"type":3,"id":168940,"message":0.0297,"country":"US","sunrise":1427723751,"sunset":1427768967},
51
                "name":"Shuzenji",
52
                "main":{
53
                    "temp":298.77,
54
                    "temp_min":298.77,
55
                    "temp_max":298.774,
56
                    "pressure":1005.93,
57
                    "sea_level":1018.18,
58
                    "grnd_level":1005.93,
59
                    "humidity":87
60
                },
61
                "weather":[{"id":804,"main":"Clouds","description":"overcast clouds","icon":"04d"}],
62
                "clouds":{"all":88},
63
                "wind":{"speed":5.71,"deg":229.501},
64
                "dt_txt":"2014-07-23 09:00:00"
65
            }]
66
        }';
67
        $this->fakeJson = json_decode($this->fakeJson);
68
        $this->currentWeatherGroup = new CurrentWeatherGroup($this->fakeJson, 'metric');
69
    }
70
71 View Code Duplication
    public function testRewind()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
72
    {
73
        $expectIndex = 1851632;
74
        $currentWeatherGroup = $this->currentWeatherGroup;
75
        $currentWeatherGroup->rewind();
76
        $position = $currentWeatherGroup->key();
77
78
        $this->assertSame($expectIndex, $position);
79
    }
80
81
    public function testCurrent()
82
    {
83
        $currentWeatherGroup = $this->currentWeatherGroup;
84
        $currentWeatherGroup->rewind();
85
        $current = $currentWeatherGroup->current();
86
87
        $this->assertInternalType('object', $current);
88
    }
89 View Code Duplication
    public function testNext()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
90
    {
91
        $expectIndex = 1851632;
92
        $currentWeatherGroup = $this->currentWeatherGroup;
93
        $currentWeatherGroup->next();
94
        $position = $currentWeatherGroup->key();
95
96
        $this->assertSame($expectIndex, $position);
97
    }
98
99
    public function testValid()
100
    {
101
        $currentWeatherGroup = $this->currentWeatherGroup;
102
        $currentWeatherGroup->rewind();
103
        $currentWeatherGroup->next();
104
        $result = $currentWeatherGroup->valid();
105
106
        $this->assertTrue($result);
107
    }
108
}
109