Skip to content

Commit

Permalink
feature: #8834 EVENTS for requirements (user contribution https://git…
Browse files Browse the repository at this point in the history
  • Loading branch information
fmancardi committed Dec 31, 2019
1 parent e2d88c9 commit 75e4085
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 8 deletions.
5 changes: 5 additions & 0 deletions lib/functions/events_inc.php
Expand Up @@ -27,6 +27,11 @@
'EVENT_TEST_CASE_UPDATE' => EVENT_TYPE_UPDATE,
'EVENT_TEST_CASE_DELETE' => EVENT_TYPE_DELETE,

// Test Case related events.
'EVENT_TEST_REQUIREMENT_CREATE' => EVENT_TYPE_CREATE,
'EVENT_TEST_REQUIREMENT_UPDATE' => EVENT_TYPE_UPDATE,
'EVENT_TEST_REQUIREMENT_DELETE' => EVENT_TYPE_DELETE,

// Test Event related events
'EVENT_EXECUTE_TEST' => EVENT_TYPE_CREATE,

Expand Down
12 changes: 11 additions & 1 deletion lib/functions/requirement_mgr.class.php
Expand Up @@ -396,8 +396,11 @@ function create($srs_id,$reqdoc_id,$title, $scope, $user_id,

}
}
$ctx = array('id' => $result['id']);
event_signal('EVENT_TEST_REQUIREMENT_CREATE', $ctx);

return $result;

} // function end


Expand Down Expand Up @@ -507,6 +510,9 @@ function update($id,$version_id,$reqdoc_id,$title, $scope, $user_id, $status, $t
$result['status_ok']=$chk['status_ok'];
$result['msg']=$chk['msg'];
}

$ctx = array('id' => $id);
event_signal('EVENT_TEST_REQUIREMENT_UPDATE', $ctx);
return $result;
} //function end

Expand Down Expand Up @@ -714,6 +720,10 @@ function delete($id,$version_id = self::ALL_VERSIONS,$user_id=null) {
}

$result = (!$result) ? lang_get('error_deleting_req') : 'ok';

$ctx = array('id' => $id);
event_signal('EVENT_TEST_REQUIREMENT_DELETE', $ctx);

return $result;
}

Expand Down
42 changes: 35 additions & 7 deletions plugins/TLTest/TLTest.php
Expand Up @@ -12,12 +12,12 @@
require_once(TL_ABS_PATH . '/lib/functions/tlPlugin.class.php');

/**
* Sample Testlink Plugin class that registers itself with the system and provides
* UI hooks for
* Sample Testlink Plugin class that registers itself with the system and provides
* UI hooks for
* Left Top, Left Bottom, Right Top and Right Bottom screens.
*
* This also listens to testsuite creation and echoes out for example.
*
*
* This also listens to testsuite creation and echoes out for example.
*
* Class TLTestPlugin
*/
class TLTestPlugin extends TestlinkPlugin
Expand Down Expand Up @@ -53,6 +53,10 @@ function hooks()
'EVENT_TEST_SUITE_CREATE' => 'testsuite_create',
'EVENT_TEST_PROJECT_CREATE' => 'testproject_create',
'EVENT_TEST_PROJECT_UPDATE' => 'testproject_update',
'EVENT_TEST_CASE_UPDATE' => 'testcase_update',
'EVENT_TEST_REQUIREMENT_CREATE' => 'testrequirement_create',
'EVENT_TEST_REQUIREMENT_UPDATE' => 'testrequirement_update',
'EVENT_TEST_REQUIREMENT_DELETE' => 'testrequirement_delete',
'EVENT_EXECUTE_TEST' => 'testExecute',
'EVENT_LEFTMENU_TOP' => 'top_link',
'EVENT_LEFTMENU_BOTTOM' => 'bottom_link',
Expand All @@ -71,18 +75,42 @@ function testsuite_create($args)
tLog("Im in testsuite create", "WARNING");
}

function testproject_create()
function testproject_create()
{
$arg = func_get_args(); // To get all the arguments
tLog("In TestProject Create with id: " . $arg[1] . ", name: " . $arg[2] . ", prefix: " . $arg[3], "WARNING");
}

function testproject_update()
function testproject_update()
{
$arg = func_get_args(); // To get all the arguments
tLog("In TestProject Update with id: " . $arg[1] . ", name: " . $arg[2] . ", prefix: " . $arg[3], "WARNING");
}

function testcase_update()
{
$arg = func_get_args(); // To get all the arguments
tLog("In TestCase Update with id: " . $arg[1] . ", planid: " . $arg[2] . ", title: " . $arg[3] . ", summary" . $arg[4], "WARNING");
}

function testrequirement_create()
{
$arg = func_get_args(); // To get all the arguments
tLog("In TestRequirement Create with id: " . $arg[1], "WARNING");
}

function testrequirement_update()
{
$arg = func_get_args(); // To get all the arguments
tLog("In TestRequirement Update with id: " . $arg[1], "WARNING");
}

function testrequirement_delete()
{
$arg = func_get_args(); // To get all the arguments
tLog("In TestRequirement Delete with id: " . $arg[1], "WARNING");
}

function testExecute() {
$arg = func_get_args(); // To get all the arguments
tLog("In TestRun with testrunid: " . $arg[1] . ", planid: " . $arg[2] . ", buildid: " . $arg[3] . ", testcaseid: " . $arg[4] . ", Notes: " . $arg[5] . ", Status: " . $arg[6], "WARNING");
Expand Down

0 comments on commit 75e4085

Please sign in to comment.