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

WeatherForecastTest::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\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
        $forecast = $this->forecast;
51
        $forecast->rewind();
52
        $current = $forecast->current();
53
54
        $this->assertInternalType('object', $current);
55
    }
56
57
    public function testNext()
58
    {
59
        $forecast = $this->forecast;
60
        $forecast->rewind();
61
        $forecast->next();
62
        $result = $forecast->valid();
63
64
        $this->assertFalse($result);
65
    }
66
67
    public function testValid()
68
    {
69
        $forecast = $this->forecast;
70
        $forecast->rewind();
71
        $forecast->next();
72
        $result = $forecast->valid();
73
74
        $this->assertFalse($result);
75
    }
76
}
77