|
|
@@ -569,18 +569,32 @@ class FileTest extends CakeTestCase {
|
|
|
* @return void
|
|
|
*/
|
|
|
public function testReplaceText() {
|
|
|
- $TestFile = new File(__FILE__);
|
|
|
+ $TestFile = new File(dirname(__FILE__) . '/../../test_app/Vendor/welcome.php');
|
|
|
$TmpFile = new File(TMP . 'tests' . DS . 'cakephp.file.test.tmp');
|
|
|
+
|
|
|
// Copy the test file to the temporary location
|
|
|
$TestFile->copy($TmpFile->path, true);
|
|
|
|
|
|
// Replace the contents of the tempory file
|
|
|
- $result = $TmpFile->replaceText("* testReplaceText method", "* testReplaceText method passed");
|
|
|
+ $result = $TmpFile->replaceText('welcome.php', 'welcome.tmp');
|
|
|
+ $this->assertTrue($result);
|
|
|
+
|
|
|
+ // Double check
|
|
|
+ $expected = 'This is the welcome.tmp file in vendors directory';
|
|
|
+ $contents = $TmpFile->read();
|
|
|
+ $this->assertContains($expected, $contents);
|
|
|
+
|
|
|
+ $search = array('This is the', 'welcome.php file', 'in tmp directory');
|
|
|
+ $replace = array('This should be a', 'welcome.tmp file', 'in the Lib directory');
|
|
|
+
|
|
|
+ // Replace the contents of the tempory file
|
|
|
+ $result = $TmpFile->replaceText($search, $replace);
|
|
|
$this->assertTrue($result);
|
|
|
|
|
|
// Double check
|
|
|
+ $expected = 'This should be a welcome.tmp file in vendors directory';
|
|
|
$contents = $TmpFile->read();
|
|
|
- $this->assertContains("* testReplaceText method passed", $contents);
|
|
|
+ $this->assertContains($expected, $contents);
|
|
|
|
|
|
$TmpFile->delete();
|
|
|
}
|