Browse Source

Expand variable name, add comment and fix tests.

Mark Story 11 years ago
parent
commit
6e8d1bfd4c
2 changed files with 9 additions and 6 deletions
  1. 5 2
      src/Console/ShellDispatcher.php
  2. 4 4
      tests/TestCase/Console/ShellDispatcherTest.php

+ 5 - 2
src/Console/ShellDispatcher.php

@@ -154,11 +154,14 @@ class ShellDispatcher {
 /**
  * Dispatches a CLI request
  *
+ * Converts a shell command result into an exit code. Null/True
+ * are treated as success. All other return values are an error.
+ *
  * @return int The cli command exit code. 0 is success.
  */
 	public function dispatch() {
-		$r = $this->_dispatch();
-		if ($r === null || $r === true) {
+		$result = $this->_dispatch();
+		if ($result === null || $result === true) {
 			return 0;
 		}
 		return 1;

+ 4 - 4
tests/TestCase/Console/ShellDispatcherTest.php

@@ -128,7 +128,7 @@ class ShellDispatcherTest extends TestCase {
 		$dispatcher = $this->getMock('Cake\Console\ShellDispatcher', ['findShell']);
 		$Shell = $this->getMock('Cake\Console\Shell');
 
-		$Shell->expects($this->once())->method('initialize');
+		$Shell->expects($this->exactly(2))->method('initialize');
 		$Shell->expects($this->at(0))->method('runCommand')
 			->will($this->returnValue(true));
 		$Shell->expects($this->at(1))->method('runCommand')
@@ -198,7 +198,7 @@ class ShellDispatcherTest extends TestCase {
 
 		$dispatcher->args = array('example');
 		$result = $dispatcher->dispatch();
-		$this->assertEquals(1, $result);
+		$this->assertEquals(0, $result);
 	}
 
 /**
@@ -225,7 +225,7 @@ class ShellDispatcherTest extends TestCase {
 
 		$dispatcher->args = ['Example'];
 		$result = $dispatcher->dispatch();
-		$this->assertEquals(1, $result);
+		$this->assertEquals(0, $result);
 	}
 
 /**
@@ -252,7 +252,7 @@ class ShellDispatcherTest extends TestCase {
 
 		$dispatcher->args = array('sample');
 		$result = $dispatcher->dispatch();
-		$this->assertEquals(1, $result);
+		$this->assertEquals(0, $result);
 	}
 
 /**