mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 11:28:25 +00:00
Updating test cases to use new objects.
Preventing ConsoleOutput and ConsoleInput constructors from being run as it causes too many files open exceptions.
This commit is contained in:
parent
73ad3043a2
commit
41db1485aa
17 changed files with 98 additions and 73 deletions
|
@ -33,7 +33,7 @@ class ConsoleErrorHandlerTest extends CakeTestCase {
|
|||
*/
|
||||
function getErrorHandler($exception) {
|
||||
$error = new ConsoleErrorHandler($exception);
|
||||
$error->stderr = $this->getMock('ConsoleOutput');
|
||||
$error->stderr = $this->getMock('ConsoleOutput', array(), array(), '', false);
|
||||
return $error;
|
||||
}
|
||||
|
||||
|
|
|
@ -49,6 +49,9 @@ class AclShellTest extends CakeTestCase {
|
|||
Configure::write('Acl.database', 'test');
|
||||
Configure::write('Acl.classname', 'DbAcl');
|
||||
|
||||
$out = $this->getMock('ConsoleOutput', array(), array(), '', false);
|
||||
$in = $this->getMock('ConsoleInput', array(), array(), '', false);
|
||||
|
||||
$this->Dispatcher = $this->getMock(
|
||||
'ShellDispatcher',
|
||||
array('_stop', '_initEnvironment', 'dispatch')
|
||||
|
@ -56,7 +59,7 @@ class AclShellTest extends CakeTestCase {
|
|||
$this->Task = $this->getMock(
|
||||
'AclShell',
|
||||
array('in', 'out', 'hr', 'createFile', 'error', 'err'),
|
||||
array(&$this->Dispatcher)
|
||||
array(&$this->Dispatcher, $out, $out, $in)
|
||||
);
|
||||
$collection = new ComponentCollection();
|
||||
$this->Task->Acl = new AclComponent($collection);
|
||||
|
|
|
@ -38,6 +38,9 @@ class ApiShellTest extends CakeTestCase {
|
|||
*/
|
||||
public function setUp() {
|
||||
parent::setUp();
|
||||
$out = $this->getMock('ConsoleOutput', array(), array(), '', false);
|
||||
$in = $this->getMock('ConsoleInput', array(), array(), '', false);
|
||||
|
||||
$this->Dispatcher = $this->getMock(
|
||||
'ShellDispatcher',
|
||||
array('_stop', '_initEnvironment', 'dispatch')
|
||||
|
@ -45,7 +48,7 @@ class ApiShellTest extends CakeTestCase {
|
|||
$this->Shell = $this->getMock(
|
||||
'ApiShell',
|
||||
array('in', 'out', 'createFile', 'hr', '_stop'),
|
||||
array(&$this->Dispatcher)
|
||||
array(&$this->Dispatcher, $out, $out, $in)
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -50,6 +50,9 @@ class BakeShellTest extends CakeTestCase {
|
|||
*/
|
||||
public function setUp() {
|
||||
parent::setUp();
|
||||
$out = $this->getMock('ConsoleOutput', array(), array(), '', false);
|
||||
$in = $this->getMock('ConsoleInput', array(), array(), '', false);
|
||||
|
||||
$this->Dispatcher = $this->getMock(
|
||||
'ShellDispatcher',
|
||||
array('_stop', '_initEnvironment')
|
||||
|
@ -57,7 +60,7 @@ class BakeShellTest extends CakeTestCase {
|
|||
$this->Shell = $this->getMock(
|
||||
'BakeShell',
|
||||
array('in', 'out', 'hr', 'err', 'createFile', '_stop', '_checkUnitTest'),
|
||||
array(&$this->Dispatcher)
|
||||
array(&$this->Dispatcher, $out, $out, $in)
|
||||
);
|
||||
$this->Shell->Dispatch->shellPaths = App::path('shells');
|
||||
}
|
||||
|
|
|
@ -53,12 +53,12 @@ class CommandListTest extends CakeTestCase {
|
|||
array('_stop', '_initEnvironment', 'dispatch')
|
||||
);
|
||||
$out = new TestStringOutput();
|
||||
$in = $this->getMock('ConsoleInput');
|
||||
$in = $this->getMock('ConsoleInput', array(), array(), '', false);
|
||||
|
||||
$this->Shell = $this->getMock(
|
||||
'CommandListShell',
|
||||
array('in', '_stop', 'clear'),
|
||||
array(&$this->Dispatcher, $out, null, $in)
|
||||
array(&$this->Dispatcher, $out, $out, $in)
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -108,15 +108,16 @@ class SchemaShellTest extends CakeTestCase {
|
|||
*
|
||||
* @return void
|
||||
*/
|
||||
public function setup() {
|
||||
$this->Dispatcher = $this->getMock(
|
||||
'ShellDispatcher',
|
||||
array('getInput', 'stdout', 'stderr', '_stop', '_initEnvironment', 'clear')
|
||||
);
|
||||
public function setUp() {
|
||||
parent::setUp();
|
||||
|
||||
$out = $this->getMock('ConsoleOutput', array(), array(), '', false);
|
||||
$in = $this->getMock('ConsoleInput', array(), array(), '', false);
|
||||
$this->Dispatcher = $this->getMock('ShellDispatcher', array('_stop', '_initEnvironment'));
|
||||
$this->Shell = $this->getMock(
|
||||
'SchemaShell',
|
||||
array('in', 'out', 'hr', 'createFile', 'error', 'err', '_stop'),
|
||||
array(&$this->Dispatcher)
|
||||
array(&$this->Dispatcher, $out, $out, $in)
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -125,13 +126,12 @@ class SchemaShellTest extends CakeTestCase {
|
|||
*
|
||||
* @return void
|
||||
*/
|
||||
public function teardown() {
|
||||
ClassRegistry::flush();
|
||||
public function tearDown() {
|
||||
parent::tearDown();
|
||||
if (!empty($this->file) && $this->file instanceof File) {
|
||||
$this->file->delete();
|
||||
unset($this->file);
|
||||
}
|
||||
App::build();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -108,9 +108,9 @@ class ShellTest extends CakeTestCase {
|
|||
'ShellDispatcher',
|
||||
array('getInput', 'stdout', 'stderr', '_stop', '_initEnvironment', 'clear')
|
||||
);
|
||||
$output = $this->getMock('ConsoleOutput');
|
||||
$error = $this->getMock('ConsoleOutput');
|
||||
$in = $this->getMock('ConsoleInput');
|
||||
$output = $this->getMock('ConsoleOutput', array(), array(), '', false);
|
||||
$error = $this->getMock('ConsoleOutput', array(), array(), '', false);
|
||||
$in = $this->getMock('ConsoleInput', array(), array(), '', false);
|
||||
$this->Shell =& new TestShell($this->Dispatcher, $output, $error, $in);
|
||||
}
|
||||
|
||||
|
|
|
@ -68,8 +68,8 @@ class ControllerTaskTest extends CakeTestCase {
|
|||
*/
|
||||
public function setUp() {
|
||||
$this->Dispatcher = $this->getMock('ShellDispatcher', array('_stop', '_initEnvironment'));
|
||||
$out = $this->getMock('ConsoleOutput');
|
||||
$in = $this->getMock('ConsoleInput');
|
||||
$out = $this->getMock('ConsoleOutput', array(), array(), '', false);
|
||||
$in = $this->getMock('ConsoleInput', array(), array(), '', false);
|
||||
$this->Task = $this->getMock('ControllerTask',
|
||||
array('in', 'out', 'err', 'hr', 'createFile', '_stop', '_checkUnitTest'),
|
||||
array(&$this->Dispatcher, $out, $out, $in)
|
||||
|
|
|
@ -60,8 +60,8 @@ class DbConfigTaskTest extends CakeTestCase {
|
|||
*/
|
||||
public function setUp() {
|
||||
parent::setUp();
|
||||
$out = $this->getMock('ConsoleOutput');
|
||||
$in = $this->getMock('ConsoleInput');
|
||||
$out = $this->getMock('ConsoleOutput', array(), array(), '', false);
|
||||
$in = $this->getMock('ConsoleInput', array(), array(), '', false);
|
||||
|
||||
$this->Dispatcher = $this->getMock('ShellDispatcher', array('_stop', '_initEnvironment'));
|
||||
$this->Task = $this->getMock('DbConfigTask',
|
||||
|
@ -116,7 +116,7 @@ class DbConfigTaskTest extends CakeTestCase {
|
|||
public function testExecuteIntoInteractive() {
|
||||
$this->Task->initialize();
|
||||
|
||||
$out = $this->getMock('ConsoleOutput');
|
||||
$out = $this->getMock('ConsoleOutput', array(), array(), '', false);
|
||||
$this->Task = $this->getMock(
|
||||
'DbConfigTask',
|
||||
array('in', '_stop', 'createFile'), array(&$this->Dispatcher, $out, $out)
|
||||
|
|
|
@ -39,10 +39,11 @@ class ExtractTaskTest extends CakeTestCase {
|
|||
* @return void
|
||||
*/
|
||||
public function setUp() {
|
||||
$this->Dispatcher = $this->getMock('ShellDispatcher', array(
|
||||
'getInput', 'stdout', 'stderr', '_stop', '_initEnvironment', 'clear'
|
||||
));
|
||||
$this->Task =& new ExtractTask($this->Dispatcher);
|
||||
$out = $this->getMock('ConsoleOutput', array(), array(), '', false);
|
||||
$in = $this->getMock('ConsoleInput', array(), array(), '', false);
|
||||
|
||||
$this->Dispatcher = $this->getMock('ShellDispatcher', array('_stop', '_initEnvironment'));
|
||||
$this->Task = new ExtractTask($this->Dispatcher, $out, $out, $in);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -51,7 +52,8 @@ class ExtractTaskTest extends CakeTestCase {
|
|||
* @return void
|
||||
*/
|
||||
public function tearDown() {
|
||||
ClassRegistry::flush();
|
||||
parent::tearDown();
|
||||
unset($this->Task, $this->Dispatcher);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -46,8 +46,8 @@ class FixtureTaskTest extends CakeTestCase {
|
|||
*/
|
||||
public function setUp() {
|
||||
parent::setUp();
|
||||
$out = $this->getMock('ConsoleOutput');
|
||||
$in = $this->getMock('ConsoleInput');
|
||||
$out = $this->getMock('ConsoleOutput', array(), array(), '', false);
|
||||
$in = $this->getMock('ConsoleInput', array(), array(), '', false);
|
||||
|
||||
$this->Dispatcher = $this->getMock('ShellDispatcher', array('_stop', '_initEnvironment'));
|
||||
$this->Task = $this->getMock('FixtureTask',
|
||||
|
@ -79,8 +79,8 @@ class FixtureTaskTest extends CakeTestCase {
|
|||
* @return void
|
||||
*/
|
||||
public function testConstruct() {
|
||||
$out = $this->getMock('ConsoleOutput');
|
||||
$in = $this->getMock('ConsoleInput');
|
||||
$out = $this->getMock('ConsoleOutput', array(), array(), '', false);
|
||||
$in = $this->getMock('ConsoleInput', array(), array(), '', false);
|
||||
|
||||
$this->Dispatcher->params['working'] = DS . 'my' . DS . 'path';
|
||||
$Task = new FixtureTask($this->Dispatcher, $out, $out, $in);
|
||||
|
|
|
@ -49,12 +49,13 @@ class ModelTaskTest extends CakeTestCase {
|
|||
*/
|
||||
public function setUp() {
|
||||
parent::setUp();
|
||||
$this->Dispatcher = $this->getMock('ShellDispatcher', array(
|
||||
'getInput', 'stdout', 'stderr', '_stop', '_initEnvironment', 'clear'
|
||||
));
|
||||
$out = $this->getMock('ConsoleOutput', array(), array(), '', false);
|
||||
$in = $this->getMock('ConsoleInput', array(), array(), '', false);
|
||||
|
||||
$this->Dispatcher = $this->getMock('ShellDispatcher', array('_stop', '_initEnvironment'));
|
||||
$this->Task = $this->getMock('ModelTask',
|
||||
array('in', 'err', 'createFile', '_stop', '_checkUnitTest'),
|
||||
array(&$this->Dispatcher)
|
||||
array(&$this->Dispatcher, $out, $out, $in)
|
||||
);
|
||||
$this->_setupOtherMocks();
|
||||
}
|
||||
|
@ -65,9 +66,12 @@ class ModelTaskTest extends CakeTestCase {
|
|||
* @return void
|
||||
*/
|
||||
protected function _useMockedOut() {
|
||||
$out = $this->getMock('ConsoleOutput', array(), array(), '', false);
|
||||
$in = $this->getMock('ConsoleInput', array(), array(), '', false);
|
||||
|
||||
$this->Task = $this->getMock('ModelTask',
|
||||
array('in', 'out', 'err', 'hr', 'createFile', '_stop', '_checkUnitTest'),
|
||||
array(&$this->Dispatcher)
|
||||
array(&$this->Dispatcher, $out, $out, $in)
|
||||
);
|
||||
$this->_setupOtherMocks();
|
||||
}
|
||||
|
@ -78,9 +82,12 @@ class ModelTaskTest extends CakeTestCase {
|
|||
* @return void
|
||||
*/
|
||||
protected function _setupOtherMocks() {
|
||||
$this->Task->Fixture = $this->getMock('FixtureTask', array(), array(&$this->Dispatcher));
|
||||
$this->Task->Test = $this->getMock('FixtureTask', array(), array(&$this->Dispatcher));
|
||||
$this->Task->Template =& new TemplateTask($this->Task->Dispatch);
|
||||
$out = $this->getMock('ConsoleOutput', array(), array(), '', false);
|
||||
$in = $this->getMock('ConsoleInput', array(), array(), '', false);
|
||||
|
||||
$this->Task->Fixture = $this->getMock('FixtureTask', array(), array(&$this->Dispatcher, $out, $out, $in));
|
||||
$this->Task->Test = $this->getMock('FixtureTask', array(), array(&$this->Dispatcher, $out, $out, $in));
|
||||
$this->Task->Template =& new TemplateTask($this->Task->Dispatch, $out, $out, $in);
|
||||
|
||||
$this->Task->name = 'ModelTask';
|
||||
$this->Task->interactive = true;
|
||||
|
|
|
@ -41,13 +41,13 @@ class PluginTaskTest extends CakeTestCase {
|
|||
*/
|
||||
public function setUp() {
|
||||
parent::setUp();
|
||||
$out = $this->getMock('ConsoleOutput', array(), array(), '', false);
|
||||
$in = $this->getMock('ConsoleInput', array(), array(), '', false);
|
||||
|
||||
$this->Dispatcher = $this->getMock('ShellDispatcher', array(
|
||||
'getInput', 'stdout', 'stderr', '_stop', '_initEnvironment', 'clear'
|
||||
));
|
||||
$this->Dispatcher = $this->getMock('ShellDispatcher', array('_stop', '_initEnvironment'));
|
||||
$this->Task = $this->getMock('PluginTask',
|
||||
array('in', 'err', 'createFile', '_stop'),
|
||||
array(&$this->Dispatcher)
|
||||
array('in', 'err', 'createFile', '_stop', 'clear'),
|
||||
array(&$this->Dispatcher, $out, $out, $in)
|
||||
);
|
||||
$this->Task->path = TMP . 'tests' . DS;
|
||||
|
||||
|
@ -221,7 +221,10 @@ class PluginTaskTest extends CakeTestCase {
|
|||
* @return void
|
||||
*/
|
||||
public function testExecuteWithTwoArgs() {
|
||||
$this->Task->Model = $this->getMock('ModelTask', array(), array(&$this->Dispatcher));
|
||||
$out = $this->getMock('ConsoleOutput', array(), array(), '', false);
|
||||
$in = $this->getMock('ConsoleInput', array(), array(), '', false);
|
||||
|
||||
$this->Task->Model = $this->getMock('ModelTask', array(), array(&$this->Dispatcher, $out, $out, $in));
|
||||
|
||||
$this->Task->expects($this->at(0))->method('in')->will($this->returnValue($this->_testPath));
|
||||
|
||||
|
|
|
@ -41,12 +41,13 @@ class ProjectTaskTest extends CakeTestCase {
|
|||
*/
|
||||
public function setUp() {
|
||||
parent::setUp();
|
||||
$this->Dispatcher = $this->getMock('ShellDispatcher', array(
|
||||
'getInput', 'stdout', 'stderr', '_stop', '_initEnvironment', 'clear'
|
||||
));
|
||||
$out = $this->getMock('ConsoleOutput', array(), array(), '', false);
|
||||
$in = $this->getMock('ConsoleInput', array(), array(), '', false);
|
||||
|
||||
$this->Dispatcher = $this->getMock('ShellDispatcher', array('_stop', '_initEnvironment', 'clear'));
|
||||
$this->Task = $this->getMock('ProjectTask',
|
||||
array('in', 'err', 'createFile', '_stop'),
|
||||
array(&$this->Dispatcher)
|
||||
array(&$this->Dispatcher, $out, $out, $in)
|
||||
);
|
||||
$this->Dispatcher->shellPaths = App::path('shells');
|
||||
$this->Task->path = TMP . 'tests' . DS;
|
||||
|
|
|
@ -39,12 +39,14 @@ class TemplateTaskTest extends CakeTestCase {
|
|||
* @return void
|
||||
*/
|
||||
public function setup() {
|
||||
$this->Dispatcher = $this->getMock('ShellDispatcher', array(
|
||||
'getInput', 'stdout', 'stderr', '_stop', '_initEnvironment', 'clear'
|
||||
));
|
||||
parent::setUp();
|
||||
$out = $this->getMock('ConsoleOutput', array(), array(), '', false);
|
||||
$in = $this->getMock('ConsoleInput', array(), array(), '', false);
|
||||
|
||||
$this->Dispatcher = $this->getMock('ShellDispatcher', array('_stop', '_initEnvironment'));
|
||||
$this->Task = $this->getMock('TemplateTask',
|
||||
array('in', 'err', 'createFile', '_stop'),
|
||||
array(&$this->Dispatcher)
|
||||
array('in', 'err', 'createFile', '_stop', 'clear'),
|
||||
array(&$this->Dispatcher, $out, $out, $in)
|
||||
);
|
||||
$this->Task->Dispatch->shellPaths = App::path('shells');
|
||||
}
|
||||
|
@ -54,10 +56,9 @@ class TemplateTaskTest extends CakeTestCase {
|
|||
*
|
||||
* @return void
|
||||
*/
|
||||
public function teardown() {
|
||||
public function tearDown() {
|
||||
parent::tearDown();
|
||||
unset($this->Task, $this->Dispatcher);
|
||||
ClassRegistry::flush();
|
||||
App::build();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -239,16 +239,17 @@ class TestTaskTest extends CakeTestCase {
|
|||
*/
|
||||
public function setup() {
|
||||
parent::setup();
|
||||
$this->Dispatcher = $this->getMock('ShellDispatcher', array(
|
||||
'getInput', 'stdout', 'stderr', '_stop', '_initEnvironment', 'clear'
|
||||
));
|
||||
$out = $this->getMock('ConsoleOutput', array(), array(), '', false);
|
||||
$in = $this->getMock('ConsoleInput', array(), array(), '', false);
|
||||
|
||||
$this->Dispatcher = $this->getMock('ShellDispatcher', array('_stop', '_initEnvironment'));
|
||||
$this->Task = $this->getMock('TestTask',
|
||||
array('in', 'err', 'createFile', '_stop', 'isLoadableClass'),
|
||||
array(&$this->Dispatcher)
|
||||
array(&$this->Dispatcher, $out, $out, $in)
|
||||
);
|
||||
$this->Dispatcher->shellPaths = App::path('shells');
|
||||
$this->Task->name = 'TestTask';
|
||||
$this->Task->Template = new TemplateTask($this->Dispatcher);
|
||||
$this->Task->Template = new TemplateTask($this->Dispatcher, $out, $out, $in);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -256,9 +257,9 @@ class TestTaskTest extends CakeTestCase {
|
|||
*
|
||||
* @return void
|
||||
*/
|
||||
public function teardown() {
|
||||
parent::teardown();
|
||||
ClassRegistry::flush();
|
||||
public function tearDown() {
|
||||
parent::tearDown();
|
||||
unset($this->Task, $this->Dispatcher);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -222,16 +222,17 @@ class ViewTaskTest extends CakeTestCase {
|
|||
*/
|
||||
public function setUp() {
|
||||
parent::setUp();
|
||||
$this->Dispatcher = $this->getMock('ShellDispatcher', array(
|
||||
'getInput', 'stdout', 'stderr', '_stop', '_initEnvironment', 'clear'
|
||||
));
|
||||
$out = $this->getMock('ConsoleOutput', array(), array(), '', false);
|
||||
$in = $this->getMock('ConsoleInput', array(), array(), '', false);
|
||||
|
||||
$this->Dispatcher = $this->getMock('ShellDispatcher', array('_stop', '_initEnvironment'));
|
||||
$this->Task = $this->getMock('ViewTask',
|
||||
array('in', 'err', 'createFile', '_stop'),
|
||||
array(&$this->Dispatcher)
|
||||
array(&$this->Dispatcher, $out, $out, $in)
|
||||
);
|
||||
$this->Task->Template = new TemplateTask($this->Dispatcher);
|
||||
$this->Task->Controller = $this->getMock('ControllerTask', array(), array(&$this->Dispatcher));
|
||||
$this->Task->Project = $this->getMock('ProjectTask', array(), array(&$this->Dispatcher));
|
||||
$this->Task->Template = new TemplateTask($this->Dispatcher, $out, $out, $in);
|
||||
$this->Task->Controller = $this->getMock('ControllerTask', array(), array(&$this->Dispatcher, $out, $out, $in));
|
||||
$this->Task->Project = $this->getMock('ProjectTask', array(), array(&$this->Dispatcher, $out, $out, $in));
|
||||
|
||||
$this->Dispatcher->shellPaths = App::path('shells');
|
||||
$this->Task->path = TMP;
|
||||
|
|
Loading…
Reference in a new issue