Skip to content
Permalink
Browse files

Fix TICKET 7903: cke_pastebin - missing changes for udpdate operations

Fix TICKET 7643: Some testcases in edit mode appear blank and can´t edit (reason: <body id="cke_pastebin")
  • Loading branch information
fmancardi committed Mar 28, 2017
1 parent d6b45fc commit 3e79efa9cc3dd766283150251d6c4d636c4ba490
Showing with 54 additions and 26 deletions.
  1. +54 −26 lib/functions/testcase.class.php
@@ -613,7 +613,8 @@ function create_tcase_only($parent_id,$name,$order=self::DEFAULT_ORDER,$id=self:
private function createVersion($item)
{
$debugMsg = 'Class:' . __CLASS__ . ' - Method: ' . __FUNCTION__;
$tcase_version_id = $this->tree_manager->new_node($item->id,$this->node_types_descr_id['testcase_version']);
$tcase_version_id = $this->tree_manager->new_node($item->id,
$this->node_types_descr_id['testcase_version']);

$this->CKEditorCopyAndPasteCleanUp($item,array('summary','precondition'));

@@ -683,8 +684,10 @@ private function createVersion($item)
$item->steps[$jdx] = (array)$item->steps[$jdx];
}

$op = $this->create_step($tcase_version_id,$item->steps[$jdx]['step_number'],
$item->steps[$jdx]['actions'],$item->steps[$jdx]['expected_results'],
$op = $this->create_step($tcase_version_id,
$item->steps[$jdx]['step_number'],
$item->steps[$jdx]['actions'],
$item->steps[$jdx]['expected_results'],
$item->steps[$jdx]['execution_type']);
}
}
@@ -1104,13 +1107,22 @@ function update($id,$tcversion_id,$name,$summary,$preconditions,$steps,
$sql[] = " UPDATE {$this->tables['nodes_hierarchy']} SET name='" .
$this->db->prepare_string($name) . "' WHERE id= {$id}";


$k2e = array('summary','preconditions');
$item = new stdClass();
$item->summary = $summary;
$item->preconditions = $preconditions;
$this->CKEditorCopyAndPasteCleanUp($item,$k2e);

$dummy = " UPDATE {$this->tables['tcversions']} " .
" SET summary='" . $this->db->prepare_string($summary) . "'," .
" SET summary='" .
$this->db->prepare_string($item->summary) . "'," .
" updater_id=" . $this->db->prepare_int($user_id) . ", " .
" modification_ts = " . $this->db->db_now() . "," .
" execution_type=" . $this->db->prepare_int($execution_type) . ", " .
" importance=" . $this->db->prepare_int($importance) . "," .
" preconditions='" . $this->db->prepare_string($preconditions) . "' ";
" preconditions='" .
$this->db->prepare_string($item->preconditions) . "' ";


if( !is_null($attrib['status']) )
@@ -1123,10 +1135,11 @@ function update($id,$tcversion_id,$name,$summary,$preconditions,$steps,
$dummy .= ", is_open=" . intval($attrib['is_open']);
}

if( !is_null($attrib['active']) )
if( !is_null($attrib['active']) )
{
$dummy .= ", active=" . intval($attrib['active']);
}

if( !is_null($attrib['estimatedExecDuration']) )
{
$dummy .= ", estimated_exec_duration=";
@@ -1796,16 +1809,20 @@ function copy_to($id,$parent_id,$user_id,$options=null,$mappings=null)
$act = "[ghost]\"Step\":{$step['step_number']}," .
'"TestCase"' .':"' . $pfx . '",' .
"\"Version\":{$tcversion['version']}[/ghost]";
$op = $this->create_step($to_tcversion_id,$step['step_number'],$act,$act,
$op = $this->create_step($to_tcversion_id,
$step['step_number'],$act,$act,
$step['execution_type']);
}
}
else
{
foreach($stepsSet as $key => $step)
{
$op = $this->create_step($to_tcversion_id,$step['step_number'],$step['actions'],
$step['expected_results'],$step['execution_type']);
$op = $this->create_step($to_tcversion_id,
$step['step_number'],
$step['actions'],
$step['expected_results'],
$step['execution_type']);
}
}
}
@@ -1996,8 +2013,9 @@ function copy_tcversion($id,$from_tcversion_id,$to_tcversion_id,$as_version_numb
{
foreach($stepsSet as $key => $step)
{
$op = $this->create_step($to_tcversion_id,$step['step_number'],$step['actions'],
$step['expected_results'],$step['execution_type']);
$op = $this->create_step($to_tcversion_id,$step['step_number'],
$step['actions'],$step['expected_results'],
$step['execution_type']);
}
}
}
@@ -5310,20 +5328,28 @@ function set_step_number($step_number)
function update_step($step_id,$step_number,$actions,$expected_results,$execution_type)
{
$debugMsg = 'Class:' . __CLASS__ . ' - Method: ' . __FUNCTION__;
$ret = array();
$ret = array();

$k2e = array('actions','expected_results');
$item = new stdClass();
$item->actions = $actions;
$item->expected_results = $expected_results;
$this->CKEditorCopyAndPasteCleanUp($item,$k2e);

$sql = "/* $debugMsg */ UPDATE {$this->tables['tcsteps']} " .
" SET step_number=" . $this->db->prepare_int($step_number) . "," .
" actions='" . $this->db->prepare_string($actions) . "', " .
" expected_results='" . $this->db->prepare_string($expected_results) . "', " .
" actions='" . $this->db->prepare_string($item->actions) . "', " .
" expected_results='" .
$this->db->prepare_string($item->expected_results) . "', " .
" execution_type = " . $this->db->prepare_int($execution_type) .
" WHERE id = " . $this->db->prepare_int($step_id);

$result = $this->db->exec_query($sql);
$ret = array('msg' => 'ok', 'status_ok' => 1, 'sql' => $sql);
if (!$result)
{
$ret['msg'] = $this->db->error_msg();
$ret['status_ok']=0;
$ret['msg'] = $this->db->error_msg();
$ret['status_ok']=0;
}
return $ret;
}
@@ -5597,20 +5623,20 @@ function filter_tcversions($tcversion_id,$filters,$options=null)
* to update whole steps/expected results structure for test case version.
* This can result in some step removed, other updated and other new created.
*
* @internal Revisions
* 20100821 - franciscom - needed to fix import feature (BUGID 3634).
*/
function update_tcversion_steps($tcversion_id,$steps)
{
$debugMsg = 'Class:' . __CLASS__ . ' - Method: ' . __FUNCTION__;

// delete all current steps (if any exists)
// Attention:
// After addition of test case steps feature, a test case version can be root of
// a subtree that contains the steps.
// Remember we are using (at least on Postgres FK => we need to delete in a precise order

$stepSet = $this->get_steps($tcversion_id,0,array('fields2get' => 'id', 'accessKey' => 'id'));
// Attention:
// After addition of test case steps feature, a test case version
// can be root of a subtree that contains the steps.
// Remember we are using (at least on Postgres FK => we need to delete
// in a precise order.

$stepSet = $this->get_steps($tcversion_id,0,
array('fields2get' => 'id', 'accessKey' => 'id'));
if( count($stepSet) > 0 )
{
$this->delete_step_by_id(array_keys($stepSet));
@@ -5620,8 +5646,10 @@ function update_tcversion_steps($tcversion_id,$steps)
$loop2do = count($steps);
for($idx=0; $idx < $loop2do; $idx++)
{
$this->create_step($tcversion_id,$steps[$idx]['step_number'],$steps[$idx]['actions'],
$steps[$idx]['expected_results'],$steps[$idx]['execution_type']);
$this->create_step($tcversion_id,$steps[$idx]['step_number'],
$steps[$idx]['actions'],
$steps[$idx]['expected_results'],
$steps[$idx]['execution_type']);
}
}

0 comments on commit 3e79efa

Please sign in to comment.
You can’t perform that action at this time.