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 | $text = $http->getStatusText(65431); |
||
0 ignored issues
–
show
Unused Code
introduced
by
![]() |
|||
58 | } catch (\Exception $e) { |
||
59 | $errorObject = ($e instanceof \RuntimeException); |
||
60 | $message = $e->getMessage(); |
||
61 | } finally { |
||
62 | $this->assertTrue($errorObject, $message); |
||
63 | } |
||
64 | } |
||
65 | } |
||
66 |