public function validateConfig()
{
// do we have any config?
$config = $this->getConfig();
// backwards-compatibility with 2.0.0-pre releases
if (isset($config->{'0'})) {
// convert to an object
//
// this is the documented format
//
// 2.0.0-pre had this file as an array of groups. we don't
// want to break that for DataSift, who are actively using
// it
$tmp = new BaseObject();
$tmp->groups = $config;
$config = $tmp;
$this->setData('', $config);
}
// do we have any defined groups?
if (!isset($config->groups)) {
throw new E4xx_TestEnvironmentNeedsGroups();
}
foreach ($config->groups as $index => $group) {
// what type of machines does this group define?
if (!isset($group->type)) {
throw new E4xx_TestEnvironmentGroupNeedsAType($index);
}
// is this a valid type?
$this->validateGroupType($index, $group->type);
// do we have any machines defined?
if (!isset($group->details, $group->details->machines)) {
throw new E4xx_TestEnvironmentGroupNeedsMachines($index);
}
// are the machines valid?
foreach ($group->details->machines as $hostId => $machine) {
// does each machine have a role?
if (!isset($machine->roles)) {
throw new E4xx_TestEnvironmentMachineNeedsARole($index, $hostId);
}
// is the roles an array?
if (!is_array($machine->roles)) {
throw new E4xx_TestEnvironmentMachineRolesMustBeArray($index, $hostId, gettype($machine->roles));
}
}
}
}