Code Duplication    Length = 14-17 lines in 6 locations

tests/integration/FileInfoTest.php 2 locations

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

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

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

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