Пример #1
0
 public function testGetContentsForCompressedFileDeletesTheUncompressedFileAfterwards()
 {
     $file = new LocalFile(static::$dir . 'file_uncompressed_todelete.test');
     $file->put('uncompressed contents');
     $gzip = new Gzip();
     $compressed = $gzip->compress($file, ['keepOldFile' => true]);
     $compressed->getContents();
     static::assertFalse(file_exists(static::$dir . 'file_uncompressed_todelete'), "The uncompressed file should be deleted");
 }
Пример #2
0
 public function testGetFileEncodingForCompressedFile()
 {
     $utf8file = (new LocalFile(static::$dir . 'utf8_tobegzipped_file.test'))->setEncoding('UTF-8');
     $utf8file->put(mb_convert_encoding('Some random Text €±§', 'UTF-8'));
     $gzip = new Gzip();
     $gzipFile = $gzip->compress($utf8file);
     static::assertEquals(strtolower($gzipFile->getEncoding()), strtolower($this->findEncoding->getEncoding($gzipFile)));
     static::assertEquals('utf-8', $this->findEncoding->getEncoding($gzipFile));
     static::assertEquals($utf8file->getEncoding(), $gzipFile->getEncoding());
 }
Пример #3
0
 public function testPassingFalseToKeepOldFileOptionWillKeepTheFile()
 {
     $file = new LocalFile(static::$dir . 'delete_file_gz.test');
     $file->put('random stuff and things!');
     $compressedFile = $this->gzip->compress($file, ['keepOldFile' => false]);
     static::assertFalse($file->exists());
     static::assertTrue($compressedFile->exists());
     $uncompresssedFile = $this->gzip->decompress($compressedFile, ['keepOldFile' => false]);
     static::assertFalse($compressedFile->exists());
     static::assertTrue($uncompresssedFile->exists());
 }
Пример #4
0
 public function testModifyWillSetTheCompression()
 {
     $file = new LocalFile(static::$dir . 'tobegzipped_file.test');
     $file->put('some random text');
     $gzip = new Gzip();
     $gzipFile = $gzip->compress($file);
     $gzipFile->setCompression(CompressionFactory::TYPE_NONE);
     $gzipFile = $this->findCompression->modify($gzipFile);
     static::assertEquals(Gzip::NAME, $gzipFile->getCompression());
 }