Completed
Push — master ( dadc12...75c176 )
by Christian
03:18 queued 01:17
created

CurrentWeatherGroupTest   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

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

5 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 5 1
A testRewind() 0 8 1
A testCurrent() 0 7 1
A testNext() 0 8 1
A testValid() 0 8 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
        $this->currentWeatherGroup->rewind();
35
        $position = $this->currentWeatherGroup->key();
36
37
        $this->assertSame($expectIndex, $position);
38
    }
39
40
    public function testCurrent()
41
    {
42
        $this->currentWeatherGroup->rewind();
43
        $current = $this->currentWeatherGroup->current();
44
45
        $this->assertInternalType('object', $current);
46
    }
47
    public function testNext()
48
    {
49
        $expectIndex = 1851632;
50
        $this->currentWeatherGroup->next();
51
        $position = $this->currentWeatherGroup->key();
52
53
        $this->assertSame($expectIndex, $position);
54
    }
55
56
    public function testValid()
57
    {
58
        $this->currentWeatherGroup->rewind();
59
        $this->currentWeatherGroup->next();
60
        $result = $this->currentWeatherGroup->valid();
61
62
        $this->assertTrue($result);
63
    }
64
}
65