| @@ 116-130 (lines=15) @@ | ||
| 113 | static::assertEquals($utf8file->getEncoding(), $gzipFile->getEncoding()); |
|
| 114 | } |
|
| 115 | ||
| 116 | public function testWhenTheProcessFailsAnExceptionIsThrownOnFindEncoding() |
|
| 117 | { |
|
| 118 | $process = m::mock(Process::class)->makePartial(); |
|
| 119 | $process->shouldReceive('isSuccessful')->andReturn(false); |
|
| 120 | ||
| 121 | $this->processFactory->shouldReceive('createProcess') |
|
| 122 | ->andReturn($process); |
|
| 123 | ||
| 124 | $file = new LocalFile(static::$dir . 'failed_find_encoding_process.test'); |
|
| 125 | $file->put('random stuff and things 2!'); |
|
| 126 | ||
| 127 | $this->expectException(ProcessFailedException::class); |
|
| 128 | ||
| 129 | $this->fileInfo->findEncoding($file); |
|
| 130 | } |
|
| 131 | ||
| 132 | public function testWhenTheProcessFailsAnExceptionIsThrownOnFindCompression() |
|
| 133 | { |
|
| @@ 132-146 (lines=15) @@ | ||
| 129 | $this->fileInfo->findEncoding($file); |
|
| 130 | } |
|
| 131 | ||
| 132 | public function testWhenTheProcessFailsAnExceptionIsThrownOnFindCompression() |
|
| 133 | { |
|
| 134 | $process = m::mock(Process::class)->makePartial(); |
|
| 135 | $process->shouldReceive('isSuccessful')->andReturn(false); |
|
| 136 | ||
| 137 | $this->processFactory->shouldReceive('createProcess') |
|
| 138 | ->andReturn($process); |
|
| 139 | ||
| 140 | $file = new LocalFile(static::$dir . 'failed_find_encoding_process.test'); |
|
| 141 | $file->put('random stuff and things 2!'); |
|
| 142 | ||
| 143 | $this->expectException(ProcessFailedException::class); |
|
| 144 | ||
| 145 | $this->fileInfo->findCompression($file); |
|
| 146 | } |
|
| 147 | ||
| 148 | public function testWhenTheProcessReturnsAnUnknownEncodingUnknownTypeIsReturned() |
|
| 149 | { |
|
| @@ 217-230 (lines=14) @@ | ||
| 214 | $this->head->modify($file, ['lines' => 1]); |
|
| 215 | } |
|
| 216 | ||
| 217 | public function testWhenTheProcessFailsAnExceptionIsThrownOnFindEncoding() |
|
| 218 | { |
|
| 219 | $process = m::mock(Process::class)->makePartial(); |
|
| 220 | $process->shouldReceive('isSuccessful')->andReturn(false); |
|
| 221 | $this->processFactory->shouldReceive('createProcess') |
|
| 222 | ->andReturn($process); |
|
| 223 | ||
| 224 | $file = new LocalFile(static::$dir . 'failed_tail.test'); |
|
| 225 | $file->put('nothing interesting here'); |
|
| 226 | ||
| 227 | $this->expectException(ProcessFailedException::class); |
|
| 228 | ||
| 229 | $this->head->head($file, 3); |
|
| 230 | } |
|
| 231 | } |
|
| 232 | ||
| @@ 208-221 (lines=14) @@ | ||
| 205 | static::assertEquals(['some pants that pants should be replaced'], $newFile->getContents()); |
|
| 206 | } |
|
| 207 | ||
| 208 | public function testWhenTheProcessFailsAnExceptionIsThrownOnFindEncoding() |
|
| 209 | { |
|
| 210 | $process = m::mock(Process::class)->makePartial(); |
|
| 211 | $process->shouldReceive('isSuccessful')->andReturn(false); |
|
| 212 | $this->processFactory->shouldReceive('createProcess') |
|
| 213 | ->andReturn($process); |
|
| 214 | ||
| 215 | $file = new LocalFile(static::$dir . 'failed_replace_text.test'); |
|
| 216 | $file->put('some text that text should be replaced'); |
|
| 217 | ||
| 218 | $this->expectException(ProcessFailedException::class); |
|
| 219 | ||
| 220 | $this->replacer->replaceText($file, 'text', 'pants'); |
|
| 221 | } |
|
| 222 | } |
|
| 223 | ||
| @@ 218-231 (lines=14) @@ | ||
| 215 | $this->tail->modify($file, ['lines' => 1]); |
|
| 216 | } |
|
| 217 | ||
| 218 | public function testWhenTheProcessFailsAnExceptionIsThrownOnFindEncoding() |
|
| 219 | { |
|
| 220 | $process = m::mock(Process::class)->makePartial(); |
|
| 221 | $process->shouldReceive('isSuccessful')->andReturn(false); |
|
| 222 | $this->processFactory->shouldReceive('createProcess') |
|
| 223 | ->andReturn($process); |
|
| 224 | ||
| 225 | $file = new LocalFile(static::$dir . 'failed_tail.test'); |
|
| 226 | $file->put('nothing interesting here'); |
|
| 227 | ||
| 228 | $this->expectException(ProcessFailedException::class); |
|
| 229 | ||
| 230 | $this->tail->tail($file, 3); |
|
| 231 | } |
|
| 232 | } |
|
| 233 | ||
| @@ 240-256 (lines=17) @@ | ||
| 237 | static::assertCount(0, $exists); |
|
| 238 | } |
|
| 239 | ||
| 240 | public function testProcessFailedThrowException() |
|
| 241 | { |
|
| 242 | $process = m::mock('Symfony\Component\Process\Process')->makePartial(); |
|
| 243 | $this->processFactory->shouldReceive('createProcess') |
|
| 244 | ->andReturn($process); |
|
| 245 | ||
| 246 | $process->shouldReceive('isSuccessful')->andReturn(false); |
|
| 247 | ||
| 248 | // set exception as no guarantee process will run on local system |
|
| 249 | $this->expectException(ProcessFailedException::class); |
|
| 250 | ||
| 251 | $collection = $this->createCollection('simple.merge/', 3); |
|
| 252 | ||
| 253 | $outputFile = new LocalFile(static::$dir . 'simple.merge.output'); |
|
| 254 | ||
| 255 | $this->merge->contract($collection, $outputFile); |
|
| 256 | } |
|
| 257 | ||
| 258 | public function testCallingContractWillPassThroughOptions() |
|
| 259 | { |
|