mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
parent
5d3fdfc9d6
commit
bc6de18417
3 changed files with 15 additions and 6 deletions
|
@ -450,7 +450,7 @@ class ShellDispatcher {
|
|||
}
|
||||
$result = trim($result);
|
||||
|
||||
if ($default != null && empty($result)) {
|
||||
if ($default !== null && ($result === '' || $result === null)) {
|
||||
return $default;
|
||||
}
|
||||
return $result;
|
||||
|
@ -471,7 +471,6 @@ class ShellDispatcher {
|
|||
return fwrite($this->stdout, $string);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Outputs to the stderr filehandle.
|
||||
*
|
||||
|
|
|
@ -347,13 +347,11 @@ class Shell extends Object {
|
|||
}
|
||||
}
|
||||
if (is_array($options)) {
|
||||
while ($in == '' || ($in && (!in_array(strtolower($in), $options) && !in_array(strtoupper($in), $options)) && !in_array($in, $options))) {
|
||||
while ($in === '' || ($in !== '' && (!in_array(strtolower($in), $options) && !in_array(strtoupper($in), $options)) && !in_array($in, $options))) {
|
||||
$in = $this->Dispatch->getInput($prompt, $options, $default);
|
||||
}
|
||||
}
|
||||
if ($in) {
|
||||
return $in;
|
||||
}
|
||||
return $in;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -208,6 +208,18 @@ class ShellTest extends CakeTestCase {
|
|||
$result = $this->Shell->in('Just a test?', 'y', 'y');
|
||||
$this->assertEqual($result, 'y');
|
||||
|
||||
$this->Shell->Dispatch->setReturnValueAt(5, 'getInput', 'y');
|
||||
$this->Shell->Dispatch->expectAt(5, 'getInput', array('Just a test?', array(0, 1, 2), 0));
|
||||
$result = $this->Shell->in('Just a test?', array(0, 1, 2), 0);
|
||||
$this->assertEqual($result, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test in() when not interactive
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function testInNonInteractive() {
|
||||
$this->Shell->interactive = false;
|
||||
|
||||
$result = $this->Shell->in('Just a test?', 'y/n', 'n');
|
||||
|
|
Loading…
Reference in a new issue