[HttpFoundation] Fixed removing a nonexisting namespaced attribute.
This commit is contained in:
parent
b46e0ad556
commit
85a9c9d114
@ -86,7 +86,7 @@ class NamespacedAttributeBag extends AttributeBag
|
|||||||
$retval = null;
|
$retval = null;
|
||||||
$attributes = & $this->resolveAttributePath($name);
|
$attributes = & $this->resolveAttributePath($name);
|
||||||
$name = $this->resolveKey($name);
|
$name = $this->resolveKey($name);
|
||||||
if (array_key_exists($name, $attributes)) {
|
if (null !== $attributes && array_key_exists($name, $attributes)) {
|
||||||
$retval = $attributes[$name];
|
$retval = $attributes[$name];
|
||||||
unset($attributes[$name]);
|
unset($attributes[$name]);
|
||||||
}
|
}
|
||||||
|
@ -143,6 +143,16 @@ class NamespacedAttributeBagTest extends \PHPUnit_Framework_TestCase
|
|||||||
$this->assertNull($this->bag->get('user.login'));
|
$this->assertNull($this->bag->get('user.login'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testRemoveExistingNamespacedAttribute()
|
||||||
|
{
|
||||||
|
$this->assertSame('cod', $this->bag->remove('category/fishing/first'));
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testRemoveNonexistingNamespacedAttribute()
|
||||||
|
{
|
||||||
|
$this->assertNull($this->bag->remove('foo/bar/baz'));
|
||||||
|
}
|
||||||
|
|
||||||
public function testClear()
|
public function testClear()
|
||||||
{
|
{
|
||||||
$this->bag->clear();
|
$this->bag->clear();
|
||||||
|
Reference in New Issue
Block a user