Removing ShellDispatcher as a constructor argument for Shell.

Updating the AclShell test case.
This commit is contained in:
mark_story 2010-10-24 14:55:16 -04:00
parent 0b2a6acc64
commit ba17e2c9a0
4 changed files with 8 additions and 23 deletions

View file

@ -20,12 +20,11 @@ App::import('Core', 'ObjectCollection');
class TaskCollection extends ObjectCollection {
/**
* Shell to give to tasks. and use to find tasks.
* Shell to use to set params to tasks.
*
* @var array
*/
protected $_Shell;
protected $_Dispatch;
/**
* The directory inside each shell path that contains tasks.
@ -40,10 +39,10 @@ class TaskCollection extends ObjectCollection {
* @param array $paths Array of paths to search for tasks on .
* @return void
*/
public function __construct(Shell $Shell, ShellDispatcher $dispatcher) {
public function __construct(Shell $Shell) {
$this->_Shell = $Shell;
$this->_Dispatch = $dispatcher;
}
/**
* Loads/constructs a task. Will return the instance in the collection
* if it already exists.
@ -72,7 +71,7 @@ class TaskCollection extends ObjectCollection {
}
$this->_loaded[$name] = new $taskClass(
$this->_Dispatch, $this->_Shell->stdout, $this->_Shell->stderr, $this->_Shell->stdin
$this->_Shell->stdout, $this->_Shell->stderr, $this->_Shell->stdin
);
if ($enable === true) {
$this->_enabled[] = $name;

View file

@ -223,7 +223,7 @@ class ShellDispatcher {
if (!class_exists($class)) {
throw new MissingShellClassException(array('shell' => $class));
}
$Shell = new $class($this);
$Shell = new $class();
return $Shell;
}

View file

@ -37,14 +37,6 @@ class Shell extends Object {
const NORMAL = 1;
const QUIET = 0;
/**
* An instance of the ShellDispatcher object that loaded this script
*
* @var ShellDispatcher
* @access public
*/
public $Dispatch = null;
/**
* An instance of ConsoleOptionParser that has been configured for this class.
*
@ -154,13 +146,11 @@ class Shell extends Object {
* Constructs this Shell instance.
*
*/
function __construct(&$dispatch, $stdout = null, $stderr = null, $stdin = null) {
function __construct($stdout = null, $stderr = null, $stdin = null) {
if ($this->name == null) {
$this->name = Inflector::underscore(str_replace(array('Shell', 'Task'), '', get_class($this)));
}
$this->Dispatch =& $dispatch;
$this->Tasks = new TaskCollection($this, $dispatch);
$this->Tasks = new TaskCollection($this);
$this->stdout = $stdout;
$this->stderr = $stderr;

View file

@ -52,14 +52,10 @@ class AclShellTest extends CakeTestCase {
$out = $this->getMock('ConsoleOutput', array(), array(), '', false);
$in = $this->getMock('ConsoleInput', array(), array(), '', false);
$this->Dispatcher = $this->getMock(
'ShellDispatcher',
array('_stop', '_initEnvironment', 'dispatch')
);
$this->Task = $this->getMock(
'AclShell',
array('in', 'out', 'hr', 'createFile', 'error', 'err', 'clear', 'dispatchShell'),
array(&$this->Dispatcher, $out, $out, $in)
array($out, $out, $in)
);
$collection = new ComponentCollection();
$this->Task->Acl = new AclComponent($collection);