Exemplo n.º 1
0
 public function testWhenTheProcessReturnsAnUnknownFileNullIsReturned()
 {
     $process = m::mock(Process::class)->makePartial();
     $process->shouldReceive('mustRun');
     $process->shouldReceive('getOutput')->andReturn('some random stuff with no charset');
     $this->builder->shouldReceive('build')->andReturn($process);
     $file = new LocalFile(static::$dir . 'unknown_compression.test');
     $file->put('random stuff and things 2!');
     static::assertNull($this->findEncoding->getEncoding($file));
 }
Exemplo n.º 2
0
 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);
 }
Exemplo n.º 3
0
 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');
 }
Exemplo n.º 4
0
 public function testProcessFailedThrowException()
 {
     $process = m::mock('Symfony\\Component\\Process\\Process')->makePartial();
     $this->builder->shouldReceive('build')->andReturn($process);
     $process->shouldReceive('isSuccessful')->andReturn(false);
     // set exception as no guarantee process will run on local system
     $this->expectException(ProcessFailedException::class);
     $collection = $this->createCollection('simple.merge/', 3);
     $outputFile = new LocalFile(static::$dir . 'simple.merge.output');
     $this->merge->contract($collection, $outputFile);
 }
Exemplo n.º 5
0
 public function testReFormatWithDeleteOldFile()
 {
     $file = m::mock(FileNodeInterface::class, FormatAwareInterface::class);
     $target = m::mock(LocalFileNodeInterface::class, FormatAwareInterface::class);
     $reader = m::mock(FileReader::class);
     $this->builder->shouldReceive('build')->with(FileReader::class, $file, null, $this->parserFactory)->andReturn($reader);
     $writer = m::mock(FileWriter::class);
     $this->builder->shouldReceive('build')->with(FileWriter::Class, $target, null, $this->formatterFactory)->andReturn($writer);
     $iterator = new ArrayIterator(['first', 'second']);
     $reader->shouldReceive('fetch')->andReturn($iterator);
     $writer->shouldReceive('insertAll')->with($iterator)->once();
     $file->shouldReceive('exists')->andReturn(true);
     $file->shouldReceive('delete')->once();
     static::assertSame($target, $this->reFormatter->reFormat($file, null, $target, null, ['keepOldFile' => false]));
 }
Exemplo n.º 6
0
 public function testWhenTheProcessFailsAnExceptionIsthrownOnUnzip()
 {
     $process = m::mock(Process::class)->makePartial();
     $this->builder->shouldReceive('build')->andReturn($process);
     $process->shouldReceive('run')->once();
     $process->shouldReceive('isSuccessful')->andReturn(false);
     $process->shouldReceive('getCommandLine')->andReturn('');
     $process->shouldReceive('getExitCode')->andReturn(1);
     $process->shouldReceive('getExitCodeText')->andReturn('bla');
     $process->shouldReceive('getWorkingDirectory')->andReturn('/something/');
     $process->shouldReceive('isOutputDisabled')->andReturn('true');
     $file = new LocalFile(static::$dir . 'failed_unzip_process.test');
     $file->put('random stuff and things 2!');
     $this->expectException(ProcessFailedException::class);
     $this->zip->decompress($file);
 }
Exemplo n.º 7
0
 public function testWhenTheProcessFailsAnExceptionIsThrownOnFindCompression()
 {
     $process = m::mock(Process::class)->makePartial();
     $process->shouldReceive('isSuccessful')->andReturn(false);
     $process->shouldReceive('getCommandLine')->andReturn('cmd');
     $process->shouldReceive('getExitCode')->andReturn(1);
     $process->shouldReceive('getExitCodeText')->andReturn('failed');
     $process->shouldReceive('getWorkingDirectory')->andReturn('bla');
     $process->shouldReceive('isOutputDisabled')->andReturn(true);
     $process->shouldReceive('mustRun')->andThrow(new ProcessFailedException($process));
     $this->builder->shouldReceive('build')->andReturn($process);
     $file = new LocalFile(static::$dir . 'failed_find_encoding_process.test');
     $file->put('random stuff and things 2!');
     $this->expectException(ProcessFailedException::class);
     $this->findCompression->getCompression($file);
 }