@@ -29,11 +29,25 @@ protected function setUp(): void
2929 })->middleware (ResponseCompression::class);
3030 }
3131
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+ }
45+
3246 public function testClientGetRawResponseWhenThresholdNotReached ()
3347 {
3448 $ this ->withoutExceptionHandling ();
3549
36- $ response = $ this ->get ('/light ' , ['Accept-Encoding ' => CompressionEncoding::GZIP ]);
50+ $ response = $ this ->get ('/light ' , ['Accept-Encoding ' => CompressionEncoding::Gzip-> value ]);
3751
3852 $ response ->assertHeaderMissing ('Content-Encoding ' );
3953
@@ -49,7 +63,7 @@ public function testClientGetRawResponseWhenNotEnabled()
4963
5064 $ this ->withoutExceptionHandling ();
5165
52- $ response = $ this ->get ('/heavy ' , ['Accept-Encoding ' => CompressionEncoding::GZIP ]);
66+ $ response = $ this ->get ('/heavy ' , ['Accept-Encoding ' => CompressionEncoding::Gzip-> value ]);
5367
5468 $ response ->assertHeaderMissing ('Content-Encoding ' );
5569
@@ -61,9 +75,9 @@ public function testClientGetRawResponseWhenNotEnabled()
6175
6276 public function testClientGetResponseCompressedWhenThresholdReached ()
6377 {
64- $ response = $ this ->get ('/heavy ' , ['Accept-Encoding ' => CompressionEncoding::GZIP ]);
78+ $ response = $ this ->get ('/heavy ' , ['Accept-Encoding ' => CompressionEncoding::Gzip-> value ]);
6579
66- $ response ->assertHeader ('Content-Encoding ' , CompressionEncoding::GZIP );
80+ $ response ->assertHeader ('Content-Encoding ' , CompressionEncoding::Gzip-> value );
6781
6882 $ this ->assertEquals (
6983 gzdecode ($ response ->getContent ()),
@@ -73,9 +87,9 @@ public function testClientGetResponseCompressedWhenThresholdReached()
7387
7488 public function testClientGetResponseInThePreferredEncoding ()
7589 {
76- $ response = $ this ->get ('/heavy ' , ['Accept-Encoding ' => CompressionEncoding::DEFLATE ]);
90+ $ response = $ this ->get ('/heavy ' , ['Accept-Encoding ' => CompressionEncoding::Deflate-> value ]);
7791
78- $ response ->assertHeader ('Content-Encoding ' , CompressionEncoding::DEFLATE );
92+ $ response ->assertHeader ('Content-Encoding ' , CompressionEncoding::Deflate-> value );
7993
8094 $ this ->assertEquals (
8195 gzinflate ($ response ->getContent ()),
@@ -100,12 +114,12 @@ public function testClientGetResponseWithContentEncodingHeaderAlreadyAttachedRec
100114 Route::get ('/heavy-ignored ' , function () {
101115 return response ()->json ([
102116 'content ' => $ this ->heavyResponseContent ,
103- ], 200 , ['Content-Encoding ' => CompressionEncoding::DEFLATE ]);
117+ ], 200 , ['Content-Encoding ' => CompressionEncoding::Deflate-> value ]);
104118 })->middleware (ResponseCompression::class);
105119
106- $ response = $ this ->get ('/heavy-ignored ' , ['Accept-Encoding ' => CompressionEncoding::GZIP ]);
120+ $ response = $ this ->get ('/heavy-ignored ' , ['Accept-Encoding ' => CompressionEncoding::Gzip-> value ]);
107121
108- $ response ->assertHeader ('Content-Encoding ' , CompressionEncoding::DEFLATE );
122+ $ response ->assertHeader ('Content-Encoding ' , CompressionEncoding::Deflate-> value );
109123
110124 $ this ->assertEquals (
111125 $ response ->json (),
@@ -121,7 +135,7 @@ public function testClientGetStreamDownloadResponseReceivesRawResponse()
121135 });
122136 })->middleware (ResponseCompression::class);
123137
124- $ response = $ this ->get ('/download ' , ['Accept-Encoding ' => CompressionEncoding::DEFLATE ]);
138+ $ response = $ this ->get ('/download ' , ['Accept-Encoding ' => CompressionEncoding::Deflate-> value ]);
125139
126140 $ response ->assertHeaderMissing ('Content-Encoding ' );
127141
@@ -133,9 +147,9 @@ public function testClientGetStreamDownloadResponseReceivesRawResponse()
133147
134148 public function testClientGetResponseUsingZstandardEncoding ()
135149 {
136- $ response = $ this ->get ('/heavy ' , ['Accept-Encoding ' => CompressionEncoding::ZSTANDARD ]);
150+ $ response = $ this ->get ('/heavy ' , ['Accept-Encoding ' => CompressionEncoding::Zstandard-> value ]);
137151
138- $ response ->assertHeader ('Content-Encoding ' , CompressionEncoding::ZSTANDARD );
152+ $ response ->assertHeader ('Content-Encoding ' , CompressionEncoding::Zstandard-> value );
139153
140154 $ this ->assertEquals (
141155 zstd_uncompress ($ response ->getContent ()),
@@ -145,13 +159,25 @@ public function testClientGetResponseUsingZstandardEncoding()
145159
146160 public function testClientGetResponseUsingBrotliEncoding ()
147161 {
148- $ response = $ this ->get ('/heavy ' , ['Accept-Encoding ' => CompressionEncoding::BROTLI ]);
162+ $ response = $ this ->get ('/heavy ' , ['Accept-Encoding ' => CompressionEncoding::Brotli-> value ]);
149163
150- $ response ->assertHeader ('Content-Encoding ' , CompressionEncoding::BROTLI );
164+ $ response ->assertHeader ('Content-Encoding ' , CompressionEncoding::Brotli-> value );
151165
152166 $ this ->assertEquals (
153167 brotli_uncompress ($ response ->getContent ()),
154168 json_encode (['content ' => $ this ->heavyResponseContent ])
155169 );
156170 }
171+
172+ public function testClientGetResponseUsingLz4Encoding ()
173+ {
174+ $ response = $ this ->get ('/heavy ' , ['Accept-Encoding ' => CompressionEncoding::Lz4->value ]);
175+
176+ $ response ->assertHeader ('Content-Encoding ' , CompressionEncoding::Lz4->value );
177+
178+ $ this ->assertEquals (
179+ lz4_uncompress ($ response ->getContent ()),
180+ json_encode (['content ' => $ this ->heavyResponseContent ])
181+ );
182+ }
157183}
0 commit comments