|
4 | 4 |
|
5 | 5 | use Spatie\HttpLogger\LogNonGetRequests;
|
6 | 6 |
|
7 |
| -class LogNonGetRequestsTest extends TestCase |
8 |
| -{ |
9 |
| - /** @var \Spatie\HttpLogger\LogNonGetRequests */ |
10 |
| - protected $logProfile; |
| 7 | +beforeEach(function () { |
| 8 | + $this->logProfile = new LogNonGetRequests(); |
| 9 | +}); |
11 | 10 |
|
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); |
15 | 14 |
|
16 |
| - $this->logProfile = new LogNonGetRequests(); |
| 15 | + $this->assertTrue($this->logProfile->shouldLogRequest($request), "{$method} should be logged."); |
17 | 16 | }
|
| 17 | +}); |
18 | 18 |
|
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); |
24 | 22 |
|
25 |
| - $this->assertTrue($this->logProfile->shouldLogRequest($request), "{$method} should be logged."); |
26 |
| - } |
| 23 | + $this->assertFalse($this->logProfile->shouldLogRequest($request), "{$method} should not be logged."); |
27 | 24 | }
|
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