@@ 111-120 (lines=10) @@ | ||
108 | $this->replacer->replaceText($file, ['text', 'pants that'], ['pants']); |
|
109 | } |
|
110 | ||
111 | public function testAddingAPostfixToTheEndOfTheFile() |
|
112 | { |
|
113 | $file = new LocalFile(static::$dir . 'postfix_test.test'); |
|
114 | $file->put('some text that text should be replaced'); |
|
115 | ||
116 | $newFile = $this->replacer->replaceText($file, 'text', 'pants', ['postfix' => 'pfixtest']); |
|
117 | ||
118 | static::assertNotNull($newFile); |
|
119 | static::assertEquals('postfix_test-pfixtest.test', $newFile->getFilename()); |
|
120 | } |
|
121 | ||
122 | public function testCallingWithBlankPostfixWillReplaceInLine() |
|
123 | { |
|
@@ 122-131 (lines=10) @@ | ||
119 | static::assertEquals('postfix_test-pfixtest.test', $newFile->getFilename()); |
|
120 | } |
|
121 | ||
122 | public function testCallingWithBlankPostfixWillReplaceInLine() |
|
123 | { |
|
124 | $file = new LocalFile(static::$dir . 'inline_replace.test'); |
|
125 | $file->put('some text that text should be replaced'); |
|
126 | ||
127 | $newFile = $this->replacer->replaceText($file, 'text', 'pants', ['postfix' => '']); |
|
128 | ||
129 | static::assertNotNull($newFile); |
|
130 | static::assertEquals($file->getFilename(), $newFile->getFilename()); |
|
131 | } |
|
132 | ||
133 | public function testSettingKeepOldFileToFalseWillDeleteTheOldFile() |
|
134 | { |
|
@@ 133-142 (lines=10) @@ | ||
130 | static::assertEquals($file->getFilename(), $newFile->getFilename()); |
|
131 | } |
|
132 | ||
133 | public function testSettingKeepOldFileToFalseWillDeleteTheOldFile() |
|
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', ['keepOldFile' => false]); |
|
139 | ||
140 | static::assertTrue($newFile->exists()); |
|
141 | static::assertFalse($file->exists()); |
|
142 | } |
|
143 | ||
144 | public function testCallingModifyReplacesText() |
|
145 | { |
|
@@ 144-153 (lines=10) @@ | ||
141 | static::assertFalse($file->exists()); |
|
142 | } |
|
143 | ||
144 | public function testCallingModifyReplacesText() |
|
145 | { |
|
146 | $file = new LocalFile(static::$dir . 'simple_replace.test'); |
|
147 | $file->put('some text that text should be replaced'); |
|
148 | ||
149 | $newFile = $this->replacer->modify($file, ['fromText' => 'text', 'toText' => 'pants']); |
|
150 | ||
151 | static::assertNotNull($newFile); |
|
152 | static::assertEquals(['some pants that pants should be replaced'], $newFile->getContents()); |
|
153 | } |
|
154 | ||
155 | public function testCallingModifyWillPassThroughOptions() |
|
156 | { |
|
@@ 207-217 (lines=11) @@ | ||
204 | $this->replacer->modify($file, ['fromText' => 'pants', 'toText' => 'more pants']); |
|
205 | } |
|
206 | ||
207 | public function testCallingReplaceTextOnAFileWithoutAnExtensionWorks() |
|
208 | { |
|
209 | $file = new LocalFile(static::$dir . 'file_no_ext'); |
|
210 | $file->put('some text that text should be replaced'); |
|
211 | ||
212 | $newFile = $this->replacer->replaceText($file, 'text', 'pants'); |
|
213 | ||
214 | static::assertTrue($newFile->exists()); |
|
215 | static::assertNotNull($newFile); |
|
216 | static::assertEquals(['some pants that pants should be replaced'], $newFile->getContents()); |
|
217 | } |
|
218 | ||
219 | public function testWhenTheProcessFailsAnExceptionIsThrownOnFindEncoding() |
|
220 | { |