Example #1
0
            $response = new Response(['format' => 'json', 'data' => ['hello' => 'world']]);
            $cookies = $response->headers->cookies;
            $cookies['foo'] = 'bar';
            $cookies['bin'] = 'baz';
            $cookies['foo'] = ['value' => 'bin', 'path' => '/foo'];
            $expected = <<<EOD
HTTP/1.1 200 OK
Content-Type: application/json
Content-Length: 17
Set-Cookie: foo=bar; Path=/
Set-Cookie: bin=baz; Path=/
Set-Cookie: foo=bin; Path=/foo

{"hello":"world"}
EOD;
            expect($response->toMessage())->toBe($expected);
        });
    });
    describe("->toString()", function () {
        it("casts the response as a string", function () {
            $response = new Response(['format' => 'json', 'data' => ['hello' => 'world']]);
            $cookies = $response->headers->cookies;
            $cookies['foo'] = 'bar';
            $cookies['bin'] = 'baz';
            $cookies['foo'] = ['value' => 'bin', 'path' => '/foo'];
            expect($response->toString())->toBe('{"hello":"world"}');
        });
    });
    describe("->__toString()", function () {
        it("echoes the response and populates headers", function () {
            $headers = [];