Skip to content

Commit

Permalink
Add test for overwrite all
Browse files Browse the repository at this point in the history
  • Loading branch information
dakota committed Jun 4, 2015
1 parent 8a0ed4c commit e4ceb0d
Showing 1 changed file with 33 additions and 0 deletions.
33 changes: 33 additions & 0 deletions tests/TestCase/Console/ShellTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -525,6 +525,39 @@ public function testCreateFileOverwriteNonInteractive()
$this->assertEquals(file_get_contents($file), 'My content');
}

/**
* 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.
*
Expand Down

0 comments on commit e4ceb0d

Please sign in to comment.