Skip to content

Commit

Permalink
Requests have method and status
Browse files Browse the repository at this point in the history
  • Loading branch information
A5hleyRich committed Apr 6, 2024
1 parent 430b0cb commit 10f72f6
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 3 deletions.
10 changes: 10 additions & 0 deletions src/Request.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,16 @@ public function url(): string
return $this->request['request']['url'];
}

public function method(): string
{
return $this->request['request']['method'];
}

public function status(): string
{
return $this->request['response']['status'];
}

public function time(int $precision = 2): float
{
return round($this->request['time'], $precision);
Expand Down
6 changes: 3 additions & 3 deletions tests/Unit/HarTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
);
});

test('count total requests', function () {
test('total requests', function () {
expect($this->har->totalRequests())->toEqual(99);
});

Expand Down Expand Up @@ -57,13 +57,13 @@
expect($this->har->totalUncompressedSize())->toEqual(4896355);
});

test('get onContentLoad timing', function () {
test('onContentLoad timing', function () {
expect($this->har->onContentLoadTiming())->toEqual(580.40)
->and($this->har->onContentLoadTiming(0))->toEqual(580)
->and($this->har->onContentLoadTiming(3))->toEqual(580.401);
});

test('get onLoad timing', function () {
test('onLoad timing', function () {
expect($this->har->onLoadTiming())->toEqual(775.93)
->and($this->har->onLoadTiming(0))->toEqual(776)
->and($this->har->onLoadTiming(3))->toEqual(775.926);
Expand Down
8 changes: 8 additions & 0 deletions tests/Unit/RequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,14 @@
expect($this->request->url())->toEqual('https://github.com/');
});

test('request method', function () {
expect($this->request->method())->toEqual('GET');
});

test('request status', function () {
expect($this->request->status())->toEqual(200);
});

test('request time', function () {
expect($this->request->time())->toEqual(266.54)
->and($this->request->time(0))->toEqual(267)
Expand Down

0 comments on commit 10f72f6

Please sign in to comment.