aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/sabre/dav/tests/Sabre/HTTP/ResponseTest.php
blob: f5302c993b9be1778ec6b1adc5be88c6fceb47ec (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
<?php

namespace Sabre\HTTP;

require_once 'Sabre/HTTP/ResponseMock.php';

class ResponseTest extends \PHPUnit_Framework_TestCase {

    /**
     * @var Sabre\HTTP\ResponseMock
     */
    private $response;

    function setUp() {

        $this->response = new ResponseMock();

    }

    function testGetStatusMessage() {

        $msg = $this->response->getStatusMessage(200);
        $this->assertEquals('HTTP/1.1 200 OK',$msg);

    }

    function testSetHeader() {

        $this->response->setHeader('Content-Type','text/html');
        $this->assertEquals('text/html', $this->response->headers['Content-Type']);


    }
    function testSetHeaders() {

        $this->response->setHeaders(array('Content-Type'=>'text/html'));
        $this->assertEquals('text/html', $this->response->headers['Content-Type']);


    }

    function testSendStatus() {

        $this->response->sendStatus(404);
        $this->assertEquals('HTTP/1.1 404 Not Found', $this->response->status);

    }

    function testSendBody() {

        ob_start();
        $response = new Response();
        $response->sendBody('hello');
        $this->assertEquals('hello',ob_get_clean());

    }

    function testSendBodyStream() {

        ob_start();
        $stream = fopen('php://memory','r+');
        fwrite($stream,'hello');
        rewind($stream);
        $response = new Response();
        $response->sendBody($stream);
        $this->assertEquals('hello',ob_get_clean());

    }

}