Skip to content

Commit

Permalink
Adding more tests and better errors for PhpReader.
Browse files Browse the repository at this point in the history
  • Loading branch information
markstory committed Dec 3, 2010
1 parent ae328ff commit bbb15c2
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
4 changes: 3 additions & 1 deletion cake/libs/config/php_reader.php
Expand Up @@ -65,7 +65,9 @@ public function read($key) {
}
include $file;
if (!isset($config)) {
return array();
throw new RuntimeException(
sprintf(__('No variable $config found in %s.php'), $file)
);
}
return $config;
}
Expand Down
12 changes: 12 additions & 0 deletions cake/tests/cases/libs/config/php_reader.test.php
Expand Up @@ -38,6 +38,7 @@ function testRead() {
$reader = new PhpReader($this->path);
$values = $reader->read('var_test');
$this->assertEquals('value', $values['Read']);
$this->assertEquals('buried', $values['Deep']['Deeper']['Deepest']);
}

/**
Expand All @@ -51,6 +52,17 @@ function testReadWithNonExistantFile() {
$reader->read('fake_values');
}

/**
* test reading an empty file.
*
* @expectedException RuntimeException
* @return void
*/
function testReadEmptyFile() {
$reader = new PhpReader($this->path);
$reader->read('empty');
}

/**
* test reading from plugins
*
Expand Down

0 comments on commit bbb15c2

Please sign in to comment.