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

WeatherForecastTest   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 54
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

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

5 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 5 1
A testRewind() 0 9 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\Tests\FakeData;
18
use \Cmfcmf\OpenWeatherMap\WeatherForecast;
19
20
class WeatherForecastTest extends \PHPUnit_Framework_TestCase
21
{
22
    /**
23
     * @var string
24
     */
25
    protected $fakeXml;
26
27
    /**
28
     * @var WeatherForecast
29
     */
30
    protected $forecast;
31
32
    protected function setUp()
33
    {
34
        $this->fakeXml = new \SimpleXMLElement(FakeData::forecastXML());
0 ignored issues
show
Documentation Bug introduced by
It seems like new \SimpleXMLElement(\C...akeData::forecastXML()) of type object<SimpleXMLElement> is incompatible with the declared type string of property $fakeXml.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
35
        $this->forecast = new WeatherForecast($this->fakeXml, 'Berlin', 2);
36
    }
37
38
    public function testRewind()
39
    {
40
        $forecast = new WeatherForecast($this->fakeXml, 'metric', 2);
41
        $expectIndex = 0;
42
        $forecast->rewind();
43
        $position = $forecast->key();
44
45
        $this->assertSame($expectIndex, $position);
46
    }
47
48
    public function testCurrent()
49
    {
50
        $this->forecast->rewind();
51
        $current = $this->forecast->current();
52
53
        $this->assertInternalType('object', $current);
54
    }
55
56
    public function testNext()
57
    {
58
        $this->forecast->rewind();
59
        $this->forecast->next();
60
        $result = $this->forecast->valid();
61
62
        $this->assertFalse($result);
63
    }
64
65
    public function testValid()
66
    {
67
        $this->forecast->rewind();
68
        $this->forecast->next();
69
        $result = $this->forecast->valid();
70
71
        $this->assertFalse($result);
72
    }
73
}
74