1<?php
2
3namespace Sabre\HTTP;
4
5class ResponseTest extends \PHPUnit_Framework_TestCase {
6
7    function testConstruct() {
8
9        $response = new Response(200, ['Content-Type' => 'text/xml']);
10        $this->assertEquals(200, $response->getStatus());
11        $this->assertEquals('OK', $response->getStatusText());
12
13    }
14
15    function testSetStatus() {
16
17        $response = new Response();
18        $response->setStatus('402 Where\'s my money?');
19        $this->assertEquals(402, $response->getStatus());
20        $this->assertEquals('Where\'s my money?', $response->getStatusText());
21
22    }
23
24    /**
25     * @expectedException InvalidArgumentException
26     */
27    function testInvalidStatus() {
28
29        $response = new Response(1000);
30
31    }
32
33    function testToString() {
34
35        $response = new Response(200, ['Content-Type' => 'text/xml']);
36        $response->setBody('foo');
37
38        $expected = <<<HI
39HTTP/1.1 200 OK\r
40Content-Type: text/xml\r
41\r
42foo
43HI;
44        $this->assertEquals($expected, (string)$response);
45
46    }
47
48}
49