Skip to content

Commit 051171b

Browse files
committed
refactor LogNonGetRequestsTest
1 parent ef41117 commit 051171b

File tree

1 file changed

+13
-26
lines changed

1 file changed

+13
-26
lines changed

tests/LogNonGetRequestsTest.php

Lines changed: 13 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -4,35 +4,22 @@
44

55
use Spatie\HttpLogger\LogNonGetRequests;
66

7-
class LogNonGetRequestsTest extends TestCase
8-
{
9-
/** @var \Spatie\HttpLogger\LogNonGetRequests */
10-
protected $logProfile;
7+
beforeEach(function () {
8+
$this->logProfile = new LogNonGetRequests();
9+
});
1110

12-
public function setUp(): void
13-
{
14-
parent::setup();
11+
test('it logs post patch put delete', function () {
12+
foreach (['post', 'put', 'patch', 'delete'] as $method) {
13+
$request = $this->makeRequest($method, $this->uri);
1514

16-
$this->logProfile = new LogNonGetRequests();
15+
$this->assertTrue($this->logProfile->shouldLogRequest($request), "{$method} should be logged.");
1716
}
17+
});
1818

19-
/** @test */
20-
public function it_logs_post_patch_put_delete()
21-
{
22-
foreach (['post', 'put', 'patch', 'delete'] as $method) {
23-
$request = $this->makeRequest($method, $this->uri);
19+
test('it doesnt log get head options trace', function () {
20+
foreach (['get', 'head', 'options', 'trace'] as $method) {
21+
$request = $this->makeRequest($method, $this->uri);
2422

25-
$this->assertTrue($this->logProfile->shouldLogRequest($request), "{$method} should be logged.");
26-
}
23+
$this->assertFalse($this->logProfile->shouldLogRequest($request), "{$method} should not be logged.");
2724
}
28-
29-
/** @test */
30-
public function it_doesnt_log_get_head_options_trace()
31-
{
32-
foreach (['get', 'head', 'options', 'trace'] as $method) {
33-
$request = $this->makeRequest($method, $this->uri);
34-
35-
$this->assertFalse($this->logProfile->shouldLogRequest($request), "{$method} should not be logged.");
36-
}
37-
}
38-
}
25+
});

0 commit comments

Comments
 (0)