Esempio n. 1
0
        });
    });
    describe("->headers()", function () {
        beforeEach(function () {
            $this->headers = <<<EOD
Custom-Header: Custom Value


EOD;
        });
        it("sets headers as a string", function () {
            $message = new Message(['headers' => $this->headers]);
            expect($message->headers->to('header'))->toBe($this->headers);
        });
        it("sets headers as an object", function () {
            $headers = new Headers();
            $headers->push($this->headers);
            $message = new Message(['headers' => $headers]);
            expect($message->headers->to('header'))->toBe($this->headers);
        });
    });
    describe("->set()", function () {
        it("endodes according to the Content-Type", function () {
            $message = new Message();
            $message->format("json");
            expect($message->set(""))->toBe($message);
            expect($message->body())->toBe('""');
            expect($message->set(['name' => 'value']))->toBe($message);
            expect($message->body())->toBe('{"name":"value"}');
        });
    });
Esempio n. 2
0
        it("clears headers", function () {
            $this->headers['Content-Type'] = 'text/plain';
            expect(isset($this->headers['Content-Type']))->toBe(true);
            $this->headers->clear();
            expect(isset($this->headers['Content-Type']))->toBe(false);
        });
    });
    describe("->__toString()", function () {
        it("casts in string", function () {
            $header = <<<EOD
Date: Thu, 25 Dec 2014 00:00:00 GMT
Content-Type: text/html; charset=UTF-8
Vary: Accept-Encoding, Cookie, User-Agent


EOD;
            $headers = new Headers();
            $headers->push($header);
            expect((string) $headers)->toBe($header);
        });
    });
    describe("->__clone", function () {
        it("clones headers", function () {
            $headers = new Headers();
            $headers['Content-Type'] = 'text/html';
            $new = clone $headers;
            expect($headers['Content-Type'])->not->toBe($new['Content-Type']);
            expect($headers['Content-Type']->value())->toBe($new['Content-Type']->value());
        });
    });
});