예제 #1
0
 if (isset($contentParts2[0])) {
     $className = trim($contentParts2[0]);
 }
 if (isset($className)) {
     $diagnostics .= "TESTING {$className}...\n";
     $objectNameList[] = $className;
     //get sql
     $sqlParts = split(";", $contentParts[0]);
     $sqlPart = split("CREATE", $sqlParts[0]);
     $sql = "CREATE " . $sqlPart[1] . ";";
     $linkParts1 = split("\\*\\/", $contentParts[1]);
     $linkParts2 = split("\\@link", $linkParts1[0]);
     $link = $linkParts2[1];
     eval('$instance = new ' . $className . '();');
     $attributeList = array_keys(get_object_vars($instance));
     $type_value = InitializeTestValues($instance->pog_attribute_type);
     foreach ($attributeList as $attribute) {
         if (isset($instance->pog_attribute_type[strtolower($attribute)])) {
             if (isset($type_value[strtolower($attribute)])) {
                 $instance->{$attribute} = $type_value[strtolower($attribute)];
             } else {
                 if ($instance->pog_attribute_type[strtolower($attribute)][0] != "OBJECT") {
                     $instance->{$attribute} = "1";
                 }
             }
         }
     }
     //Test Save()
     $instanceId = false;
     $instance->{strtolower($className) . "Id"} = 0;
     $instanceId = $instance->Save(false);
예제 #2
0
/**
 * Populates object attributes with test values
 *
 * @param unknown_type $object
 * @return unknown
 */
function PopulateTestValues(&$object)
{
    $attributeList = array_keys(get_object_vars($object));
    $type_value = InitializeTestValues($object->pog_attribute_type);
    $objectName = get_class($object);
    foreach ($attributeList as $attribute) {
        if (isset($object->pog_attribute_type[$attribute])) {
            if (isset($type_value[$attribute])) {
                $object->{$attribute} = $type_value[$attribute];
            } else {
                if ($object->pog_attribute_type[$attribute]['db_attributes'][0] != "OBJECT") {
                    $object->{$attribute} = "1";
                }
            }
        }
    }
    eval("\$object -> " . strtolower($objectName) . "Id = '';");
    return $object;
}