mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Merge branch '1.3' into 1.3-merge
Conflicts: cake/console/cake.php cake/console/libs/shell.php cake/tests/cases/console/libs/shell.test.php
This commit is contained in:
commit
788d38ccef
4 changed files with 44 additions and 12 deletions
|
@ -448,14 +448,12 @@ 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->_getInput($prompt, $options, $default);
|
||||
}
|
||||
}
|
||||
if ($in) {
|
||||
return $in;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Prompts the user for input, and returns it.
|
||||
|
@ -484,7 +482,7 @@ class Shell extends Object {
|
|||
}
|
||||
$result = trim($result);
|
||||
|
||||
if ($default != null && empty($result)) {
|
||||
if ($default !== null && ($result === '' || $result === null)) {
|
||||
return $default;
|
||||
}
|
||||
return $result;
|
||||
|
|
|
@ -214,6 +214,10 @@ class ShellTest extends CakeTestCase {
|
|||
->method('read')
|
||||
->will($this->returnValue('y'));
|
||||
|
||||
$this->Shell->stdin->expects($this->at(5))
|
||||
->method('read')
|
||||
->will($this->returnValue('0'));
|
||||
|
||||
$result = $this->Shell->in('Just a test?', array('y', 'n'), 'n');
|
||||
$this->assertEqual($result, 'n');
|
||||
|
||||
|
@ -229,6 +233,16 @@ class ShellTest extends CakeTestCase {
|
|||
$result = $this->Shell->in('Just a test?', 'y', 'y');
|
||||
$this->assertEqual($result, 'y');
|
||||
|
||||
$result = $this->Shell->in('Just a test?', array(0, 1, 2), '0');
|
||||
$this->assertEqual($result, '0');
|
||||
}
|
||||
|
||||
/**
|
||||
* Test in() when not interactive.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testInNonInteractive() {
|
||||
$this->Shell->interactive = false;
|
||||
|
||||
$result = $this->Shell->in('Just a test?', 'y/n', 'n');
|
||||
|
@ -517,13 +531,13 @@ class ShellTest extends CakeTestCase {
|
|||
|
||||
$this->Shell->interactive = false;
|
||||
|
||||
$contents = "<?php\necho 'test';\n\$te = 'st';\n?>";
|
||||
$contents = "<?php\necho 'test';\n\$te = 'st';\n";
|
||||
$result = $this->Shell->createFile($file, $contents);
|
||||
$this->assertTrue($result);
|
||||
$this->assertTrue(file_exists($file));
|
||||
$this->assertEqual(file_get_contents($file), $contents);
|
||||
|
||||
$contents = "<?php\necho 'another test';\n\$te = 'st';\n?>";
|
||||
$contents = "<?php\necho 'another test';\n\$te = 'st';\n";
|
||||
$result = $this->Shell->createFile($file, $contents);
|
||||
$this->assertTrue($result);
|
||||
$this->assertTrue(file_exists($file));
|
||||
|
@ -555,7 +569,7 @@ class ShellTest extends CakeTestCase {
|
|||
->will($this->returnValue('y'));
|
||||
|
||||
|
||||
$contents = "<?php\necho 'yet another test';\n\$te = 'st';\n?>";
|
||||
$contents = "<?php\necho 'yet another test';\n\$te = 'st';\n";
|
||||
$result = $this->Shell->createFile($file, $contents);
|
||||
$this->assertTrue($result);
|
||||
$this->assertTrue(file_exists($file));
|
||||
|
@ -593,13 +607,13 @@ class ShellTest extends CakeTestCase {
|
|||
|
||||
$this->Shell->interactive = false;
|
||||
|
||||
$contents = "<?php\r\necho 'test';\r\n\$te = 'st';\r\n?>";
|
||||
$contents = "<?php\r\necho 'test';\r\n\$te = 'st';\r\n";
|
||||
$result = $this->Shell->createFile($file, $contents);
|
||||
$this->assertTrue($result);
|
||||
$this->assertTrue(file_exists($file));
|
||||
$this->assertEqual(file_get_contents($file), $contents);
|
||||
|
||||
$contents = "<?php\r\necho 'another test';\r\n\$te = 'st';\r\n?>";
|
||||
$contents = "<?php\r\necho 'another test';\r\n\$te = 'st';\r\n";
|
||||
$result = $this->Shell->createFile($file, $contents);
|
||||
$this->assertTrue($result);
|
||||
$this->assertTrue(file_exists($file));
|
||||
|
@ -631,7 +645,7 @@ class ShellTest extends CakeTestCase {
|
|||
->will($this->returnValue('y'));
|
||||
|
||||
|
||||
$contents = "<?php\r\necho 'yet another test';\r\n\$te = 'st';\r\n?>";
|
||||
$contents = "<?php\r\necho 'yet another test';\r\n\$te = 'st';\r\n";
|
||||
$result = $this->Shell->createFile($file, $contents);
|
||||
$this->assertTrue($result);
|
||||
$this->assertTrue(file_exists($file));
|
||||
|
|
|
@ -2263,6 +2263,26 @@ class SetTest extends CakeTestCase {
|
|||
$this->assertEqual($expected, $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* testFormattingNullValues method
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function testFormattingNullValues() {
|
||||
$data = array(
|
||||
array('Person' => array('first_name' => 'Nate', 'last_name' => 'Abele', 'city' => 'Boston', 'state' => 'MA', 'something' => '42')),
|
||||
array('Person' => array('first_name' => 'Larry', 'last_name' => 'Masters', 'city' => 'Boondock', 'state' => 'TN', 'something' => null)),
|
||||
array('Person' => array('first_name' => 'Garrett', 'last_name' => 'Woodworth', 'city' => 'Venice Beach', 'state' => 'CA', 'something' => null)));
|
||||
|
||||
$result = Set::format($data, '%s', array('{n}.Person.something'));
|
||||
$expected = array('42', '', '');
|
||||
$this->assertEqual($expected, $result);
|
||||
|
||||
$result = Set::format($data, '{0}, {1}', array('{n}.Person.city', '{n}.Person.something'));
|
||||
$expected = array('Boston, 42', 'Boondock, ', 'Venice Beach, ');
|
||||
$this->assertEqual($expected, $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* testCountDim method
|
||||
*
|
||||
|
|
|
@ -298,7 +298,7 @@ class Set {
|
|||
for ($j = 0; $j < $count; $j++) {
|
||||
$args = array();
|
||||
for ($i = 0; $i < $count2; $i++) {
|
||||
if (isset($data[$i][$j])) {
|
||||
if (array_key_exists($j, $data[$i])) {
|
||||
$args[] = $data[$i][$j];
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue