Example #1
0
         expect($request->requestTarget())->toBe('/?param=value&param1=value1');
     });
 });
 describe("->auth()", function () {
     it("sets a basic Authorization header", function () {
         $request = new Request(['username' => 'Willy', 'password' => 'Boy', 'auth' => 'Basic']);
         expect((string) $request->headers['Authorization'])->toBe('Authorization: Basic V2lsbHk6Qm95');
     });
     it("sets a digest Authorization header", function () {
         $request = new Request(['username' => 'Willy', 'password' => 'Boy', 'auth' => ['realm' => 'app', 'qop' => 'auth', 'nonce' => '4bca0fbca7bd0', 'opaque' => 'd3fb67a7aa4d887ec4bf83040a820a46']]);
         expect((string) $request->headers['Authorization'])->toMatch('~^Authorization: Digest~');
     });
     it("removes a setted Authorization", function () {
         $request = new Request(['username' => 'Willy', 'password' => 'Boy', 'auth' => 'Basic']);
         expect((string) $request->headers['Authorization'])->toBe('Authorization: Basic V2lsbHk6Qm95');
         $request->auth(false);
         expect(isset($request->headers['Authorization']))->toBe(false);
     });
 });
 context("through ->headers()", function () {
     beforeEach(function () {
         $this->request = new Request();
         $this->headers = $this->request->headers;
     });
     it("sets Cookie value", function () {
         $this->headers['Cookie'] = 'foo1=bar1; foo2=bar2; foo3=bar3';
         expect($this->headers->cookies->to('header'))->toBe("Cookie: foo1=bar1; foo2=bar2; foo3=bar3");
     });
     it("sets Cookie value with same cookie names", function () {
         $this->headers['Cookie'] = 'foo1=bar1; foo1=bar2; foo1=bar3';
         expect($this->headers->cookies->to('header'))->toBe("Cookie: foo1=bar1; foo1=bar2; foo1=bar3");