Merge branch '2.7' into 2.8

* 2.7:
  [Console] Fixed different behaviour of key and value user inputs in multiple choice question
  [Intl] Fix intl tests for PHP < 5.5.10
This commit is contained in:
Fabien Potencier 2017-05-27 10:24:13 -07:00
commit 2663293522
3 changed files with 36 additions and 9 deletions

View File

@ -137,7 +137,7 @@ class ChoiceQuestion extends Question
if ($multiselect) {
// Check for a separated comma values
if (!preg_match('/^[a-zA-Z0-9_-]+(?:,[a-zA-Z0-9_-]+)*$/', $selectedChoices, $matches)) {
if (!preg_match('/^[^,]+(?:,[^,]+)*$/', $selectedChoices, $matches)) {
throw new InvalidArgumentException(sprintf($errorMessage, $selected));
}
$selectedChoices = explode(',', $selectedChoices);

View File

@ -273,6 +273,37 @@ class QuestionHelperTest extends TestCase
);
}
/**
* @dataProvider specialCharacterInMultipleChoice
*/
public function testSpecialCharacterChoiceFromMultipleChoiceList($providedAnswer, $expectedValue)
{
$possibleChoices = array(
'.',
'src',
);
$dialog = new QuestionHelper();
$dialog->setInputStream($this->getInputStream($providedAnswer."\n"));
$helperSet = new HelperSet(array(new FormatterHelper()));
$dialog->setHelperSet($helperSet);
$question = new ChoiceQuestion('Please select the directory', $possibleChoices);
$question->setMaxAttempts(1);
$question->setMultiselect(true);
$answer = $dialog->ask($this->createInputInterfaceMock(), $this->createOutputInterface(), $question);
$this->assertSame($expectedValue, $answer);
}
public function specialCharacterInMultipleChoice()
{
return array(
array('.', array('.')),
array('., src', array('.', 'src')),
);
}
/**
* @dataProvider mixedKeysChoiceListAnswerProvider
*/

View File

@ -342,7 +342,7 @@ abstract class AbstractIntlDateFormatterTest extends TestCase
/**
* @dataProvider formatTimezoneProvider
* @requires PHP 5.5
* @requires PHP 5.5.10
*/
public function testFormatTimezone($pattern, $timezone, $expected)
{
@ -459,15 +459,11 @@ abstract class AbstractIntlDateFormatterTest extends TestCase
);
}
/**
* @requires PHP 5.5.10
*/
public function testFormatWithDateTimeZoneGmt()
{
if (PHP_VERSION_ID < 50500 && !(extension_loaded('intl') && method_exists('IntlDateFormatter', 'setTimeZone'))) {
$this->markTestSkipped('Only in PHP 5.5+ IntlDateFormatter allows to use DateTimeZone objects.');
}
if (PHP_VERSION_ID < 50510) {
$this->markTestSkipped('Before PHP 5.5.10 the GMT timezone used to be converted to UTC.');
}
$formatter = $this->getDateFormatter('en', IntlDateFormatter::MEDIUM, IntlDateFormatter::SHORT, new \DateTimeZone('GMT'), IntlDateFormatter::GREGORIAN, 'zzz');
$this->assertEquals('GMT', $formatter->format(0));