Merge branch '2.8' into 3.3
* 2.8: [HttpFoundation] fixed return type of method HeaderBag::get [HttpFoundation] Added "resource" type on Request::create docblock Revert "bug #25789 Enableable ArrayNodeDefinition is disabled for empty configuration (kejwmen)" Formatting fix in upgrade 3.0 document Revert "bug #25851 [Validator] Conflict with egulias/email-validator 2.0 (emodric)" [Validator] add missing parent isset and add test
This commit is contained in:
commit
fa7b76059f
@ -283,9 +283,7 @@ class ArrayNodeDefinition extends NodeDefinition implements ParentNodeDefinition
|
||||
->beforeNormalization()
|
||||
->ifArray()
|
||||
->then(function ($v) {
|
||||
if (!isset($v['enabled'])) {
|
||||
$v['enabled'] = !empty($v);
|
||||
}
|
||||
$v['enabled'] = isset($v['enabled']) ? $v['enabled'] : true;
|
||||
|
||||
return $v;
|
||||
})
|
||||
|
@ -207,20 +207,6 @@ class ArrayNodeDefinitionTest extends TestCase
|
||||
$this->assertTrue($this->getField($enabledNode, 'defaultValue'));
|
||||
}
|
||||
|
||||
public function testEnableableNodeIsDisabledForEmptyConfigurationWhenNormalized()
|
||||
{
|
||||
$config = array();
|
||||
|
||||
$node = new ArrayNodeDefinition('root');
|
||||
$node->canBeEnabled();
|
||||
|
||||
$this->assertEquals(
|
||||
array('enabled' => false),
|
||||
$node->getNode()->normalize($config),
|
||||
'An enableable node is disabled by default'
|
||||
);
|
||||
}
|
||||
|
||||
public function testIgnoreExtraKeys()
|
||||
{
|
||||
$node = new ArrayNodeDefinition('root');
|
||||
@ -296,7 +282,6 @@ class ArrayNodeDefinitionTest extends TestCase
|
||||
array(array('enabled' => true, 'foo' => 'baz'), array(array('foo' => 'baz')), 'any configuration enables an enableable node'),
|
||||
array(array('enabled' => false, 'foo' => 'baz'), array(array('foo' => 'baz', 'enabled' => false)), 'An enableable node can be disabled'),
|
||||
array(array('enabled' => false, 'foo' => 'bar'), array(false), 'false disables an enableable node'),
|
||||
array(array('enabled' => false, 'foo' => 'bar'), array(), 'enableable node is disabled by default'),
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -12,7 +12,6 @@
|
||||
namespace Symfony\Component\Config\Tests\Definition\Builder;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Symfony\Component\Config\Definition\Processor;
|
||||
use Symfony\Component\Config\Tests\Fixtures\Builder\NodeBuilder as CustomNodeBuilder;
|
||||
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
|
||||
|
||||
@ -132,22 +131,4 @@ class TreeBuilderTest extends TestCase
|
||||
$this->assertInternalType('array', $tree->getExample());
|
||||
$this->assertEquals('example', $children['child']->getExample());
|
||||
}
|
||||
|
||||
public function testRootNodeThatCanBeEnabledIsDisabledByDefault()
|
||||
{
|
||||
$builder = new TreeBuilder();
|
||||
|
||||
$builder->root('test')
|
||||
->canBeEnabled();
|
||||
|
||||
$tree = $builder->buildTree();
|
||||
$children = $tree->getChildren();
|
||||
|
||||
$this->assertFalse($children['enabled']->getDefaultValue());
|
||||
|
||||
$processor = new Processor();
|
||||
$result = $processor->process($tree, array());
|
||||
|
||||
$this->assertEquals(array('enabled' => false), $result);
|
||||
}
|
||||
}
|
||||
|
@ -101,11 +101,11 @@ class HeaderBag implements \IteratorAggregate, \Countable
|
||||
/**
|
||||
* Returns a header value by name.
|
||||
*
|
||||
* @param string $key The header name
|
||||
* @param mixed $default The default value
|
||||
* @param bool $first Whether to return the first value or all header values
|
||||
* @param string $key The header name
|
||||
* @param string|string[] $default The default value
|
||||
* @param bool $first Whether to return the first value or all header values
|
||||
*
|
||||
* @return string|array The first header value if $first is true, an array of values otherwise
|
||||
* @return string|string[] The first header value or default value if $first is true, an array of values otherwise
|
||||
*/
|
||||
public function get($key, $default = null, $first = true)
|
||||
{
|
||||
@ -130,9 +130,9 @@ class HeaderBag implements \IteratorAggregate, \Countable
|
||||
/**
|
||||
* Sets a header by name.
|
||||
*
|
||||
* @param string $key The key
|
||||
* @param string|array $values The value or an array of values
|
||||
* @param bool $replace Whether to replace the actual value or not (true by default)
|
||||
* @param string $key The key
|
||||
* @param string|string[] $values The value or an array of values
|
||||
* @param bool $replace Whether to replace the actual value or not (true by default)
|
||||
*/
|
||||
public function set($key, $values, $replace = true)
|
||||
{
|
||||
|
@ -329,13 +329,13 @@ class Request
|
||||
* The information contained in the URI always take precedence
|
||||
* over the other information (server and parameters).
|
||||
*
|
||||
* @param string $uri The URI
|
||||
* @param string $method The HTTP method
|
||||
* @param array $parameters The query (GET) or request (POST) parameters
|
||||
* @param array $cookies The request cookies ($_COOKIE)
|
||||
* @param array $files The request files ($_FILES)
|
||||
* @param array $server The server parameters ($_SERVER)
|
||||
* @param string $content The raw body data
|
||||
* @param string $uri The URI
|
||||
* @param string $method The HTTP method
|
||||
* @param array $parameters The query (GET) or request (POST) parameters
|
||||
* @param array $cookies The request cookies ($_COOKIE)
|
||||
* @param array $files The request files ($_FILES)
|
||||
* @param array $server The server parameters ($_SERVER)
|
||||
* @param string|resource $content The raw body data
|
||||
*
|
||||
* @return static
|
||||
*/
|
||||
|
@ -214,6 +214,16 @@ abstract class Constraint
|
||||
throw new InvalidOptionsException(sprintf('The option "%s" does not exist in constraint %s', $option, get_class($this)), array($option));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $option The option name
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function __isset($option)
|
||||
{
|
||||
return 'groups' === $option;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds the given group if this constraint is in the Default group.
|
||||
*
|
||||
|
@ -26,6 +26,16 @@ class FileTest extends TestCase
|
||||
|
||||
$this->assertSame($bytes, $file->maxSize);
|
||||
$this->assertSame($binaryFormat, $file->binaryFormat);
|
||||
$this->assertTrue($file->__isset('maxSize'));
|
||||
}
|
||||
|
||||
public function testMagicIsset()
|
||||
{
|
||||
$file = new File(array('maxSize' => 1));
|
||||
|
||||
$this->assertTrue($file->__isset('maxSize'));
|
||||
$this->assertTrue($file->__isset('groups'));
|
||||
$this->assertFalse($file->__isset('toto'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user