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