Browse Source

Make Shell::createFile() always work the same.

Ignoring the force param is annoying and not always obvious.
mark_story 12 years ago
parent
commit
1affe70004
2 changed files with 1 additions and 44 deletions
  1. 1 1
      src/Console/Shell.php
  2. 0 43
      tests/TestCase/Console/ShellTest.php

+ 1 - 1
src/Console/Shell.php

@@ -643,7 +643,7 @@ class Shell extends Object {
 
 		$this->out();
 
-		if (is_file($path) && empty($this->params['force']) && $this->interactive === true) {
+		if (is_file($path) && empty($this->params['force'])) {
 			$this->out(__d('cake_console', '<warning>File `%s` exists</warning>', $path));
 			$key = $this->in(__d('cake_console', 'Do you want to overwrite?'), ['y', 'n', 'q'], 'n');
 

+ 0 - 43
tests/TestCase/Console/ShellTest.php

@@ -553,49 +553,6 @@ class ShellTest extends TestCase {
 	}
 
 /**
- * test createFile when the shell is interactive.
- *
- * @return void
- */
-	public function testCreateFileInteractive() {
-		$eol = PHP_EOL;
-
-		$path = TMP . 'shell_test';
-		$file = $path . DS . 'file1.php';
-		new Folder($path, true);
-
-		$this->Shell->interactive = true;
-
-		$this->Shell->stdin->expects($this->at(0))
-			->method('read')
-			->will($this->returnValue('n'));
-
-		$this->Shell->stdin->expects($this->at(1))
-			->method('read')
-			->will($this->returnValue('y'));
-
-		$contents = "<?php{$eol}echo 'yet another test';{$eol}\$te = 'st';{$eol}";
-		$result = $this->Shell->createFile($file, $contents);
-		$this->assertTrue($result);
-		$this->assertTrue(file_exists($file));
-		$this->assertEquals(file_get_contents($file), $contents);
-
-		// no overwrite
-		$contents = 'new contents';
-		$result = $this->Shell->createFile($file, $contents);
-		$this->assertFalse($result);
-		$this->assertTrue(file_exists($file));
-		$this->assertNotEquals($contents, file_get_contents($file));
-
-		// overwrite
-		$contents = 'more new contents';
-		$result = $this->Shell->createFile($file, $contents);
-		$this->assertTrue($result);
-		$this->assertTrue(file_exists($file));
-		$this->assertEquals($contents, file_get_contents($file));
-	}
-
-/**
  * Test that you can't create files that aren't writable.
  *
  * @return void