Skip to content

Commit

Permalink
remove stub class from controller tests template and mock condition to
Browse files Browse the repository at this point in the history
make it extends ControllerTestCase
  • Loading branch information
huoxito committed May 11, 2012
1 parent a238116 commit c651bf2
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 31 deletions.
2 changes: 1 addition & 1 deletion lib/Cake/Console/Command/Task/TestTask.php
Expand Up @@ -460,7 +460,7 @@ public function generateConstructor($type, $fullClassName, $plugin) {
} }
if ($type == 'controller') { if ($type == 'controller') {
$className = substr($fullClassName, 0, -10); $className = substr($fullClassName, 0, -10);
$construct = "new Test$fullClassName();\n"; $construct = "new $fullClassName();\n";
$post = "\$this->{$className}->constructClasses();\n"; $post = "\$this->{$className}->constructClasses();\n";
} }
if ($type == 'helper') { if ($type == 'helper') {
Expand Down
31 changes: 1 addition & 30 deletions lib/Cake/Console/Templates/default/classes/test.ctp
Expand Up @@ -23,40 +23,11 @@ echo "<?php\n";
App::uses('<?php echo $dependency[0]; ?>', '<?php echo $dependency[1]; ?>'); App::uses('<?php echo $dependency[0]; ?>', '<?php echo $dependency[1]; ?>');
<?php endforeach; ?> <?php endforeach; ?>


<?php if ($mock && strtolower($type) === 'controller'): ?>
/**
* Test<?php echo $fullClassName; ?>
*
*/
class Test<?php echo $fullClassName; ?> extends <?php echo $fullClassName; ?> {

/**
* Auto render
*
* @var boolean
*/
public $autoRender = false;

/**
* Redirect action
*
* @param mixed $url
* @param mixed $status
* @param boolean $exit
* @return void
*/
public function redirect($url, $status = null, $exit = true) {
$this->redirectUrl = $url;
}

}

<?php endif; ?>
/** /**
* <?php echo $fullClassName; ?> Test Case * <?php echo $fullClassName; ?> Test Case
* *
*/ */
<?php if ($mock and strtolower($type) == 'controller'): ?> <?php if ($type === 'Controller'): ?>
class <?php echo $fullClassName; ?>TestCase extends ControllerTestCase { class <?php echo $fullClassName; ?>TestCase extends ControllerTestCase {
<?php else: ?> <?php else: ?>
class <?php echo $fullClassName; ?>TestCase extends CakeTestCase { class <?php echo $fullClassName; ?>TestCase extends CakeTestCase {
Expand Down

0 comments on commit c651bf2

Please sign in to comment.