Skip to content

Commit 28ee5c0

Browse files
committed
add Vapor test
1 parent 18a5721 commit 28ee5c0

File tree

1 file changed

+12
-17
lines changed

1 file changed

+12
-17
lines changed

tests/ResponseCompressionTest.php

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -28,20 +28,6 @@ protected function setUp(): void
2828
]);
2929
})->middleware(ResponseCompression::class);
3030
}
31-
32-
public function testList()
33-
{
34-
$this->withoutExceptionHandling();
35-
36-
$response = $this->get('/light', ['Accept-Encoding' => CompressionEncoding::Gzip->value]);
37-
38-
$response->assertHeaderMissing('Content-Encoding');
39-
40-
$this->assertEquals(
41-
$response->json(),
42-
['content' => $this->lightResponseContent]
43-
);
44-
}
4531

4632
public function testClientGetRawResponseWhenThresholdNotReached()
4733
{
@@ -84,15 +70,24 @@ public function testClientGetResponseCompressedWhenThresholdReached()
8470
json_encode(['content' => $this->heavyResponseContent])
8571
);
8672
}
73+
74+
public function testClientGetResponseWithVaporHeaderWhenWithinVapor()
75+
{
76+
putenv('VAPOR_SSM_PATH=1');
77+
78+
$response = $this->get('/heavy', ['Accept-Encoding' => CompressionEncoding::Deflate->value]);
79+
80+
$response->assertHeader('X-Vapor-Base64-Encode', 'True');
81+
}
8782

8883
public function testClientGetResponseInThePreferredEncoding()
8984
{
90-
$response = $this->get('/heavy', ['Accept-Encoding' => CompressionEncoding::Deflate->value]);
85+
$response = $this->get('/heavy', ['Accept-Encoding' => implode(', ', [CompressionEncoding::Gzip->value, CompressionEncoding::Deflate->value])]);
9186

92-
$response->assertHeader('Content-Encoding', CompressionEncoding::Deflate->value);
87+
$response->assertHeader('Content-Encoding', CompressionEncoding::Gzip->value);
9388

9489
$this->assertEquals(
95-
gzinflate($response->getContent()),
90+
gzdecode($response->getContent()),
9691
json_encode(['content' => $this->heavyResponseContent])
9792
);
9893
}

0 commit comments

Comments
 (0)