| @@ 123-143 (lines=21) @@ | ||
| 120 | static::assertEquals(CompressionFactory::TYPE_UNKNOWN, $this->findCompression->getCompression($file)); |
|
| 121 | } |
|
| 122 | ||
| 123 | public function testWhenTheProcessFailsAnExceptionIsThrownOnFindCompression() |
|
| 124 | { |
|
| 125 | $process = m::mock(Process::class)->makePartial(); |
|
| 126 | $process->shouldReceive('isSuccessful')->andReturn(false); |
|
| 127 | $process->shouldReceive('getCommandLine')->andReturn('cmd'); |
|
| 128 | $process->shouldReceive('getExitCode')->andReturn(1); |
|
| 129 | $process->shouldReceive('getExitCodeText')->andReturn('failed'); |
|
| 130 | $process->shouldReceive('getWorkingDirectory')->andReturn('bla'); |
|
| 131 | $process->shouldReceive('isOutputDisabled')->andReturn(true); |
|
| 132 | $process->shouldReceive('mustRun')->andThrow(new ProcessFailedException($process)); |
|
| 133 | ||
| 134 | $this->builder->shouldReceive('build') |
|
| 135 | ->andReturn($process); |
|
| 136 | ||
| 137 | $file = new LocalFile(static::$dir . 'failed_find_encoding_process.test'); |
|
| 138 | $file->put('random stuff and things 2!'); |
|
| 139 | ||
| 140 | $this->expectException(ProcessFailedException::class); |
|
| 141 | ||
| 142 | $this->findCompression->getCompression($file); |
|
| 143 | } |
|
| 144 | ||
| 145 | public function testCanModifyCanModifyLocalFiles() |
|
| 146 | { |
|
| @@ 89-109 (lines=21) @@ | ||
| 86 | static::assertEquals($utf8file->getEncoding(), $gzipFile->getEncoding()); |
|
| 87 | } |
|
| 88 | ||
| 89 | public function testWhenTheProcessFailsAnExceptionIsThrownOnFindEncoding() |
|
| 90 | { |
|
| 91 | $process = m::mock(Process::class)->makePartial(); |
|
| 92 | $process->shouldReceive('isSuccessful')->andReturn(false); |
|
| 93 | $process->shouldReceive('getCommandLine')->andReturn('cmd'); |
|
| 94 | $process->shouldReceive('getExitCode')->andReturn(1); |
|
| 95 | $process->shouldReceive('getExitCodeText')->andReturn('failed'); |
|
| 96 | $process->shouldReceive('getWorkingDirectory')->andReturn('bla'); |
|
| 97 | $process->shouldReceive('isOutputDisabled')->andReturn(true); |
|
| 98 | $process->shouldReceive('mustRun')->andThrow(new ProcessFailedException($process)); |
|
| 99 | ||
| 100 | $this->builder->shouldReceive('build') |
|
| 101 | ->andReturn($process); |
|
| 102 | ||
| 103 | $file = new LocalFile(static::$dir . 'failed_find_encoding_process.test'); |
|
| 104 | $file->put('random stuff and things 2!'); |
|
| 105 | ||
| 106 | $this->expectException(ProcessFailedException::class); |
|
| 107 | ||
| 108 | $this->findEncoding->getEncoding($file); |
|
| 109 | } |
|
| 110 | ||
| 111 | public function testWhenTheProcessReturnsAnUnknownFileNullIsReturned() |
|
| 112 | { |
|