Passed
Push — master ( 23c0d6...0ebb81 )
by Darío
02:04
created

HttpTest::testGetStatusText()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 0
dl 0
loc 6
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * DronePHP (http://www.dronephp.com)
4
 *
5
 * @link      http://github.com/Pleets/DronePHP
6
 * @copyright Copyright (c) 2016-2018 Pleets. (http://www.pleets.org)
7
 * @license   http://www.dronephp.com/license
8
 * @author    Darío Rivera <[email protected]>
9
 */
10
11
namespace DroneTest\Network;
12
13
use Drone\Network\Http;
14
use PHPUnit\Framework\TestCase;
15
16
class HttpTest extends TestCase
17
{
18
    /**
19
     * Tests if we can write a HTTP status
20
     *
21
     * @return null
22
     */
23
    public function testWriteStatus()
24
    {
25
        $http = new Http();
26
        $header = $http->writeStatus($http::HTTP_NOT_FOUND);
27
28
        $this->assertEquals("HTTP/1.0 404 Not Found", $header);
29
    }
30
31
    /**
32
     * Tests gettting status text
33
     *
34
     * @return null
35
     */
36
    public function testGetStatusText()
37
    {
38
        $http = new Http();
39
        $text = $http->getStatusText($http::HTTP_NOT_FOUND);
40
41
        $this->assertEquals("Not Found", $text);
42
    }
43
44
    /**
45
     * Tests throwing exception on gettting status text
46
     *
47
     * @return null
48
     */
49
    public function testExceptionWhenStatusTextDoesNotExists()
50
    {
51
        $http = new Http();
52
53
        $errorObject = null;
54
        $message = "No exception";
55
56
        try
57
        {
58
            $text = $http->getStatusText(65431);
0 ignored issues
show
Unused Code introduced by
The assignment to $text is dead and can be removed.
Loading history...
59
        }
60
        catch (\Exception $e)
61
        {
62
            $errorObject = ($e instanceof \RuntimeException);
63
            $message = $e->getMessage();
64
        }
65
        finally
66
        {
67
            $this->assertTrue($errorObject, $message);
68
        }
69
    }
70
}
71