Completed
Push — master ( 2a0a89...468a99 )
by Christian
02:41
created

FileGetContentsFetcherTest::setUp()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 6
rs 9.4286
cc 2
eloc 3
nc 2
nop 0
1
<?php
2
/**
3
 * OpenWeatherMap-PHP-API — A php api to parse weather data from http://www.OpenWeatherMap.org .
4
 *
5
 * @license MIT
6
 *
7
 * Please see the LICENSE file distributed with this source code for further
8
 * information regarding copyright and licensing.
9
 *
10
 * Please visit the following links to read about the usage policies and the license of
11
 * OpenWeatherMap before using this class:
12
 *
13
 * @see http://www.OpenWeatherMap.org
14
 * @see http://www.OpenWeatherMap.org/terms
15
 * @see http://openweathermap.org/appid
16
 */
17
18
namespace Cmfcmf\OpenWeatherMap\Tests\Fetcher;
19
20
use \Cmfcmf\OpenWeatherMap\Fetcher\FileGetContentsFetcher;
21
22
class FileGetContentsFetcherTest extends \PHPUnit_Framework_TestCase
23
{
24
    protected function setUp()
25
    {
26
        if (!ini_get('allow_url_fopen')) {
27
            $this->markTestSkipped('"allow_url_fopen" is set to off.');
28
        }
29
    }
30
31
    /**
32
     * @expectedException \PHPUnit_Framework_Error_Warning
33
     */
34
    public function testInvalidUrl()
35
    {
36
        $fetcher = new FileGetContentsFetcher();
37
38
        $fetcher->fetch('http://notexisting.example.com');
39
    }
40
41
    /**
42
     * @expectedException \PHPUnit_Framework_Error_Warning
43
     */
44
    public function testEmptyUrl()
45
    {
46
        $fetcher = new FileGetContentsFetcher();
47
48
        $fetcher->fetch('');
49
    }
50
51
    public function testValidUrl()
52
    {
53
        $fetcher = new FileGetContentsFetcher();
54
55
        $content = $fetcher->fetch('http://httpbin.org/html');
56
57
        $this->assertContains('Herman Melville', $content);
58
    }
59
}
60