Browse Source

Add test for overwrite all

Walther Lalk 10 years ago
parent
commit
e4ceb0df93
1 changed files with 33 additions and 0 deletions
  1. 33 0
      tests/TestCase/Console/ShellTest.php

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

@@ -526,6 +526,39 @@ class ShellTest extends TestCase
     }
 
     /**
+     * Test that all files are changed with a 'a' reply.
+     *
+     * @return void
+     */
+    public function testCreateFileOverwriteAll()
+    {
+        $eol = PHP_EOL;
+        $path = TMP . 'shell_test';
+        $files = [
+            $path . DS . 'file1.php' => 'My first content',
+            $path . DS . 'file2.php' => 'My second content',
+            $path . DS . 'file3.php' => 'My third content'
+        ];
+
+        new Folder($path, true);
+
+        $this->io->expects($this->once())
+            ->method('askChoice')
+            ->will($this->returnValue('a'));
+
+        foreach ($files as $file => $content) {
+            touch($file);
+            $this->assertTrue(file_exists($file));
+
+            $contents = "My content";
+            $result = $this->Shell->createFile($file, $contents);
+            $this->assertTrue(file_exists($file));
+            $this->assertTextEquals($contents, file_get_contents($file));
+            $this->assertTrue($result, 'Did create file.');
+        }
+    }
+
+    /**
      * Test that you can't create files that aren't writable.
      *
      * @return void