Merge branch '2.2' into 2.3
* 2.2: Reverts JSON_NUMERIC_CHECK Just a Typo [Yaml] removed wrong comment removal inside a string block Fixing configuration validation error messages. [HtppKernel] fixed inline fragment renderer fixed inline fragment renderer ProgressHelper shows percentage complete. Comment fixed: RedrawFrequency is measured in steps. fix handling of a default 'template' as a string Conflicts: src/Symfony/Component/Console/Helper/ProgressHelper.php src/Symfony/Component/Console/Tests/Helper/ProgressHelperTest.php src/Symfony/Component/HttpKernel/Tests/Fragment/HIncludeFragmentRendererTest.php src/Symfony/Component/HttpKernel/Tests/Fragment/InlineFragmentRendererTest.php
This commit is contained in:
commit
c2c156835f
@ -39,10 +39,10 @@ class NumericNode extends ScalarNode
|
|||||||
|
|
||||||
$errorMsg = null;
|
$errorMsg = null;
|
||||||
if (isset($this->min) && $value < $this->min) {
|
if (isset($this->min) && $value < $this->min) {
|
||||||
$errorMsg = sprintf('The value %s is too small for path "%s". Should be greater than: %s', $value, $this->getPath(), $this->min);
|
$errorMsg = sprintf('The value %s is too small for path "%s". Should be greater than or equal to %s', $value, $this->getPath(), $this->min);
|
||||||
}
|
}
|
||||||
if (isset($this->max) && $value > $this->max) {
|
if (isset($this->max) && $value > $this->max) {
|
||||||
$errorMsg = sprintf('The value %s is too big for path "%s". Should be less than: %s', $value, $this->getPath(), $this->max);
|
$errorMsg = sprintf('The value %s is too big for path "%s". Should be less than or equal to %s', $value, $this->getPath(), $this->max);
|
||||||
}
|
}
|
||||||
if (isset($errorMsg)) {
|
if (isset($errorMsg)) {
|
||||||
$ex = new InvalidConfigurationException($errorMsg);
|
$ex = new InvalidConfigurationException($errorMsg);
|
||||||
|
@ -39,7 +39,7 @@ class NumericNodeDefinitionTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @expectedException \Symfony\Component\Config\Definition\Exception\InvalidConfigurationException
|
* @expectedException \Symfony\Component\Config\Definition\Exception\InvalidConfigurationException
|
||||||
* @expectedExceptionMessage The value 4 is too small for path "foo". Should be greater than: 5
|
* @expectedExceptionMessage The value 4 is too small for path "foo". Should be greater than or equal to 5
|
||||||
*/
|
*/
|
||||||
public function testIntegerMinAssertion()
|
public function testIntegerMinAssertion()
|
||||||
{
|
{
|
||||||
@ -49,7 +49,7 @@ class NumericNodeDefinitionTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @expectedException \Symfony\Component\Config\Definition\Exception\InvalidConfigurationException
|
* @expectedException \Symfony\Component\Config\Definition\Exception\InvalidConfigurationException
|
||||||
* @expectedExceptionMessage The value 4 is too big for path "foo". Should be less than: 3
|
* @expectedExceptionMessage The value 4 is too big for path "foo". Should be less than or equal to 3
|
||||||
*/
|
*/
|
||||||
public function testIntegerMaxAssertion()
|
public function testIntegerMaxAssertion()
|
||||||
{
|
{
|
||||||
@ -66,7 +66,7 @@ class NumericNodeDefinitionTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @expectedException \Symfony\Component\Config\Definition\Exception\InvalidConfigurationException
|
* @expectedException \Symfony\Component\Config\Definition\Exception\InvalidConfigurationException
|
||||||
* @expectedExceptionMessage The value 400 is too small for path "foo". Should be greater than: 500
|
* @expectedExceptionMessage The value 400 is too small for path "foo". Should be greater than or equal to 500
|
||||||
*/
|
*/
|
||||||
public function testFloatMinAssertion()
|
public function testFloatMinAssertion()
|
||||||
{
|
{
|
||||||
@ -76,7 +76,7 @@ class NumericNodeDefinitionTest extends \PHPUnit_Framework_TestCase
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @expectedException \Symfony\Component\Config\Definition\Exception\InvalidConfigurationException
|
* @expectedException \Symfony\Component\Config\Definition\Exception\InvalidConfigurationException
|
||||||
* @expectedExceptionMessage The value 4.3 is too big for path "foo". Should be less than: 0.3
|
* @expectedExceptionMessage The value 4.3 is too big for path "foo". Should be less than or equal to 0.3
|
||||||
*/
|
*/
|
||||||
public function testFloatMaxAssertion()
|
public function testFloatMaxAssertion()
|
||||||
{
|
{
|
||||||
|
@ -167,7 +167,7 @@ class ProgressHelper extends Helper
|
|||||||
/**
|
/**
|
||||||
* Sets the redraw frequency.
|
* Sets the redraw frequency.
|
||||||
*
|
*
|
||||||
* @param int $freq The frequency in seconds
|
* @param int $freq The frequency in steps
|
||||||
*/
|
*/
|
||||||
public function setRedrawFrequency($freq)
|
public function setRedrawFrequency($freq)
|
||||||
{
|
{
|
||||||
@ -344,12 +344,12 @@ class ProgressHelper extends Helper
|
|||||||
$vars = array();
|
$vars = array();
|
||||||
$percent = 0;
|
$percent = 0;
|
||||||
if ($this->max > 0) {
|
if ($this->max > 0) {
|
||||||
$percent = (double) round($this->current / $this->max, 2);
|
$percent = (double) $this->current / $this->max;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($this->formatVars['bar'])) {
|
if (isset($this->formatVars['bar'])) {
|
||||||
$completeBars = 0;
|
$completeBars = 0;
|
||||||
$emptyBars = 0;
|
|
||||||
if ($this->max > 0) {
|
if ($this->max > 0) {
|
||||||
$completeBars = floor($percent * $this->barWidth);
|
$completeBars = floor($percent * $this->barWidth);
|
||||||
} else {
|
} else {
|
||||||
@ -384,7 +384,7 @@ class ProgressHelper extends Helper
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (isset($this->formatVars['percent'])) {
|
if (isset($this->formatVars['percent'])) {
|
||||||
$vars['percent'] = str_pad($percent * 100, $this->widths['percent'], ' ', STR_PAD_LEFT);
|
$vars['percent'] = str_pad(floor($percent * 100), $this->widths['percent'], ' ', STR_PAD_LEFT);
|
||||||
}
|
}
|
||||||
|
|
||||||
return $vars;
|
return $vars;
|
||||||
|
@ -151,6 +151,18 @@ class ProgressHelperTest extends \PHPUnit_Framework_TestCase
|
|||||||
$this->assertEquals($this->generateOutput(' 3 [■■■>------------------------]'), stream_get_contents($output->getStream()));
|
$this->assertEquals($this->generateOutput(' 3 [■■■>------------------------]'), stream_get_contents($output->getStream()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testPercentNotHundredBeforeComplete()
|
||||||
|
{
|
||||||
|
$progress = new ProgressHelper();
|
||||||
|
$progress->start($output = $this->getOutputStream(), 200);
|
||||||
|
$progress->display();
|
||||||
|
$progress->advance(199);
|
||||||
|
$progress->advance();
|
||||||
|
|
||||||
|
rewind($output->getStream());
|
||||||
|
$this->assertEquals($this->generateOutput(' 0/200 [>---------------------------] 0%').$this->generateOutput(' 199/200 [===========================>] 99%').$this->generateOutput(' 200/200 [============================] 100%'), stream_get_contents($output->getStream()));
|
||||||
|
}
|
||||||
|
|
||||||
protected function getOutputStream()
|
protected function getOutputStream()
|
||||||
{
|
{
|
||||||
return new StreamOutput(fopen('php://memory', 'r+', false));
|
return new StreamOutput(fopen('php://memory', 'r+', false));
|
||||||
|
@ -89,7 +89,7 @@ class JsonResponse extends Response
|
|||||||
public function setData($data = array())
|
public function setData($data = array())
|
||||||
{
|
{
|
||||||
// Encode <, >, ', &, and " for RFC4627-compliant JSON, which may also be embedded into HTML.
|
// Encode <, >, ', &, and " for RFC4627-compliant JSON, which may also be embedded into HTML.
|
||||||
$this->data = json_encode($data, JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_AMP | JSON_HEX_QUOT | JSON_NUMERIC_CHECK);
|
$this->data = json_encode($data, JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_AMP | JSON_HEX_QUOT );
|
||||||
|
|
||||||
return $this->update();
|
return $this->update();
|
||||||
}
|
}
|
||||||
|
@ -130,7 +130,11 @@ class HIncludeFragmentRenderer extends RoutableFragmentRenderer
|
|||||||
private function templateExists($template)
|
private function templateExists($template)
|
||||||
{
|
{
|
||||||
if ($this->templating instanceof EngineInterface) {
|
if ($this->templating instanceof EngineInterface) {
|
||||||
|
try {
|
||||||
return $this->templating->exists($template);
|
return $this->templating->exists($template);
|
||||||
|
} catch (\InvalidArgumentException $e) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$loader = $this->templating->getLoader();
|
$loader = $this->templating->getLoader();
|
||||||
|
@ -60,7 +60,7 @@ class InlineFragmentRenderer extends RoutableFragmentRenderer
|
|||||||
$attributes = $reference->attributes;
|
$attributes = $reference->attributes;
|
||||||
$reference->attributes = array();
|
$reference->attributes = array();
|
||||||
$uri = $this->generateFragmentUri($uri, $request);
|
$uri = $this->generateFragmentUri($uri, $request);
|
||||||
$reference->attributes = $attributes;
|
$reference->attributes = array_merge($attributes, $reference->attributes);
|
||||||
}
|
}
|
||||||
|
|
||||||
$subRequest = $this->createSubRequest($uri, $request);
|
$subRequest = $this->createSubRequest($uri, $request);
|
||||||
|
@ -50,7 +50,7 @@ class HIncludeFragmentRendererTest extends \PHPUnit_Framework_TestCase
|
|||||||
$this->assertEquals('<hx:include src="/foo"></hx:include>', $strategy->render('/foo', Request::create('/'))->getContent());
|
$this->assertEquals('<hx:include src="/foo"></hx:include>', $strategy->render('/foo', Request::create('/'))->getContent());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testRenderWhithDefault()
|
public function testRenderWithDefault()
|
||||||
{
|
{
|
||||||
// only default
|
// only default
|
||||||
$strategy = new HIncludeFragmentRenderer();
|
$strategy = new HIncludeFragmentRenderer();
|
||||||
@ -79,4 +79,17 @@ class HIncludeFragmentRendererTest extends \PHPUnit_Framework_TestCase
|
|||||||
$strategy = new HIncludeFragmentRenderer();
|
$strategy = new HIncludeFragmentRenderer();
|
||||||
$this->assertEquals('<hx:include src="/foo" p1="v1" p2="v2" id="bar">default</hx:include>', $strategy->render('/foo', Request::create('/'), array('default' => 'default', 'id' => 'bar', 'attributes' => array('p1' => 'v1', 'p2' => 'v2')))->getContent());
|
$this->assertEquals('<hx:include src="/foo" p1="v1" p2="v2" id="bar">default</hx:include>', $strategy->render('/foo', Request::create('/'), array('default' => 'default', 'id' => 'bar', 'attributes' => array('p1' => 'v1', 'p2' => 'v2')))->getContent());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testRenderWithDefaultText()
|
||||||
|
{
|
||||||
|
$engine = $this->getMock('Symfony\\Component\\Templating\\EngineInterface');
|
||||||
|
$engine->expects($this->once())
|
||||||
|
->method('exists')
|
||||||
|
->with('default')
|
||||||
|
->will($this->throwException(new \InvalidArgumentException()));
|
||||||
|
|
||||||
|
// only default
|
||||||
|
$strategy = new HIncludeFragmentRenderer($engine);
|
||||||
|
$this->assertEquals('<hx:include src="/foo">default</hx:include>', $strategy->render('/foo', Request::create('/'), array('default' => 'default'))->getContent());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -51,7 +51,7 @@ class InlineFragmentRendererTest extends \PHPUnit_Framework_TestCase
|
|||||||
$object = new \stdClass();
|
$object = new \stdClass();
|
||||||
|
|
||||||
$subRequest = Request::create('/_fragment?_path=_format%3Dhtml%26_controller%3Dmain_controller');
|
$subRequest = Request::create('/_fragment?_path=_format%3Dhtml%26_controller%3Dmain_controller');
|
||||||
$subRequest->attributes->replace(array('object' => $object));
|
$subRequest->attributes->replace(array('object' => $object, '_format' => 'html', '_controller' => 'main_controller'));
|
||||||
$subRequest->headers->set('x-forwarded-for', array('127.0.0.1'));
|
$subRequest->headers->set('x-forwarded-for', array('127.0.0.1'));
|
||||||
$subRequest->server->set('HTTP_X_FORWARDED_FOR', '127.0.0.1');
|
$subRequest->server->set('HTTP_X_FORWARDED_FOR', '127.0.0.1');
|
||||||
|
|
||||||
|
@ -164,7 +164,7 @@ abstract class AbstractAuthenticationListener implements ListenerInterface
|
|||||||
/**
|
/**
|
||||||
* Whether this request requires authentication.
|
* Whether this request requires authentication.
|
||||||
*
|
*
|
||||||
* The default implementation only processed requests to a specific path,
|
* The default implementation only processes requests to a specific path,
|
||||||
* but a subclass could change this to only authenticate requests where a
|
* but a subclass could change this to only authenticate requests where a
|
||||||
* certain parameters is present.
|
* certain parameters is present.
|
||||||
*
|
*
|
||||||
|
@ -304,14 +304,16 @@ class Parser
|
|||||||
|
|
||||||
$isItUnindentedCollection = $this->isStringUnIndentedCollectionItem($this->currentLine);
|
$isItUnindentedCollection = $this->isStringUnIndentedCollectionItem($this->currentLine);
|
||||||
|
|
||||||
while ($this->moveToNextLine()) {
|
// We are in string block (ie. after a line ending with "|")
|
||||||
|
$removeComments = !preg_match('~(.*)\|[\s]*$~', $this->currentLine);
|
||||||
|
|
||||||
|
while ($this->moveToNextLine()) {
|
||||||
if ($isItUnindentedCollection && !$this->isStringUnIndentedCollectionItem($this->currentLine)) {
|
if ($isItUnindentedCollection && !$this->isStringUnIndentedCollectionItem($this->currentLine)) {
|
||||||
$this->moveToPreviousLine();
|
$this->moveToPreviousLine();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->isCurrentLineEmpty()) {
|
if ($removeComments && $this->isCurrentLineEmpty() || $this->isCurrentLineBlank()) {
|
||||||
if ($this->isCurrentLineBlank()) {
|
if ($this->isCurrentLineBlank()) {
|
||||||
$data[] = substr($this->currentLine, $newIndent);
|
$data[] = substr($this->currentLine, $newIndent);
|
||||||
}
|
}
|
||||||
|
@ -522,6 +522,63 @@ EOF;
|
|||||||
|
|
||||||
$this->assertEquals(array('hash' => null), Yaml::parse($input));
|
$this->assertEquals(array('hash' => null), Yaml::parse($input));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testStringBlockWithComments()
|
||||||
|
{
|
||||||
|
$this->assertEquals(array('content' => <<<EOT
|
||||||
|
# comment 1
|
||||||
|
header
|
||||||
|
|
||||||
|
# comment 2
|
||||||
|
<body>
|
||||||
|
<h1>title</h1>
|
||||||
|
</body>
|
||||||
|
|
||||||
|
footer # comment3
|
||||||
|
EOT
|
||||||
|
), Yaml::parse(<<<EOF
|
||||||
|
content: |
|
||||||
|
# comment 1
|
||||||
|
header
|
||||||
|
|
||||||
|
# comment 2
|
||||||
|
<body>
|
||||||
|
<h1>title</h1>
|
||||||
|
</body>
|
||||||
|
|
||||||
|
footer # comment3
|
||||||
|
EOF
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testNestedStringBlockWithComments()
|
||||||
|
{
|
||||||
|
$this->assertEquals(array(array('content' => <<<EOT
|
||||||
|
# comment 1
|
||||||
|
header
|
||||||
|
|
||||||
|
# comment 2
|
||||||
|
<body>
|
||||||
|
<h1>title</h1>
|
||||||
|
</body>
|
||||||
|
|
||||||
|
footer # comment3
|
||||||
|
EOT
|
||||||
|
)), Yaml::parse(<<<EOF
|
||||||
|
-
|
||||||
|
content: |
|
||||||
|
# comment 1
|
||||||
|
header
|
||||||
|
|
||||||
|
# comment 2
|
||||||
|
<body>
|
||||||
|
<h1>title</h1>
|
||||||
|
</body>
|
||||||
|
|
||||||
|
footer # comment3
|
||||||
|
EOF
|
||||||
|
));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
class B
|
class B
|
||||||
|
Reference in New Issue
Block a user