Skip to content
Browse files

Remove duplicate code / skipped tests.

  • Loading branch information...
1 parent 6167529 commit f818caf47c2c41cfb3d3809a3bf755f17bd61607 @markstory markstory committed Apr 14, 2012
Showing with 4 additions and 79 deletions.
  1. +4 −79 lib/Cake/Test/Case/Console/ShellTest.php
View
83 lib/Cake/Test/Case/Console/ShellTest.php
@@ -525,7 +525,7 @@ public function testShortPath() {
* @return void
*/
public function testCreateFileNonInteractive() {
- $this->skipIf(DIRECTORY_SEPARATOR === '\\', 'Not supported on Windows.');
+ $eol = PHP_EOL;
$path = TMP . 'shell_test';
$file = $path . DS . 'file1.php';
@@ -534,7 +534,7 @@ public function testCreateFileNonInteractive() {
$this->Shell->interactive = false;
- $contents = "<?php\necho 'test';\n\$te = 'st';\n";
+ $contents = "<?php{$eol}echo 'test';${eol}\$te = 'st';{$eol}";
$result = $this->Shell->createFile($file, $contents);
$this->assertTrue($result);
$this->assertTrue(file_exists($file));
@@ -553,7 +553,7 @@ public function testCreateFileNonInteractive() {
* @return void
*/
public function testCreateFileInteractive() {
- $this->skipIf(DIRECTORY_SEPARATOR === '\\', 'Not supported on Windows.');
+ $eol = PHP_EOL;
$path = TMP . 'shell_test';
$file = $path . DS . 'file1.php';
@@ -569,7 +569,7 @@ public function testCreateFileInteractive() {
->method('read')
->will($this->returnValue('y'));
- $contents = "<?php\necho 'yet another test';\n\$te = 'st';\n";
+ $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));
@@ -610,81 +610,6 @@ public function testCreateFileNoPermissions() {
}
/**
- * testCreateFileWindows method
- *
- * @return void
- */
- public function testCreateFileWindowsNonInteractive() {
- $this->skipIf(DIRECTORY_SEPARATOR === '/', 'testCreateFileWindowsNonInteractive supported on Windows only.');
-
- $path = TMP . 'shell_test';
- $file = $path . DS . 'file1.php';
-
- $Folder = new Folder($path, true);
-
- $this->Shell->interactive = false;
-
- $contents = "<?php\r\necho 'test';\r\n\$te = 'st';\r\n";
- $result = $this->Shell->createFile($file, $contents);
- $this->assertTrue($result);
- $this->assertTrue(file_exists($file));
- $this->assertEquals(file_get_contents($file), $contents);
-
- $contents = "<?php\r\necho 'another test';\r\n\$te = 'st';\r\n";
- $result = $this->Shell->createFile($file, $contents);
- $this->assertTrue($result);
- $this->assertTrue(file_exists($file));
- $this->assertEquals(file_get_contents($file), $contents);
-
- $Folder = new Folder($path);
- $Folder->delete();
- }
-
-/**
- * test createFile on windows with interactive on.
- *
- * @return void
- */
- public function testCreateFileWindowsInteractive() {
- $this->skipIf(DIRECTORY_SEPARATOR === '/', 'testCreateFileWindowsInteractive supported on Windows only.');
- $path = TMP . 'shell_test';
- $file = $path . DS . 'file1.php';
- $Folder = 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\r\necho 'yet another test';\r\n\$te = 'st';\r\n";
- $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));
-
- $Folder->delete();
- }
-
-/**
* test hasTask method
*
* @return void

0 comments on commit f818caf

Please sign in to comment.
Something went wrong with that request. Please try again.