Completed
Pull Request — master (#96)
by Christian
06:33 queued 04:32
created

CurrentWeatherGroupTest::setUp()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 5
rs 9.4285
cc 1
eloc 3
nc 1
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
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