Add quotes around all values that contain spaces in them, and add a

test to make sure that we continue to do so.

This makes sure that we don't have problems with 5.3 which treats the
literal "on" as a boolean.
This commit is contained in:
Bharat Mediratta
2009-07-13 10:36:55 -07:00
parent a944bf4259
commit e2a9a1d284
21 changed files with 74 additions and 37 deletions

View File

@@ -213,6 +213,43 @@ class File_Structure_Test extends Unit_Test_Case {
}
}
}
public function module_info_is_well_formed_test() {
$info_files = array_merge(
glob("modules/*/module.info"),
glob("themes/*/module.info"));
$errors = array();
foreach ($info_files as $file) {
foreach (file($file) as $line) {
$parts = explode("=", $line, 2);
$values[trim($parts[0])] = trim($parts[1]);
}
$module = dirname($file);
// Certain keys must exist
foreach (array("name", "description", "version") as $key) {
if (!array_key_exists($key, $values)) {
$errors[] = "$module: missing key $key";
}
}
// Any values containing spaces must be quoted
foreach ($values as $key => $value) {
if (strpos($value, " ") !== false && !preg_match('/^".*"$/', $value)) {
$errors[] = "$module: value for $key must be quoted";
}
}
// The file must parse
if (!is_array(parse_ini_file($file))) {
$errors[] = "$module: info file is not parseable";
}
}
if ($errors) {
$this->assert_true(false, $errors);
}
}
}
class PhpCodeFilterIterator extends FilterIterator {