Skip to content

Commit

Permalink
[HttpFoundation] Fixed removing a nonexisting namespaced attribute.
Browse files Browse the repository at this point in the history
  • Loading branch information
jakzal committed Aug 19, 2013
1 parent b46e0ad commit 85a9c9d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
Expand Up @@ -86,7 +86,7 @@ public function remove($name)
$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]);
}
Expand Down
Expand Up @@ -143,6 +143,16 @@ public function testRemove()
$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();
Expand Down

0 comments on commit 85a9c9d

Please sign in to comment.