Skip to content
Permalink
Browse files

Removing ShellDispatcher as a constructor argument for Shell.

Updating the AclShell test case.
  • Loading branch information...
markstory committed Oct 24, 2010
1 parent 0b2a6ac commit ba17e2c9a0ebdb0e686b84b9f6b8468646637182
@@ -20,12 +20,11 @@
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 @@ public function load($task, $settings = array(), $enable = true) {
}
$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;
@@ -223,7 +223,7 @@ protected function _getShell($shell) {
if (!class_exists($class)) {
throw new MissingShellClassException(array('shell' => $class));
}
$Shell = new $class($this);
$Shell = new $class();
return $Shell;
}
@@ -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;
@@ -52,14 +52,10 @@ public function setUp() {
$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);

0 comments on commit ba17e2c

Please sign in to comment.
You can’t perform that action at this time.