| @@ 67-84 (lines=18) @@ | ||
| 64 | static::assertEquals(1, $result, "File is not compressed as gzip"); |
|
| 65 | } |
|
| 66 | ||
| 67 | public function testFileGetsDecompressedFromGzip() |
|
| 68 | { |
|
| 69 | $file = new LocalFile(static::$dir . 'get_decompressed_uncompressed_gz.test'); |
|
| 70 | $file->put('random stuff and things!'); |
|
| 71 | ||
| 72 | $compressedFile = $this->gzip->compress($file); |
|
| 73 | $uncompressedFile = $this->gzip->decompress($compressedFile); |
|
| 74 | ||
| 75 | static::assertNotNull($uncompressedFile); |
|
| 76 | static::assertInstanceOf(FileNodeInterface::class, $uncompressedFile); |
|
| 77 | static::assertEquals(static::$dir . 'get_decompressed_uncompressed_gz', $uncompressedFile->getPath()); |
|
| 78 | static::assertTrue($uncompressedFile->exists()); |
|
| 79 | static::assertEquals(CompressionFactory::TYPE_NONE, $uncompressedFile->getCompression()); |
|
| 80 | ||
| 81 | $cmd = "file {$uncompressedFile->getPath()} | grep " . escapeshellarg('\bgzip\b') . " | wc -l"; |
|
| 82 | $result = exec($cmd); |
|
| 83 | static::assertEquals(0, $result, "File should not be compressed"); |
|
| 84 | } |
|
| 85 | ||
| 86 | public function testCallingGzipWithAFileThatDoesNotExistsThrowsAnException() |
|
| 87 | { |
|
| @@ 75-94 (lines=20) @@ | ||
| 72 | static::assertEquals(1, $result, "File is not compressed as zip"); |
|
| 73 | } |
|
| 74 | ||
| 75 | public function testFileGetsDecompressedFromZip() |
|
| 76 | { |
|
| 77 | $file = new LocalFile(static::$dir . 'get_decompressed_uncompressed_zip.test'); |
|
| 78 | $file->put('random stuff and things!'); |
|
| 79 | ||
| 80 | $compressedFile = $this->zip->compress($file); |
|
| 81 | ||
| 82 | static::assertTrue($compressedFile->exists()); |
|
| 83 | $uncompressedFile = $this->zip->decompress($compressedFile); |
|
| 84 | ||
| 85 | static::assertNotNull($uncompressedFile); |
|
| 86 | static::assertInstanceOf(FileNodeInterface::class, $uncompressedFile); |
|
| 87 | static::assertEquals(static::$dir . 'get_decompressed_uncompressed_zip', $uncompressedFile->getPath()); |
|
| 88 | static::assertTrue($uncompressedFile->exists()); |
|
| 89 | static::assertEquals(CompressionFactory::TYPE_NONE, $uncompressedFile->getCompression()); |
|
| 90 | ||
| 91 | $cmd = "file {$uncompressedFile->getPath()} | grep " . escapeshellarg('\bzip\b') . " | wc -l"; |
|
| 92 | $result = exec($cmd); |
|
| 93 | static::assertEquals(0, $result, "File should not be compressed"); |
|
| 94 | } |
|
| 95 | ||
| 96 | public function testCallingZipWithAFileThatDoesNotExistsThrowsAnException() |
|
| 97 | { |
|