Skip to content
Browse files

Fixing a bug where the Config class couldnt find the exception class.…

… Also added full CC for the Config class.
  • Loading branch information...
1 parent 4f21b7f commit 934579b06acb5f080c4edb1a9ac4872c8f3ad100 @robmorgan committed Jan 14, 2012
Showing with 21 additions and 1 deletion.
  1. +1 −1 src/Phinx/Config/Config.php
  2. +20 −0 tests/Phinx/Config/ConfigTest.php
View
2 src/Phinx/Config/Config.php
@@ -225,7 +225,7 @@ public function offsetSet($id, $value)
function offsetGet($id)
{
if (!array_key_exists($id, $this->values)) {
- throw new InvalidArgumentException(sprintf('Identifier "%s" is not defined.', $id));
+ throw new \InvalidArgumentException(sprintf('Identifier "%s" is not defined.', $id));
}
return $this->values[$id] instanceof \Closure ? $this->values[$id]($this) : $this->values[$id];
View
20 tests/Phinx/Config/ConfigTest.php
@@ -100,4 +100,24 @@ public function testGetMigrationPathReturnsNullForNoPath()
$config = new \Phinx\Config\Config(array());
$this->assertNull($config->getMigrationPath());
}
+
+ public function testArrayAccessMethods()
+ {
+ $config = new \Phinx\Config\Config(array());
+ $config['foo'] = 'bar';
+ $this->assertEquals('bar', $config['foo']);
+ $this->assertTrue(isset($config['foo']));
+ unset($config['foo']);
+ $this->assertFalse(isset($config['foo']));
+ }
+
+ /**
+ * @expectedException \InvalidArgumentException
+ * @expectedExceptionMessage Identifier "foo" is not defined.
+ */
+ public function testUndefinedArrayAccess()
+ {
+ $config = new \Phinx\Config\Config(array());
+ $config['foo'];
+ }
}

0 comments on commit 934579b

Please sign in to comment.
Something went wrong with that request. Please try again.