Completed
Push — peter279k-master ( fcaf21...a307a7 )
by Christian
43:15 queued 28:09
created

CurrentWeatherGroupTest   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 49
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 5
c 0
b 0
f 0
lcom 1
cbo 2
dl 0
loc 49
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 5 1
A testRewind() 0 9 1
A testCurrent() 0 8 1
A testNext() 0 9 1
A testValid() 0 9 1
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