Code Duplication    Length = 14-17 lines in 6 locations

tests/integration/Modify/HeadTest.php 1 location

@@ 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

tests/integration/Modify/ReplaceTextTest.php 1 location

@@ 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

tests/integration/Modify/TailTest.php 1 location

@@ 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

tests/integration/Modify/Contract/MergeFilesTest.php 1 location

@@ 241-257 (lines=17) @@
238
        static::assertCount(0, $exists);
239
    }
240
241
    public function testProcessFailedThrowException()
242
    {
243
        $process = m::mock('Symfony\Component\Process\Process')->makePartial();
244
        $this->processFactory->shouldReceive('createProcess')
245
                             ->andReturn($process);
246
247
        $process->shouldReceive('isSuccessful')->andReturn(false);
248
249
        // set exception as no guarantee process will run on local system
250
        $this->expectException(ProcessFailedException::class);
251
252
        $collection = $this->createCollection('simple.merge/', 3);
253
254
        $outputFile = new LocalFile(static::$dir . 'simple.merge.output');
255
256
        $this->merge->contract($collection, $outputFile);
257
    }
258
259
    public function testCallingContractWillPassThroughOptions()
260
    {

tests/integration/Modify/Compress/FindCompressionTest.php 1 location

@@ 92-105 (lines=14) @@
89
        static::assertEquals(Zip::NAME, $zipFile->getCompression());
90
    }
91
92
    public function testWhenTheProcessReturnsAnUnknownCompressionUnknownTypeIsReturned()
93
    {
94
        $process = m::mock(Process::class)->makePartial();
95
        $process->shouldReceive('mustRun');
96
        $process->shouldReceive('getOutput')->andReturn('text/plain; charset=utf-8 compressed-encoding=application/lzop; charset=binary; charset=binary');
97
98
        $this->processFactory->shouldReceive('createProcess')
99
                             ->andReturn($process);
100
101
        $file = new LocalFile(static::$dir . 'unknown_compression.test');
102
        $file->put('random stuff and things 2!');
103
104
        static::assertEquals(CompressionFactory::TYPE_UNKNOWN, $this->findCompression->getCompression($file));
105
    }
106
107
    public function testWhenTheProcessFailsAnExceptionIsThrownOnFindCompression()
108
    {

tests/integration/Modify/Encoding/FindEncodingTest.php 1 location

@@ 98-111 (lines=14) @@
95
        $this->findEncoding->getEncoding($file);
96
    }
97
98
    public function testWhenTheProcessReturnsAnUnknownFileNullIsReturned()
99
    {
100
        $process = m::mock(Process::class)->makePartial();
101
        $process->shouldReceive('mustRun');
102
        $process->shouldReceive('getOutput')->andReturn('some random stuff with no charset');
103
104
        $this->processFactory->shouldReceive('createProcess')
105
                             ->andReturn($process);
106
107
        $file = new LocalFile(static::$dir . 'unknown_compression.test');
108
        $file->put('random stuff and things 2!');
109
110
        static::assertNull($this->findEncoding->getEncoding($file));
111
    }
112
113
    public function testCanModifyCanModifyLocalFiles()
114
    {