|
1 | 1 | <?php |
2 | 2 |
|
3 | | -namespace OpenSoutheners\LaravelResponseCompression\Tests; |
4 | | - |
5 | | -use OpenSoutheners\LaravelResponseCompression\CompressionEncoding; |
6 | | -use PHPUnit\Framework\TestCase; |
| 3 | +namespace OpenSoutheners\LaravelResponseCompression |
| 4 | +{ |
| 5 | + function function_exists(string $name): bool { |
| 6 | + if (getenv('FUNCTION_EXISTS_MOCK')) { |
| 7 | + return false; |
| 8 | + } |
| 9 | + |
| 10 | + return \function_exists($name); |
| 11 | + } |
| 12 | +} |
7 | 13 |
|
8 | | -class CompressionEncodingTest extends TestCase |
| 14 | +namespace OpenSoutheners\LaravelResponseCompression\Tests |
9 | 15 | { |
10 | | - public function testCompressionEncodingListSupportedReturnsArray() |
| 16 | + use OpenSoutheners\LaravelResponseCompression\CompressionEncoding; |
| 17 | + use PHPUnit\Framework\TestCase; |
| 18 | + |
| 19 | + class CompressionEncodingTest extends TestCase |
11 | 20 | { |
12 | | - $supportedList = CompressionEncoding::listSupported(); |
| 21 | + public function testCompressionEncodingListSupportedReturnsArray() |
| 22 | + { |
| 23 | + $supportedList = CompressionEncoding::listSupported(); |
| 24 | + |
| 25 | + $this->assertIsArray($supportedList); |
| 26 | + $this->assertArrayHasKey(CompressionEncoding::Deflate->value, $supportedList); |
| 27 | + $this->assertEmpty(array_diff( |
| 28 | + array_map(fn ($case) => $case->value, CompressionEncoding::cases()), |
| 29 | + array_keys($supportedList), |
| 30 | + )); |
| 31 | + } |
13 | 32 |
|
14 | | - $this->assertIsArray($supportedList); |
15 | | - $this->assertArrayHasKey(CompressionEncoding::Deflate->value, $supportedList); |
16 | | - $this->assertEmpty(array_diff( |
17 | | - array_map(fn ($case) => $case->value, CompressionEncoding::cases()), |
18 | | - array_keys($supportedList), |
19 | | - )); |
| 33 | + public function testCompressionEncodingIsSupportedGetsNullWhenNonPresent() |
| 34 | + { |
| 35 | + putenv('FUNCTION_EXISTS_MOCK=1'); |
| 36 | + |
| 37 | + $supported = CompressionEncoding::Lz4->isSupported(); |
| 38 | + |
| 39 | + putenv('FUNCTION_EXISTS_MOCK='); |
| 40 | + |
| 41 | + $this->assertNull($supported); |
| 42 | + } |
20 | 43 | } |
21 | 44 | } |
0 commit comments