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')
97
                ->andReturn(
98
                    'text/plain; charset=utf-8 compressed-encoding=application/lzop; charset=binary; charset=binary'
99
                );
100
101
        $this->processFactory->shouldReceive('createProcess')
102
                             ->andReturn($process);
103
104
        $file = new LocalFile(static::$dir . 'unknown_compression.test');
105
        $file->put('random stuff and things 2!');
106
107
        static::assertEquals(CompressionFactory::TYPE_UNKNOWN, $this->findCompression->getCompression($file));
108
    }

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

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