[HttpFoundation] Fixed removing a nonexisting namespaced attribute.

This commit is contained in:
Jakub Zalas 2013-08-19 05:39:23 +01:00
parent b46e0ad556
commit 85a9c9d114
2 changed files with 11 additions and 1 deletions

View File

@ -86,7 +86,7 @@ class NamespacedAttributeBag extends AttributeBag
$retval = null;
$attributes = & $this->resolveAttributePath($name);
$name = $this->resolveKey($name);
if (array_key_exists($name, $attributes)) {
if (null !== $attributes && array_key_exists($name, $attributes)) {
$retval = $attributes[$name];
unset($attributes[$name]);
}

View File

@ -143,6 +143,16 @@ class NamespacedAttributeBagTest extends \PHPUnit_Framework_TestCase
$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()
{
$this->bag->clear();