Esempio n. 1
0
use InvalidArgumentException;
use Lead\Net\Http\Psr7\Uri;
use Lead\Net\Http\Request;
describe("RequestTrait", function () {
    describe("->getMethod()", function () {
        it("delegates to `->method()`", function () {
            $request = new Request();
            expect($request)->toReceive('method');
            $request->getMethod();
        });
    });
    describe("->withMethod()", function () {
        it("creates a new request with the provided method", function () {
            $request = new Request();
            $new = $request->withMethod('POST');
            expect($request->getMethod())->toBe('GET');
            expect($new)->not->toBe($request);
            expect($new->getMethod())->toBe('POST');
        });
    });
    describe("->getRequestTarget()", function () {
        it("delegates to `->path()`", function () {
            $request = new Request();
            expect($request)->toReceive('requestTarget');
            $request->getRequestTarget();
        });
    });
    describe("->withRequestTarget()", function () {
        it("creates a new request with the provided request target url", function () {
            $request = new Request();
            $new = $request->withRequestTarget('https://www.domain.com:8000/foo?bar=baz#quz');