mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Add test for shell unknown option
This commit is contained in:
parent
65841081e9
commit
7e50fc9ee6
1 changed files with 26 additions and 0 deletions
|
@ -778,6 +778,32 @@ class ShellTest extends CakeTestCase {
|
||||||
$this->assertFalse($result);
|
$this->assertFalse($result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* test unknown option causes display of error and help.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function testRunCommandUnknownOption() {
|
||||||
|
$output = $this->getMock('ConsoleOutput', array(), array(), '', false);
|
||||||
|
$error = $this->getMock('ConsoleOutput', array(), array(), '', false);
|
||||||
|
$in = $this->getMock('ConsoleInput', array(), array(), '', false);
|
||||||
|
|
||||||
|
$Parser = $this->getMock('ConsoleOptionParser', array(), array(), '', false);
|
||||||
|
$Parser->expects($this->once())->method('parse')
|
||||||
|
->with(array('--unknown'))
|
||||||
|
->will($this->throwException(new ConsoleException('Unknown option `unknown`')));
|
||||||
|
$Parser->expects($this->once())->method('help');
|
||||||
|
|
||||||
|
$Shell = $this->getMock('ShellTestShell', array('getOptionParser'), array($output, $error, $in));
|
||||||
|
|
||||||
|
$Shell->expects($this->once())->method('getOptionParser')
|
||||||
|
->will($this->returnValue($Parser));
|
||||||
|
$Shell->stderr->expects($this->once())->method('write');
|
||||||
|
$Shell->stdout->expects($this->once())->method('write');
|
||||||
|
|
||||||
|
$Shell->runCommand('do_something', array('do_something', '--unknown'));
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* test that a --help causes help to show.
|
* test that a --help causes help to show.
|
||||||
*
|
*
|
||||||
|
|
Loading…
Reference in a new issue