mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Adding return from _stop() to help testing.
Updating tests for getName()
This commit is contained in:
parent
9647e359c4
commit
8ac46c3b63
2 changed files with 22 additions and 18 deletions
|
@ -409,10 +409,9 @@ class ControllerTask extends BakeTask {
|
|||
|
||||
while ($enteredController == '') {
|
||||
$enteredController = $this->in(__("Enter a number from the list above,\ntype in the name of another controller, or 'q' to exit"), null, 'q');
|
||||
|
||||
if ($enteredController === 'q') {
|
||||
$this->out(__('Exit'));
|
||||
$this->_stop();
|
||||
return $this->_stop();
|
||||
}
|
||||
|
||||
if ($enteredController == '' || intval($enteredController) > count($controllers)) {
|
||||
|
|
|
@ -139,27 +139,32 @@ class ControllerTaskTest extends CakeTestCase {
|
|||
*
|
||||
* @return void
|
||||
*/
|
||||
public function xxtestGetName() {
|
||||
public function testGetNameValidIndex() {
|
||||
$this->Task->interactive = true;
|
||||
$this->Task->expects($this->any())->method('in')->will($this->returnValue(1));
|
||||
|
||||
$this->Task->expects($this->at(0))->method('in')->will($this->returnValue('q'));
|
||||
$this->Task->expectOnce('_stop');
|
||||
$this->Task->getName('test_suite');
|
||||
|
||||
$this->Task->expects($this->at(1))->method('in')->will($this->returnValue(1));
|
||||
$result = $this->Task->getName('test_suite');
|
||||
$expected = 'Articles';
|
||||
$this->assertEqual($result, $expected);
|
||||
|
||||
$this->Task->expects($this->at(2))->method('in')->will($this->returnValue(3));
|
||||
$this->Task->expects($this->at(5))->method('in')->will($this->returnValue(3));
|
||||
$result = $this->Task->getName('test_suite');
|
||||
$expected = 'Comments';
|
||||
$this->assertEqual($result, $expected);
|
||||
|
||||
$this->Task->expects($this->at(3))->method('in')->will($this->returnValue(10));
|
||||
$this->Task->expects($this->at(7))->method('in')->will($this->returnValue(1));
|
||||
$result = $this->Task->getName('test_suite');
|
||||
$this->Task->expectOnce('err');
|
||||
$expected = 'Articles';
|
||||
$this->assertEqual($result, $expected);
|
||||
}
|
||||
|
||||
/**
|
||||
* test getting invalid indexes.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function testGetNameInvalidIndex() {
|
||||
$this->Task->interactive = true;
|
||||
$this->Task->expects($this->at(5))->method('in')->will($this->returnValue(10));
|
||||
$this->Task->expects($this->at(7))->method('in')->will($this->returnValue('q'));
|
||||
$this->Task->expects($this->once())->method('err');
|
||||
$this->Task->expects($this->once())->method('_stop');
|
||||
|
||||
$this->Task->getName('test_suite');
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue