Projekt

Obecné

Profil

« Předchozí | Další » 

Revize 1040

Přidáno uživatelem Ondřej Fibich před více než 13 roky(ů)

Pokracovani prace na unit testech:
- Testovani helperu.
- Uprava konfiguracniho souboru pro preskoceni nekterych metod helperu, jejichz parametry jsou objekty.

Bugy:
- Opravy kritickych bugu v helprech.

Zobrazit rozdíly:

freenetis/branches/unit_tester/application/vendors/unit_tester/unit_testing_config.xml
</method>
</helper>
<helper name="callback">
<method name="balance_field" autogenerate="on">
<method name="balance_field" autogenerate="off">
<attributes>
<attribute name="item" default_value="" />
<attribute name="name" default_value="" />
<attribute name="item" default_value=""/>
<attribute name="name" default_value=""/>
</attributes>
<values>
<input>
<param value="" />
<param value="" />
</input>
</values>
</method>
<method name="amount_field" autogenerate="on">
<method name="amount_field" autogenerate="off">
<attributes>
<attribute name="item" default_value="" />
<attribute name="name" default_value="" />
<attribute name="item" default_value=""/>
<attribute name="name" default_value=""/>
</attributes>
<values>
<input>
<param value="" />
<param value="" />
</input>
</values>
<values/>
</method>
<method name="origin_account_field" autogenerate="on">
<method name="origin_account_field" autogenerate="off">
<attributes>
<attribute name="item" default_value="" />
<attribute name="name" default_value="" />
<attribute name="item" default_value=""/>
<attribute name="name" default_value=""/>
</attributes>
<values>
<input>
<param value="" />
<param value="" />
</input>
</values>
<values/>
</method>
<method name="destination_account_field" autogenerate="on">
<method name="destination_account_field" autogenerate="off">
<attributes>
<attribute name="item" default_value="" />
<attribute name="name" default_value="" />
<attribute name="item" default_value=""/>
<attribute name="name" default_value=""/>
</attributes>
<values>
<input>
<param value="" />
<param value="" />
</input>
</values>
</method>
<method name="redirect_field" autogenerate="on">
<method name="redirect_field" autogenerate="off">
<attributes>
<attribute name="item" default_value="" />
<attribute name="name" default_value="" />
<attribute name="item" default_value=""/>
<attribute name="name" default_value=""/>
</attributes>
<values>
<input>
<param value="" />
<param value="" />
</input>
</values>
</method>
<method name="member_field" autogenerate="on">
<method name="member_field" autogenerate="off">
<attributes>
<attribute name="item" default_value="" />
<attribute name="name" default_value="" />
<attribute name="item" default_value=""/>
<attribute name="name" default_value=""/>
</attributes>
<values>
<input>
<param value="" />
<param value="" />
</input>
</values>
</method>
<method name="subnet_field" autogenerate="on">
<method name="subnet_field" autogenerate="off">
<attributes>
<attribute name="item" default_value="" />
<attribute name="name" default_value="" />
<attribute name="item" default_value=""/>
<attribute name="name" default_value=""/>
</attributes>
<values>
<input>
<param value="" />
<param value="" />
</input>
</values>
</method>
<method name="ip_address_field" autogenerate="on">
<method name="ip_address_field" autogenerate="off">
<attributes>
<attribute name="item" default_value="" />
<attribute name="name" default_value="" />
<attribute name="item" default_value=""/>
<attribute name="name" default_value=""/>
</attributes>
<values>
<input>
<param value="" />
<param value="" />
</input>
</values>
</method>
<method name="segment_field" autogenerate="on">
<method name="segment_field" autogenerate="off">
<attributes>
<attribute name="item" default_value="" />
<attribute name="name" default_value="" />
<attribute name="item" default_value=""/>
<attribute name="name" default_value=""/>
</attributes>
<values>
<input>
<param value="" />
<param value="" />
</input>
</values>
</method>
<method name="device_field" autogenerate="on">
<method name="device_field" autogenerate="off">
<attributes>
<attribute name="item" default_value="" />
<attribute name="name" default_value="" />
<attribute name="item" default_value=""/>
<attribute name="name" default_value=""/>
</attributes>
<values>
<input>
<param value="" />
<param value="" />
</input>
</values>
</method>
<method name="device_type_field" autogenerate="on">
<method name="device_type_field" autogenerate="off">
<attributes>
<attribute name="item" default_value="" />
<attribute name="name" default_value="" />
<attribute name="item" default_value=""/>
<attribute name="name" default_value=""/>
</attributes>
<values>
<input>
<param value="" />
<param value="" />
</input>
</values>
</method>
<method name="device_price_field" autogenerate="on">
<method name="device_price_field" autogenerate="off">
<attributes>
<attribute name="item" default_value="" />
<attribute name="name" default_value="" />
<attribute name="item" default_value=""/>
<attribute name="name" default_value=""/>
</attributes>
<values>
<input>
<param value="" />
<param value="" />
</input>
</values>
</method>
<method name="iface_field" autogenerate="on">
<method name="iface_field" autogenerate="off">
<attributes>
<attribute name="item" default_value="" />
<attribute name="name" default_value="" />
<attribute name="item" default_value=""/>
<attribute name="name" default_value=""/>
</attributes>
<values>
<input>
<param value="" />
<param value="" />
</input>
</values>
</method>
<method name="user_field" autogenerate="on">
<method name="user_field" autogenerate="off">
<attributes>
<attribute name="item" default_value="" />
<attribute name="name" default_value="" />
<attribute name="item" default_value=""/>
<attribute name="name" default_value=""/>
</attributes>
<values>
<input>
<param value="" />
<param value="" />
</input>
</values>
</method>
<method name="user_login_field" autogenerate="on">
<method name="user_login_field" autogenerate="off">
<attributes>
<attribute name="item" default_value="" />
<attribute name="name" default_value="" />
<attribute name="item" default_value=""/>
<attribute name="name" default_value=""/>
</attributes>
<values>
<input>
<param value="" />
<param value="" />
</input>
</values>
</method>
<method name="cancel_redirection_of_member" autogenerate="on">
<method name="cancel_redirection_of_member" autogenerate="off">
<attributes>
<attribute name="item" default_value="" />
<attribute name="name" default_value="" />
<attribute name="item" default_value=""/>
<attribute name="name" default_value=""/>
</attributes>
<values>
<input>
<param value="" />
<param value="" />
</input>
</values>
</method>
<method name="phone_invoice_private_field_locked" autogenerate="on">
<method name="phone_invoice_private_field_locked" autogenerate="off">
<attributes>
<attribute name="item" default_value="" />
<attribute name="name" default_value="" />
<attribute name="item" default_value=""/>
<attribute name="name" default_value=""/>
</attributes>
<values>
<input>
<param value="" />
<param value="" />
</input>
</values>
</method>
<method name="phone_period_field" autogenerate="on">
<method name="phone_period_field" autogenerate="off">
<attributes>
<attribute name="item" default_value="" />
<attribute name="name" default_value="" />
<attribute name="item" default_value=""/>
<attribute name="name" default_value=""/>
</attributes>
<values>
<input>
<param value="" />
<param value="" />
</input>
</values>
</method>
<method name="phone_price_field" autogenerate="on">
<method name="phone_price_field" autogenerate="off">
<attributes>
<attribute name="item" default_value="" />
<attribute name="name" default_value="" />
<attribute name="item" default_value=""/>
<attribute name="name" default_value=""/>
</attributes>
<values>
<input>
<param value="" />
<param value="" />
</input>
</values>
</method>
<method name="phone_number_field" autogenerate="on">
<method name="phone_number_field" autogenerate="off">
<attributes>
<attribute name="item" default_value="" />
<attribute name="name" default_value="" />
<attribute name="item" default_value=""/>
<attribute name="name" default_value=""/>
</attributes>
<values>
<input>
<param value="" />
<param value="" />
</input>
</values>
</method>
<method name="phone_private_checkbox" autogenerate="on">
<method name="phone_private_checkbox" autogenerate="off">
<attributes>
<attribute name="item" default_value="" />
<attribute name="name" default_value="" />
<attribute name="input" default_value="" />
<attribute name="item" default_value=""/>
<attribute name="name" default_value=""/>
<attribute name="input" default_value=""/>
</attributes>
<values>
<input>
<param value="" />
<param value="" />
<param value="" />
</input>
</values>
</method>
<method name="phone_invoice_delete_field" autogenerate="on">
<method name="phone_invoice_delete_field" autogenerate="off">
<attributes>
<attribute name="item" default_value="" />
<attribute name="name" default_value="" />
<attribute name="item" default_value=""/>
<attribute name="name" default_value=""/>
</attributes>
<values>
<input>
<param value="" />
<param value="" />
</input>
</values>
</method>
<method name="phone_invoice_edit_field" autogenerate="on">
<method name="phone_invoice_edit_field" autogenerate="off">
<attributes>
<attribute name="item" default_value="" />
<attribute name="name" default_value="" />
<attribute name="item" default_value=""/>
<attribute name="name" default_value=""/>
</attributes>
<values>
<input>
<param value="" />
<param value="" />
</input>
</values>
</method>
<method name="phone_invoice_user_edit_field" autogenerate="on">
<method name="phone_invoice_user_edit_field" autogenerate="off">
<attributes>
<attribute name="item" default_value="" />
<attribute name="name" default_value="" />
<attribute name="item" default_value=""/>
<attribute name="name" default_value=""/>
</attributes>
<values>
<input>
<param value="" />
<param value="" />
</input>
</values>
</method>
<method name="user_id_log_field" autogenerate="on">
<method name="user_id_log_field" autogenerate="off">
<attributes>
<attribute name="item" default_value="" />
<attribute name="name" default_value="" />
<attribute name="item" default_value=""/>
<attribute name="name" default_value=""/>
</attributes>
<values>
<input>
<param value="" />
<param value="" />
</input>
</values>
</method>
<method name="log_action_field" autogenerate="on">
<method name="log_action_field" autogenerate="off">
<attributes>
<attribute name="item" default_value="" />
<attribute name="name" default_value="" />
<attribute name="item" default_value=""/>
<attribute name="name" default_value=""/>
</attributes>
<values>
<input>
<param value="" />
<param value="" />
</input>
</values>
</method>
<method name="object_log_field" autogenerate="on">
<method name="object_log_field" autogenerate="off">
<attributes>
<attribute name="item" default_value="" />
<attribute name="name" default_value="" />
<attribute name="item" default_value=""/>
<attribute name="name" default_value=""/>
</attributes>
<values>
<input>
<param value="" />
<param value="" />
</input>
</values>
</method>
<method name="value_log_field" autogenerate="on">
<method name="value_log_field" autogenerate="off">
<attributes>
<attribute name="item" default_value="" />
<attribute name="name" default_value="" />
<attribute name="item" default_value=""/>
<attribute name="name" default_value=""/>
</attributes>
<values>
<input>
<param value="" />
<param value="" />
</input>
</values>
</method>
<method name="gps_field" autogenerate="on">
<method name="gps_field" autogenerate="off">
<attributes>
<attribute name="item" default_value="" />
<attribute name="name" default_value="" />
<attribute name="item" default_value=""/>
<attribute name="name" default_value=""/>
</attributes>
<values>
<input>
<param value="" />
<param value="" />
</input>
</values>
</method>
<method name="order_number_field" autogenerate="on">
<method name="order_number_field" autogenerate="off">
<attributes>
<attribute name="item" default_value="" />
<attribute name="name" default_value="" />
<attribute name="args" default_value="array()" />
<attribute name="item" default_value=""/>
<attribute name="name" default_value=""/>
<attribute name="args" default_value="array()"/>
</attributes>
<values>
<input>
<param value="" />
<param value="" />
<param value="array()" />
</input>
</values>
</method>
<method name="traffic_field" autogenerate="on">
<method name="traffic_field" autogenerate="off">
<attributes>
<attribute name="item" default_value="" />
<attribute name="name" default_value="" />
<attribute name="item" default_value=""/>
<attribute name="name" default_value=""/>
</attributes>
<values>
<input>
<param value="" />
<param value="" />
</input>
</values>
</method>
<method name="voip_caller" autogenerate="on">
<method name="voip_caller" autogenerate="off">
<attributes>
<attribute name="item" default_value="" />
<attribute name="name" default_value="" />
<attribute name="args" default_value="array()" />
<attribute name="item" default_value=""/>
<attribute name="name" default_value=""/>
<attribute name="args" default_value="array()"/>
</attributes>
<values>
<input>
<param value="" />
<param value="" />
<param value="array()" />
</input>
</values>
</method>
<method name="voip_callcon" autogenerate="on">
<method name="voip_callcon" autogenerate="off">
<attributes>
<attribute name="item" default_value="" />
<attribute name="name" default_value="" />
<attribute name="args" default_value="array()" />
<attribute name="item" default_value=""/>
<attribute name="name" default_value=""/>
<attribute name="args" default_value="array()"/>
</attributes>
<values>
<input>
<param value="" />
<param value="" />
<param value="array()" />
</input>
</values>
</method>
</helper>
</method></helper>
<helper name="cookie">
<method name="set" autogenerate="on">
<attributes>
......
</input>
</values>
</method>
<method name="interval" autogenerate="on">
<method name="interval" autogenerate="off">
<attributes>
<attribute name="datetime" default_value="0000-00-00 00:00:00" />
<attribute name="unit" default_value="hours" />
<attribute name="datetime" default_value="0000-00-00 00:00:00"/>
<attribute name="unit" default_value="hours"/>
</attributes>
<values>
<input>
<param value="0000-00-00 00:00:00" />
<param value="hours" />
</input>
</values>
</method>
<method name="from_interval" autogenerate="on">
......
</input>
</values>
</method>
<method name="interval" autogenerate="on">
<method name="interval" autogenerate="off">
<attributes>
<attribute name="date1" default_value="" />
<attribute name="date2" default_value="0000-00-00 00:00:00" />
<attribute name="datetime" default_value="0000-00-00 00:00:00"/>
<attribute name="unit" default_value="hours"/>
</attributes>
<values>
<input>
<param value="" />
<param value="0000-00-00 00:00:00" />
</input>
</values>
</method>
<method name="day_diff" autogenerate="on">
......
</method>
</helper>
<helper name="network">
<method name="netmask2cidr" autogenerate="on">
<method name="netmask2cidr" autogenerate="off">
<attributes>
<attribute name="netmask" default_value="" />
<attribute name="netmask" default_value=""/>
</attributes>
<values>
<input>
<param value="" />
<param value="255.255.255.0"/>
</input>
<input>
<param value="255.255.0.0"/>
</input>
<input>
<param value="255.0.0.0"/>
</input>
<input>
<param value=""/>
</input>
</values>
</method>
<method name="size" autogenerate="on">
......
</method>
</helper>
<helper name="redirection_log">
<method name="log" autogenerate="on">
<method name="log" autogenerate="off">
<attributes>
<attribute name="admin" default_value="" />
<attribute name="action" default_value="" />
<attribute name="ip_address_id" default_value="" />
<attribute name="admin" default_value=""/>
<attribute name="action" default_value=""/>
<attribute name="ip_address_id" default_value=""/>
</attributes>
<values>
<input>
<param value="" />
<param value="" />
<param value="" />
</input>
</values>
</method>
</helper>
</method></helper>
<helper name="request">
<method name="is_ajax" autogenerate="on">
<attributes></attributes>
......
</method>
</helper>
<helper name="special">
<method name="required_forge_style" autogenerate="on">
<method name="required_forge_style" autogenerate="off">
<attributes>
<attribute name="form" default_value="" />
<attribute name="post_label" default_value="" />
<attribute name="class" default_value="" />
<attribute name="form" default_value=""/>
<attribute name="post_label" default_value=""/>
<attribute name="class" default_value=""/>
</attributes>
<values>
<input>
<param value="" />
<param value="" />
<param value="" />
</input>
</values>
</method>
<method name="required_forge_style" autogenerate="on">
<attributes>
<attribute name="form" default_value="" />
<attribute name="post_label" default_value="" />
<attribute name="class" default_value="" />
</attributes>
<values>
<input>
<param value="" />
<param value="" />
<param value="" />
</input>
</values>
</method>
<method name="create_language_flags" autogenerate="on">
<attributes>
<attribute name="flags_array" default_value="" />
......
</input>
</values>
</method>
<method name="censor" autogenerate="on">
<method name="censor" autogenerate="off">
<attributes>
<attribute name="str" default_value="" />
<attribute name="badwords" default_value="" />
<attribute name="replacement" default_value="#" />
<attribute name="replace_partial_words" default_value="FALSE" />
<attribute name="str" default_value=""/>
<attribute name="badwords" default_value=""/>
<attribute name="replacement" default_value="#"/>
<attribute name="replace_partial_words" default_value="FALSE"/>
</attributes>
<values>
<input>
<param value="" />
<param value="" />
<param value="#" />
<param value="FALSE" />
</input>
</values>
</method>
<method name="bytes" autogenerate="on">
freenetis/branches/unit_tester/application/helpers/network.php
*/
public static function netmask2cidr($netmask)
{
if (!preg_match("/^\d+.\d+.\d+.\d+$/", $netmask))
{
return false;
}
return 32 - log(~ip2long($netmask) + 1, 2);
}
freenetis/branches/unit_tester/application/helpers/special.php
* Returns:
* true / false
*/
/*public static function required_forge_style($form, $post_label = '', $class = '')
{
if (isset($form))
{
$form_array = $form->as_array();
foreach($form_array as $key => $value)
{
if (is_object ($form->$key))
{
if (in_array('required',$form->$key->rules()))
{
if ($class != '') $form->$key->class($class);
if ($post_label != '')
{
$old_label = $form->$key->label;
unset($form->$key->label);
$form->$key->label($old_label.$post_label);
unset($old_label);
}
}
}
}
unset($form_array);
return true;
}
else return false;
}*/
public static function required_forge_style($form, $post_label = '', $class = '')
{
if (isset($form))
freenetis/branches/unit_tester/application/helpers/request.php
if (!in_array($type, array_keys(self::$accept_types)))
return false;
$accept_types= Config::item('mimes.'.$type);
$accept_types= Config::get('mimes.'.$type);
if (is_array($accept_types))
{
freenetis/branches/unit_tester/application/controllers/unit_tester.php
// overload Kohana error handlers
set_error_handler("unit_tester_error_handler");
set_exception_handler('unit_tester_exception_handler');
set_time_limit(60);
// errors
$results = array
(
......
// test helpers
if ($type & self::HELPERS)
{
$results["helpers"]["errors"] = $this->helpers();
}
/* Display results */
$view = new View("unit_tester");
......
/**
* Model testing utility.
* Check parse errors and exception throws of models.
* Check parse errors and exception throws from models.
* @return array Errors with keys obj, type, error
*/
private function models()
{
$errors = array();
$f = false;
$xml_dom = new DOMDocument("1.0", "UTF-8");
......
}
/**
* Helper testing utility.
* Check parse errors and exception throws from helpers.
* @return array Errors with keys obj, type, error
*/
private function helpers()
{
$errors = array();
$f = false;
$xml_dom = new DOMDocument("1.0", "UTF-8");
// open file
if (($f = file_exists(filename)) === false)
{
echo "Cannot find file: `" . filename . "`\n";
echo "Run unit_testing_config.pl\n";
exit(1);
}
// read whole file
$source = file_get_contents(filename);
// parse file
if (!$xml_dom->loadXML($source))
{
echo "Cannot parse config file: `" . filename . "`\n";
exit(2);
}
$models = $xml_dom->getElementsByTagName("helper");
// each helper
foreach ($models as $model)
{
$model_name = $model->getAttribute('name');
$helper_file = APPPATH . "helpers/" . $model_name . EXT;
/* File exist catcher */
if (!file_exists($helper_file))
{
$errors[] = array
(
"obj" => $model_name,
"type" => "FILE ERROR on helper",
"error" => "Cannot find helper file: `" . $helper_file . "`\n"
);
// next helper
continue;
}
/* Syntax error catcher */
$output = null;
$return_var = null;
exec("php -l " . $helper_file . " 2>&1", $output, $return_var);
if ($return_var != 0)
{
$errors[] = array
(
"obj" => $model_name,
"type" => "PARSE ERROR (" . $return_var . ") in helper",
"error" => join("", $output)
);
// next helper
continue;
}
/* Load helper */
$class_name = $model_name;
if (!class_exists($class_name))
{
if (class_exists($class_name . "_Core"))
{
$class_name = $class_name . "_Core";
}
else
{
$errors[] = array
(
"obj" => $class_name,
"type" => "EXCEPTION ERROR in model",
"error" => "Helper does not exists."
);
// next model
continue;
}
}
try
{
$obj = new $class_name;
}
catch (Exception $e)
{
$errors[] = array
(
"obj" => $class_name,
"type" => "EXCEPTION ERROR during loading helper",
"error" => $e->__toString()
);
// next helper
continue;
}
/* Check model methods */
$methods = $model->getElementsByTagName("method");
foreach ($methods as $method)
{
$method_name = $method->getAttribute("name");
$attributes = array();
/* Get attributes */
$attrs = $method->getElementsByTagName("attributes")
->item(0)
->getElementsByTagName("attribute");
foreach ($attrs as $attr)
{
$attr_name = $attr->getAttribute("name");
$attributes[$attr_name] = $attr->getAttribute("default_value");
if (preg_match("/^array\(.*\)$/", $attributes[$attr_name]))
{
$attributes[$attr_name] = self::array_parse($attributes[$attr_name]);
}
}
/* Call for all inputs */
$inputs = $method->getElementsByTagName("values")
->item(0)
->getElementsByTagName("input");
foreach ($inputs as $input)
{
/* Get params */
$paramsarray = array_values($attributes);
$i = 0;
if ($input->hasChildNodes())
{
$params = $input->getElementsByTagName("param");
foreach ($params as $param)
{
$paramsarray[$i] = $param->getAttribute("value");
if (preg_match("/^array\(.*\)$/", $paramsarray[$i]))
{
$paramsarray[$i] = self::array_parse($paramsarray[$i]);
}
$i++;
}
}
/* Call method */
try
{
call_user_func_array(array($obj, $method_name), $paramsarray);
}
catch (Exception $e)
{
$errors[] = array
(
"obj" => $class_name . "#" . $method_name,
"type" => "EXCEPTION ERROR in helper during call on line " . $e->getLine(),
"error" => $e->getMessage()
);
// next
continue;
}
}
}
}
return $errors;
}
/**
* Parse string with array
* @param type $str String with array PHP syntax
* @return array Parsed array or null on error

Také k dispozici: Unified diff