2009-02-13 14:22:11 +00:00
|
|
|
<?php
|
|
|
|
/* SVN FILE: $Id$ */
|
|
|
|
/**
|
|
|
|
* Test Case for test generation shell task
|
|
|
|
*
|
2009-03-13 16:06:18 +00:00
|
|
|
* Long description for file
|
2009-02-13 14:22:11 +00:00
|
|
|
*
|
|
|
|
* PHP versions 4 and 5
|
|
|
|
*
|
|
|
|
* CakePHP : Rapid Development Framework (http://www.cakephp.org)
|
|
|
|
* Copyright 2006-2008, Cake Software Foundation, Inc.
|
|
|
|
*
|
|
|
|
* Licensed under The MIT License
|
|
|
|
* Redistributions of files must retain the above copyright notice.
|
|
|
|
*
|
|
|
|
* @filesource
|
|
|
|
* @copyright Copyright 2006-2008, Cake Software Foundation, Inc.
|
|
|
|
* @link http://www.cakefoundation.org/projects/info/cakephp CakePHP Project
|
2009-03-13 16:06:18 +00:00
|
|
|
* @package cake.tests
|
|
|
|
* @subpackage cake.tests.cases.console.libs.tasks
|
2009-02-13 14:22:11 +00:00
|
|
|
* @since CakePHP v 1.2.0.7726
|
|
|
|
* @version $Revision$
|
|
|
|
* @modifiedby $LastChangedBy$
|
|
|
|
* @lastmodified $Date$
|
|
|
|
* @license http://www.opensource.org/licenses/mit-license.php The MIT License
|
|
|
|
*/
|
|
|
|
App::import('Core', 'Shell');
|
|
|
|
|
|
|
|
if (!defined('DISABLE_AUTO_DISPATCH')) {
|
|
|
|
define('DISABLE_AUTO_DISPATCH', true);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!class_exists('ShellDispatcher')) {
|
|
|
|
ob_start();
|
|
|
|
$argv = false;
|
|
|
|
require CAKE . 'console' . DS . 'cake.php';
|
|
|
|
ob_end_clean();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!class_exists('TestTask')) {
|
|
|
|
require CAKE . 'console' . DS . 'libs' . DS . 'tasks' . DS . 'test.php';
|
|
|
|
}
|
|
|
|
|
2009-03-13 16:06:18 +00:00
|
|
|
Mock::generatePartial(
|
|
|
|
'ShellDispatcher', 'TestTestTaskMockShellDispatcher',
|
|
|
|
array('getInput', 'stdout', 'stderr', '_stop', '_initEnvironment')
|
|
|
|
);
|
|
|
|
Mock::generatePartial(
|
|
|
|
'TestTask', 'MockTestTask',
|
|
|
|
array('in', 'out', 'createFile')
|
|
|
|
);
|
|
|
|
/**
|
|
|
|
* TestTaskTest class
|
|
|
|
*
|
|
|
|
* @package cake.tests
|
|
|
|
* @subpackage cake.tests.cases.console.libs.tasks
|
|
|
|
*/
|
2009-02-13 14:22:11 +00:00
|
|
|
class TestTaskTest extends CakeTestCase {
|
2009-03-13 16:06:18 +00:00
|
|
|
/**
|
|
|
|
* setUp method
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
* @access public
|
|
|
|
*/
|
2009-02-13 14:22:11 +00:00
|
|
|
function setUp() {
|
2009-03-13 16:06:18 +00:00
|
|
|
$this->Dispatcher =& new TestTestTaskMockShellDispatcher();
|
|
|
|
$this->Task =& new MockTestTask($this->Dispatcher);
|
|
|
|
$this->Task->Dispatch = new $this->Dispatcher;
|
|
|
|
}
|
|
|
|
/**
|
|
|
|
* tearDown method
|
|
|
|
*
|
|
|
|
* @return void
|
|
|
|
* @access public
|
|
|
|
*/
|
|
|
|
function tearDown() {
|
|
|
|
ClassRegistry::flush();
|
2009-02-13 14:22:11 +00:00
|
|
|
}
|
|
|
|
/**
|
|
|
|
* Test that file path generation doesn't continuously append paths.
|
2009-03-13 16:06:18 +00:00
|
|
|
*
|
2009-02-13 14:22:11 +00:00
|
|
|
* @access public
|
|
|
|
* @return void
|
|
|
|
*/
|
|
|
|
function testFilePathGeneration () {
|
2009-03-13 16:06:18 +00:00
|
|
|
$file = TESTS . 'cases' . DS . 'models' . DS . 'my_class.test.php';
|
2009-02-13 14:22:11 +00:00
|
|
|
|
2009-03-13 16:06:18 +00:00
|
|
|
$this->Task->Dispatch->expectNever('stderr');
|
|
|
|
$this->Task->Dispatch->expectNever('_stop');
|
|
|
|
|
|
|
|
$this->Task->setReturnValueAt(0, 'in', 'y');
|
|
|
|
$this->Task->expectAt(0, 'createFile', array($file, '*'));
|
|
|
|
$this->Task->bake('Model', 'MyClass');
|
|
|
|
|
|
|
|
$this->Task->setReturnValueAt(1, 'in', 'y');
|
|
|
|
$this->Task->expectAt(1, 'createFile', array($file, '*'));
|
|
|
|
$this->Task->bake('Model', 'MyClass');
|
2009-02-13 14:22:11 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
?>
|