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\Util; |
16
|
|
|
|
17
|
|
|
use \Cmfcmf\OpenWeatherMap\Util\Weather; |
18
|
|
|
|
19
|
|
|
class WeatherTest extends \PHPUnit_Framework_TestCase |
20
|
|
|
{ |
21
|
|
|
/** |
22
|
|
|
* @var Weather |
23
|
|
|
*/ |
24
|
|
|
protected $weather; |
25
|
|
|
|
26
|
|
|
/** |
27
|
|
|
* @var string |
28
|
|
|
*/ |
29
|
|
|
protected $description = 'thunderstorm with light rain'; |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* @var string |
33
|
|
|
*/ |
34
|
|
|
protected $iconName = '11d'; |
35
|
|
|
|
36
|
|
|
protected function setUp() |
37
|
|
|
{ |
38
|
|
|
$this->weather = new Weather(200, $this->description, $this->iconName); |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
public function test__toString() |
42
|
|
|
{ |
43
|
|
|
$expectDescription = $this->description; |
44
|
|
|
$description = $this->weather->__toString(); |
45
|
|
|
|
46
|
|
|
$this->assertSame($expectDescription, $description); |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
public function testGetIconUrl() |
50
|
|
|
{ |
51
|
|
|
$expectIconLink = '//openweathermap.org/img/w/11d.png'; |
52
|
|
|
$weather = $this->weather; |
53
|
|
|
$iconLink = $weather->getIconUrl(); |
54
|
|
|
|
55
|
|
|
$this->assertSame($expectIconLink, $iconLink); |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
public function testSetIconUrlTemplate() |
59
|
|
|
{ |
60
|
|
|
$expectIconLink = '//openweathermap.org'; |
61
|
|
|
$weather = $this->weather; |
62
|
|
|
$weather::setIconUrlTemplate($expectIconLink); |
63
|
|
|
$resultLink = $weather->getIconUrl(); |
64
|
|
|
|
65
|
|
|
$this->assertSame($expectIconLink, $resultLink); |
66
|
|
|
} |
67
|
|
|
} |
68
|
|
|
|