Code Duplication    Length = 10-11 lines in 5 locations

tests/integration/Modify/ReplaceTextTest.php 5 locations

@@ 122-131 (lines=10) @@
119
        $this->replacer->replaceText($file, ['text', 'pants that'], 'pants');
120
    }
121
122
    public function testAddingAPostfixToTheEndOfTheFile()
123
    {
124
        $file = new LocalFile(static::$dir . 'postfix_test.test');
125
        $file->put('some text that text should be replaced');
126
127
        $newFile = $this->replacer->replaceText($file, 'text', 'pants', ['postfix' => 'pfixtest']);
128
129
        static::assertNotNull($newFile);
130
        static::assertEquals('postfix_test-pfixtest.test', $newFile->getFilename());
131
    }
132
133
    public function testCallingWithBlankPostfixWillReplaceInLine()
134
    {
@@ 133-142 (lines=10) @@
130
        static::assertEquals('postfix_test-pfixtest.test', $newFile->getFilename());
131
    }
132
133
    public function testCallingWithBlankPostfixWillReplaceInLine()
134
    {
135
        $file = new LocalFile(static::$dir . 'inline_replace.test');
136
        $file->put('some text that text should be replaced');
137
138
        $newFile = $this->replacer->replaceText($file, 'text', 'pants', ['postfix' => '']);
139
140
        static::assertNotNull($newFile);
141
        static::assertEquals($file->getFilename(), $newFile->getFilename());
142
    }
143
144
    public function testSettingKeepOldFileToFalseWillDeleteTheOldFile()
145
    {
@@ 144-153 (lines=10) @@
141
        static::assertEquals($file->getFilename(), $newFile->getFilename());
142
    }
143
144
    public function testSettingKeepOldFileToFalseWillDeleteTheOldFile()
145
    {
146
        $file = new LocalFile(static::$dir . 'inline_replace.test');
147
        $file->put('some text that text should be replaced');
148
149
        $newFile = $this->replacer->replaceText($file, 'text', 'pants', ['keepOldFile' => false]);
150
151
        static::assertTrue($newFile->exists());
152
        static::assertFalse($file->exists());
153
    }
154
155
    public function testCallingModifyReplacesText()
156
    {
@@ 155-164 (lines=10) @@
152
        static::assertFalse($file->exists());
153
    }
154
155
    public function testCallingModifyReplacesText()
156
    {
157
        $file = new LocalFile(static::$dir . 'simple_replace.test');
158
        $file->put('some text that text should be replaced');
159
160
        $newFile = $this->replacer->modify($file, ['fromText' => 'text', 'toText' => 'pants']);
161
162
        static::assertNotNull($newFile);
163
        static::assertEquals(['some pants that pants should be replaced'], $newFile->getContents());
164
    }
165
166
    public function testCallingModifyWillPassThroughOptions()
167
    {
@@ 218-228 (lines=11) @@
215
        $this->replacer->modify($file, ['fromText' => 'pants', 'toText' => 'more pants']);
216
    }
217
218
    public function testCallingReplaceTextOnAFileWithoutAnExtensionWorks()
219
    {
220
        $file = new LocalFile(static::$dir . 'file_no_ext');
221
        $file->put('some text that text should be replaced');
222
223
        $newFile = $this->replacer->replaceText($file, 'text', 'pants');
224
225
        static::assertTrue($newFile->exists());
226
        static::assertNotNull($newFile);
227
        static::assertEquals(['some pants that pants should be replaced'], $newFile->getContents());
228
    }
229
230
    public function testWhenTheProcessFailsAnExceptionIsThrownOnFindEncoding()
231
    {