public function testMoveDeletesTheOldFile() { $fromFile = new LocalFile(static::$dir . 'delete_from.text'); $fromFile->put('Some Text In Here'); $toFile = new LocalFile(static::$dir . 'delete_to.text'); $this->transfer->moveTo($fromFile, $toFile); static::assertEquals('Some Text In Here', $toFile->read()); static::assertFalse($fromFile->exists()); }
public function testConversionWillFailWhenSpecifyingAnInvalidEncoding() { $asciiFile = new LocalFile(static::$dir . 'ascii_fail.test'); $asciiFile->put(mb_convert_encoding('Some random Text', 'ASCII')); $this->expectException(ProcessFailedException::class); $this->converter->toEncoding($asciiFile, 'NotARealEncoding'); }
public function testPassingFalseToKeepOldFileOptionWillKeepTheFile() { $file = new LocalFile(static::$dir . 'delete_file_zip.test'); $file->put('random stuff and things!'); $compressedFile = $this->zip->compress($file, ['keepOldFile' => false]); static::assertFalse($file->exists()); static::assertTrue($compressedFile->exists()); $uncompresssedFile = $this->zip->decompress($compressedFile, ['keepOldFile' => false]); static::assertFalse($compressedFile->exists()); static::assertTrue($uncompresssedFile->exists()); }
public function testSetCompressionReturnsIsFluent() { $file = new LocalFile(static::$dir . 'file_set_compression2.test'); $file->put('uncompressed contents'); $newFile = $file->setCompression(Gzip::NAME); static::assertNotNull($newFile); static::assertSame($file, $newFile); }
public function testModifyWillSetTheEncoding() { $utf8file = new LocalFile(static::$dir . 'utf8_file.test'); $utf8file->put(mb_convert_encoding('Some random Text €±§', 'UTF-8')); $utf8file = $this->findEncoding->modify($utf8file); static::assertEquals('utf-8', $utf8file->getEncoding()); }
public function testWhenTheProcessFailsAnExceptionIsThrownOnFindEncoding() { $process = m::mock(Process::class)->makePartial(); $process->shouldReceive('isSuccessful')->andReturn(false); $this->builder->shouldReceive('build')->andReturn($process); $file = new LocalFile(static::$dir . 'failed_tail.test'); $file->put('nothing interesting here'); $this->expectException(ProcessFailedException::class); $this->head->head($file, 3); }
public function testWhenTheProcessFailsAnExceptionIsThrownOnFindEncoding() { $process = m::mock(Process::class)->makePartial(); $process->shouldReceive('isSuccessful')->andReturn(false); $this->builder->shouldReceive('build')->andReturn($process); $file = new LocalFile(static::$dir . 'failed_replace_text.test'); $file->put('some text that text should be replaced'); $this->expectException(ProcessFailedException::class); $this->replacer->replaceText($file, 'text', 'pants'); }
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()); }