PageRenderTime 53ms CodeModel.GetById 28ms RepoModel.GetById 1ms app.codeStats 0ms

/lib/api/sample_clients/php/clientReportTCResultOVERWRITE.php

https://bitbucket.org/pfernandez/testlink1.9.6
PHP | 159 lines | 83 code | 27 blank | 49 comment | 12 complexity | e6f200bac41a99ed38cff58fe2eaf886 MD5 | raw file
Possible License(s): GPL-2.0, LGPL-2.1, GPL-3.0
  1. <?php
  2. /**
  3. * A sample client implementation in php
  4. *
  5. * @author Asiel Brumfield <asielb@users.sourceforge.net>
  6. * @package TestlinkAPI
  7. * @link http://testlink.org/api/
  8. *
  9. * rev: 20080306 - franciscom - added dBug to improve diagnostic info.
  10. * 20080305 - franciscom - refactored
  11. */
  12. require_once 'util.php';
  13. require_once 'sample.inc.php';
  14. show_api_db_sample_msg();
  15. $tcaseStatusCode['passed']='p';
  16. $tcaseStatusCode['blocked']='b';
  17. $tcaseStatusCode['failed']='f';
  18. $tcaseStatusCode['wrong']='w';
  19. $tcaseStatusCode['departed']='d';
  20. // Substitute for tcid and tpid that apply to your project
  21. $unitTestDescription="Test - Call with valid parameters: testPlanID,testCaseID,buildID";
  22. $testPlanID=389;
  23. // $testCaseExternalID='API-71'; // 'API-69'
  24. $testCaseExternalID='API-66';
  25. $testCaseID=null;
  26. $buildID=21;
  27. $status=$tcaseStatusCode['blocked'];
  28. //$status=$tcaseStatusCode['failed'];
  29. //$status=$tcaseStatusCode['passed'];
  30. $exec_notes="Call using all EXTERNAL ID ({$testCaseExternalID}) - status={$status}";
  31. //$platformName='NO PLATFORM LINKED';
  32. $platformName='Solaris 9';
  33. $overwrite=true;
  34. $debug=false;
  35. echo $unitTestDescription;
  36. $response = reportResult($server_url,$testCaseID,$testCaseExternalID,$testPlanID,
  37. $buildID,null,$status,$exec_notes,$bug_id,$customfields,
  38. $platformName,$overwrite,$debug);
  39. echo "<br> Result was: ";
  40. // Typically you'd want to validate the result here and probably do something more useful with it
  41. // print_r($response);
  42. new dBug($response);
  43. echo "<br>";
  44. // Substitute for tcid and tpid that apply to your project
  45. // $unitTestDescription="Test - Call with valid parameters: testPlanID,testCaseID,buildID";
  46. // $testPlanID=446;
  47. // $testCaseExternalID='AA-1';
  48. // $testCaseID=null;
  49. // $buildID=2;
  50. // // $status=$tcaseStatusCode['departed'];
  51. // $status=$tcaseStatusCode['blocked'];
  52. // // $status=$tcaseStatusCode['wrong'];
  53. // // $exec_notes="Call using all INTERNAL ID's ({$testCaseID}) - status={$status}";
  54. // $exec_notes="Call using all EXTERNAL ID ({$testCaseExternalID}) - status={$status}";
  55. // $bug_id='999FF';
  56. // $customfields=array('CF_EXE1' => 'COMODORE64','CF_DT' => mktime(10,10,0,7,29,2009));
  57. //
  58. // $debug=false;
  59. // echo $unitTestDescription;
  60. // $response = reportResult($server_url,$testCaseID,$testCaseExternalID,$testPlanID,
  61. // $buildID,null,$status,$exec_notes,$bug_id,$customfields,$debug);
  62. //
  63. // echo "<br> Result was: ";
  64. // // Typically you'd want to validate the result here and probably do something more useful with it
  65. // // print_r($response);
  66. // new dBug($response);
  67. // echo "<br>";
  68. /*
  69. function:
  70. args:
  71. returns:
  72. */
  73. function reportResult($server_url,$tcaseid=null, $tcaseexternalid=null,$tplanid, $buildid=null,
  74. $buildname=null, $status,$notes=null,$bugid=null,$customfields=null,
  75. $platformname=null,$overwrite=false,$debug=false)
  76. {
  77. $client = new IXR_Client($server_url);
  78. $client->debug=$debug;
  79. $data = array();
  80. $data["devKey"] = constant("DEV_KEY");
  81. $data["testplanid"] = $tplanid;
  82. if( !is_null($bugid) )
  83. {
  84. $data["bugid"] = $bugid;
  85. }
  86. if( !is_null($tcaseid) )
  87. {
  88. $data["testcaseid"] = $tcaseid;
  89. }
  90. else if( !is_null($tcaseexternalid) )
  91. {
  92. $data["testcaseexternalid"] = $tcaseexternalid;
  93. }
  94. if( !is_null($buildid) )
  95. {
  96. $data["buildid"] = $buildid;
  97. }
  98. else if ( !is_null($buildname) )
  99. {
  100. $data["buildname"] = $buildname;
  101. }
  102. if( !is_null($notes) )
  103. {
  104. $data["notes"] = $notes;
  105. }
  106. $data["status"] = $status;
  107. if( !is_null($customfields) )
  108. {
  109. $data["customfields"]=$customfields;
  110. }
  111. if( !is_null($platformname) )
  112. {
  113. $data["platformname"]=$platformname;
  114. }
  115. if( !is_null($overwrite) )
  116. {
  117. $data["overwrite"]=$overwrite;
  118. }
  119. new dBug($data);
  120. if(!$client->query('tl.reportTCResult', $data))
  121. {
  122. echo "something went wrong - " . $client->getErrorCode() . " - " . $client->getErrorMessage();
  123. }
  124. else
  125. {
  126. return $client->getResponse();
  127. }
  128. }
  129. ?>