Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Using array_key_exists for raw instead of isset. Adding coverage.

  • Loading branch information...
commit a78e1f7b51e9d6f4cdead1ac0bf2e47420ec9e77 1 parent 3900a1b
@mtdowling mtdowling authored
Showing with 18 additions and 1 deletion.
  1. +1 −1  lib/Pimple.php
  2. +17 −0 tests/Pimple/Tests/PimpleTest.php
View
2  lib/Pimple.php
@@ -139,7 +139,7 @@ function protect(Closure $callable)
*/
function raw($id)
{
- if (!isset($this->values[$id])) {
+ if (!array_key_exists($id, $this->values)) {
throw new InvalidArgumentException(sprintf('Identifier "%s" is not defined.', $id));
}
View
17 tests/Pimple/Tests/PimpleTest.php
@@ -165,4 +165,21 @@ public function testRaw()
$pimple['service'] = $definition = function () { return 'foo'; };
$this->assertSame($definition, $pimple->raw('service'));
}
+
+ public function testRawHonorsNullValues()
+ {
+ $pimple = new Pimple();
+ $pimple['foo'] = null;
+ $this->assertNull($pimple->raw('foo'));
+ }
+
+ /**
+ * @expectedException InvalidArgumentException
+ * @expectedExceptionMessage Identifier "foo" is not defined.
+ */
+ public function testRawValidatesKeyIsPresent()
+ {
+ $pimple = new Pimple();
+ $pimple->raw('foo');
+ }
}
Please sign in to comment.
Something went wrong with that request. Please try again.