Skip to content

Commit

Permalink
[Zend\Config\Factory] Throw exception for unrecognized config extension
Browse files Browse the repository at this point in the history
Also added unit tests for expected exceptions.
  • Loading branch information
EvanDotPro committed Feb 29, 2012
1 parent ea8bc44 commit 7f019a6
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 1 deletion.
2 changes: 1 addition & 1 deletion library/Zend/Config/Factory.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public static function fromFile($filename)
break;
}

return null;
throw new Exception\RuntimeException(sprintf('Unsupported config file extension: .%s', $pathinfo['extension']));
}

/**
Expand Down
12 changes: 12 additions & 0 deletions tests/Zend/Config/FactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,5 +85,17 @@ public function testFromIniAndXmlFiles()
$this->assertEquals('bar', $config['base']['foo']);
$this->assertEquals('baz', $config['test']['bar']);
}

public function testNonExistentFileThrowsRuntimeException()
{
$this->setExpectedException('RuntimeException');
$config = Factory::fromFile('foo.bar');
}

public function testInvalidFileExtensionThrowsInvalidArgumentException()
{
$this->setExpectedException('RuntimeException');
$config = Factory::fromFile(__DIR__ . '/TestAssets/bad.ext');
}
}

Empty file.

0 comments on commit 7f019a6

Please sign in to comment.