Merge branch '2.8' into 3.0

* 2.8:
  [Form] [ChoiceType] Prefer placeholder to empty_value
  Add missing RFC comment
  ensure dump indentation to be greather than zero
This commit is contained in:
Fabien Potencier 2016-03-02 11:18:25 +01:00
commit dc15374300
6 changed files with 46 additions and 2 deletions

View File

@ -1435,7 +1435,7 @@ class ChoiceTypeTest extends \Symfony\Component\Form\Test\TypeTestCase
));
$view = $form->createView();
$this->assertEquals($viewValue, $view->vars['placeholder']);
$this->assertSame($viewValue, $view->vars['placeholder']);
$this->assertFalse($view->vars['placeholder_in_choices']);
}

View File

@ -170,7 +170,7 @@ class Response
428 => 'Precondition Required', // RFC6585
429 => 'Too Many Requests', // RFC6585
431 => 'Request Header Fields Too Large', // RFC6585
451 => 'Unavailable For Legal Reasons',
451 => 'Unavailable For Legal Reasons', // RFC7725
500 => 'Internal Server Error',
501 => 'Not Implemented',
502 => 'Bad Gateway',

View File

@ -32,6 +32,10 @@ class Dumper
*/
public function setIndentation($num)
{
if ($num < 1) {
throw new \InvalidArgumentException('The indentation must be greater than zero.');
}
$this->indentation = (int) $num;
}

View File

@ -228,6 +228,24 @@ EOF;
'paragraph-separator' => array("\t\\P", '"\t\\\\P"'),
);
}
/**
* @expectedException \InvalidArgumentException
* @expectedExceptionMessage The indentation must be greater than zero
*/
public function testZeroIndentationThrowsException()
{
$this->dumper->setIndentation(0);
}
/**
* @expectedException \InvalidArgumentException
* @expectedExceptionMessage The indentation must be greater than zero
*/
public function testNegativeIndentationThrowsException()
{
$this->dumper->setIndentation(-4);
}
}
class A

View File

@ -22,4 +22,22 @@ class YamlTest extends \PHPUnit_Framework_TestCase
$parsed = Yaml::parse($yml);
$this->assertEquals($data, $parsed);
}
/**
* @expectedException \InvalidArgumentException
* @expectedExceptionMessage The indentation must be greater than zero
*/
public function testZeroIndentationThrowsException()
{
Yaml::dump(array('lorem' => 'ipsum', 'dolor' => 'sit'), 2, 0);
}
/**
* @expectedException \InvalidArgumentException
* @expectedExceptionMessage The indentation must be greater than zero
*/
public function testNegativeIndentationThrowsException()
{
Yaml::dump(array('lorem' => 'ipsum', 'dolor' => 'sit'), 2, -4);
}
}

View File

@ -61,6 +61,10 @@ class Yaml
*/
public static function dump($array, $inline = 2, $indent = 4, $exceptionOnInvalidType = false, $objectSupport = false)
{
if ($indent < 1) {
throw new \InvalidArgumentException('The indentation must be greater than zero.');
}
$yaml = new Dumper();
$yaml->setIndentation($indent);