1<?php 2# --------------------------------------------------------------------- 3# rth is a requirement, test, and bugtracking system 4# Copyright (C) 2005 George Holbrook - rth@lists.sourceforge.net 5# This program is distributed under the terms and conditions of the GPL 6# See the README and LICENSE files for details 7#---------------------------------------------------------------------- 8# ------------------------------------ 9# TestSet API 10# 11# $RCSfile: testset_api.php,v $ $Revision: 1.12 $ 12# ------------------------------------ 13 14 15#------------------------------------------------------------------------------------------ 16# Creates a testset and inserts the name, description and date created. 17# 18# INPUT: 19# testset name 20# testset description 21# build id 22# OUTPUT: 23# new testset id 24#------------------------------------------------------------------------------------------ 25function testset_add( $testset_name, $testset_description, $build_id, $page_name ) { 26 27 global $db; 28 $ts_tbl = TS_TBL; 29 $f_ts_id = TS_ID; 30 $f_name = TS_NAME; 31 $f_desc = TS_DESCRIPTION; 32 $f_date_created = TS_DATE_CREATED; 33 $f_orderby = TS_ORDERBY; 34 $f_archive = TS_ARCHIVE; 35 $f_build_id = TS_BUILD_ID; 36 37 $date = date_get_short_dt(); 38 $archive = 'N'; 39 40 # query testset table by build and get the max order by 41 # add one to the order by when inserting into the testset table 42 $q = "SELECT MAX($f_orderby) FROM $ts_tbl WHERE $f_build_id = '$build_id'"; 43 $order_by = db_get_one( $db, $q ); 44 45 if( !isset( $order_by ) || $order_by == '' ) { 46 $order_by = '1'; 47 } else { 48 $order_by = $order_by + 1; 49 } 50 51 $q = "INSERT INTO $ts_tbl 52 ($f_name, $f_desc, $f_date_created, $f_orderby, $f_archive, $f_build_id) 53 VALUES 54 ('$testset_name', '$testset_description', '$date', '$order_by', '$archive', '$build_id')"; 55 56 db_query( $db, $q ); 57 58 $q = "SELECT MAX($f_ts_id) FROM $ts_tbl WHERE $f_build_id = '$build_id'"; 59 $testset_id = db_get_one( $db, $q ); 60 ####################################################################################################### 61 #Add entry into the log table for the project 62 63 $build_name = admin_get_build_name( $build_id ); 64 $deletion = 'N'; 65 $creation = 'Y'; 66 $upload = 'N'; 67 $action = "ADDED TESTSET $testset_name to $build_name"; 68 69 log_activity_log( $page_name, $deletion, $creation, $upload, $action ); 70 71 #logfile entry end 72 ####################################################################################################### 73 74 session_set_properties( "release", Array("testset_id"=> $testset_id) ); 75 return $testset_id; 76} 77 78#------------------------------------------------------------------------------------------ 79# Returns the rows, which are equal with filter rows 80# 81# INPUT: 82# build name, release name 83# OUTPUT: 84# rows matching with filter options 85#------------------------------------------------------------------------------------------ 86function testset_filter_row($project_id, $build_name, $release_name, $per_page, $order_by, $order_dir, $page_number){ 87 88 $where_clause = testset_filter_generate_where_clause($build_name, $release_name); 89 90 $row = testset_filter_apply($where_clause, $project_id, $per_page, $order_by, $order_dir, $page_number); 91 92 return $row; 93} 94 95function testset_filter_apply($where_clause, $project_id, $per_page, $order_by, $order_dir, $page_number){ 96 97 global $db; 98 $tbl_release = RELEASE_TBL; 99 $tbl_build = BUILD_TBL; 100 $tbl_testset = TS_TBL; 101 $tbl_tsa = TEST_TS_ASSOC_TBL; 102 $f_testset_id = $tbl_testset.".".TS_ID; 103 $f_testset_name = $tbl_testset.".".TS_NAME; 104 $f_test_ts_id = $tbl_tsa.".".TEST_TS_ASSOC_TS_ID; 105 $f_testset_build_id = $tbl_testset.".".TS_BUILD_ID; 106 $f_build_name = $tbl_build.".".BUILD_NAME; 107 $f_build_id = $tbl_build.".".BUILD_ID; 108 $f_build_release_id = $tbl_build.".".BUILD_REL_ID; 109 $f_release_id = $tbl_release.".".RELEASE_ID; 110 $f_project_id = $tbl_release.".".RELEASE_PROJECT_ID ; 111 $f_release_name = $tbl_release.".".RELEASE_NAME; 112 $f_date_created = $tbl_testset.".".TS_DATE_CREATED; 113 $csv_name = null; 114 115 116 $q = "SELECT $f_testset_id, $f_date_created, $f_testset_name, $f_build_name, $f_release_name, $f_date_created 117 FROM $tbl_testset, $tbl_build, $tbl_release 118 WHERE $f_testset_build_id = $f_build_id 119 AND $f_build_release_id = $f_release_id 120 AND $f_project_id = $project_id ". $where_clause ." 121 GROUP BY $f_testset_id"; 122 123 124 $order_clause = " ORDER BY $order_by $order_dir"; 125 126 $q .= $order_clause; 127 128 if( $per_page!=0 && $page_number!=0 ) { 129 130 $row_count = db_num_rows( $db, db_query($db, $q) ); 131 132 $page_number = util_page_number($page_number, $row_count, $per_page); 133 134 # Add the limit clause to the query so that we only show n number of records per page 135 $offset = ( ( $page_number - 1 ) * $per_page ); 136 html_table_offset( $row_count, 137 $per_page, 138 $page_number, 139 $order_by, 140 $order_dir, 141 $csv_name ); 142 143 $q .= " LIMIT $offset, ".$per_page; 144 145 } 146 147 $rs = db_query($db, $q); 148 149 return db_fetch_array($db, $rs); 150} 151 152#------------------------------------------------------------------------------------------ 153# Generates the where clause for SQL statement 154# 155# INPUT: 156# build name, release name 157# OUTPUT: 158# where clause 159#------------------------------------------------------------------------------------------ 160function testset_filter_generate_where_clause($build_name, $release_name){ 161 $f_build_name = BUILD_TBL. "." .BUILD_NAME; 162 $f_release_name = RELEASE_TBL. "." .RELEASE_NAME; 163 164 $where_clause = ""; 165 if( !empty($build_name)){ 166 $where_clause = $where_clause." AND $f_build_name = '$build_name'"; 167 } 168 if( !empty($release_name)){ 169 $where_clause = $where_clause." AND $f_release_name = '$release_name'"; 170 } 171 172 return $where_clause; 173} 174 175 176 177function testset_name_exists( $build_id, $testset_name ) { 178 179 global $db; 180 $testset_tbl = TS_TBL; 181 $f_testset_name = $testset_tbl.".".TS_NAME; 182 $f_build_id = $testset_tbl.".".TS_BUILD_ID; 183 184 185 $q = "SELECT COUNT($f_testset_name) 186 FROM $testset_tbl 187 WHERE $f_testset_name = '$testset_name' 188 AND $f_build_id = '$build_id'"; 189 190 191 $result = db_get_one( $db, $q ); 192 193 if ( 0 == $result) { 194 return false; 195 } else { 196 return true; 197 } 198 199} 200 201# --------------------------------------------------------------------------------- 202# Edits a testset. 203# 204# INPUT: 205# Array of tests to add 206# --------------------------------------------------------------------------------- 207function testset_edit( $testset_id, $tests ) { 208 209 $project_id = session_get_project_id(); 210 211 global $db; 212 $testsuite_tbl = TEST_TBL; 213 $f_test_id = TEST_TBL. "." .TEST_ID; 214 $f_project_id = TEST_TBL. "." .PROJECT_ID; 215 $f_test_name = TEST_TBL. "." .TEST_NAME; 216 $f_test_type = TEST_TBL. "." .TEST_TESTTYPE; 217 $f_area_tested = TEST_TBL. "." .TEST_AREA_TESTED; 218 $f_deleted = TEST_TBL. "." .TEST_DELETED; 219 $f_archived = TEST_TBL. "." .TEST_ARCHIVED; 220 $f_test_priority= TEST_TBL. "." .TEST_PRIORITY; 221 $f_auto_pass = TEST_TBL. "." .TEST_AUTO_PASS; 222 223 $ts_assoc_tbl = TEST_TS_ASSOC_TBL; 224 $f_ts_assoc_id = TEST_TS_ASSOC_TBL. "." .TEST_TS_ASSOC_ID; 225 $f_ts_assoc_ts_id = TEST_TS_ASSOC_TBL. "." .TEST_TS_ASSOC_TS_ID; 226 $f_ts_assoc_test_id = TEST_TS_ASSOC_TBL. "." .TEST_TS_ASSOC_TEST_ID; 227 $f_ts_assoc_test_status = TEST_TS_ASSOC_TBL. "." .TEST_TS_ASSOC_STATUS; 228 $f_ts_assoc_assigned_to = TEST_TS_ASSOC_TBL. "." .TEST_TS_ASSOC_ASSIGNED_TO; 229 $f_ts_assoc_comments = TEST_TS_ASSOC_TBL. "." .TEST_TS_ASSOC_COMMENTS; 230 231 # Need variables for INSERT statement 232 $f_ts_id = TEST_TS_ASSOC_TS_ID; 233 $f_tst_id = TEST_TS_ASSOC_TEST_ID; 234 235 $q = " SELECT $f_test_id, 236 $f_ts_assoc_id 237 FROM $ts_assoc_tbl 238 RIGHT JOIN $testsuite_tbl ON $f_ts_assoc_test_id = $f_test_id 239 WHERE $f_project_id = $project_id 240 AND $f_archived = 'N' 241 AND $f_deleted = 'N' 242 GROUP BY $f_test_id"; 243 244 $rs = db_query( $db, $q); 245 246 while( $row = db_fetch_row($db, $rs) ) { 247 248 if( isset( $tests[$row[TEST_ID]] ) ) { 249 # If the test is set, then form an association between Test/TestSet 250 251 # Check for associations between TestSet and the Test 252 $query_check = " 253 SELECT $f_ts_assoc_test_id 254 FROM $ts_assoc_tbl 255 WHERE $f_ts_assoc_ts_id = $testset_id 256 AND $f_ts_assoc_test_id = " . $row[TEST_ID]; 257 258 $num_check = db_num_rows( $db, db_query($db, $query_check) ); 259 260 if($num_check == 0) { 261 $query_Assoc = " 262 INSERT INTO $ts_assoc_tbl 263 ($f_ts_id, $f_tst_id ) 264 VALUES 265 ($testset_id, ". $row[TEST_ID] .")"; 266 db_query($db, $query_Assoc); 267 } 268 269 } else { 270 271 # Check for associations between TestSet and the Test 272 $query_check = " 273 SELECT $f_ts_assoc_test_id 274 FROM $ts_assoc_tbl 275 WHERE $f_ts_assoc_ts_id = $testset_id 276 AND $f_ts_assoc_test_id = " . $row[TEST_ID]; 277 278 $num_check = db_num_rows( $db, db_query($db, $query_check) ); 279 280 if($num_check != 0) { 281 $query_Assoc = " 282 DELETE FROM $ts_assoc_tbl 283 WHERE $f_tst_id = $row[TestID] 284 AND $f_ts_id = $testset_id"; 285 db_query($db, $query_Assoc); 286 } 287 } 288 } 289} 290 291# --------------------------------------------------------------------------- 292# Creates an array of selected tests and passes them to testset_edit. 293# --------------------------------------------------------------------------- 294function testset_edit_from_session( $testset_id, $f_status, $property_set ) { 295 296 $checked_tests = array(); 297 $project_id = session_get_project_id(); 298 $s_project_properties = session_get_project_properties(); 299 300 global $db; 301 $testsuite_tbl = TEST_TBL; 302 $f_test_id = TEST_TBL. "." .TEST_ID; 303 $f_project_id = TEST_TBL. "." .PROJECT_ID; 304 $f_deleted = TEST_TBL. "." .TEST_DELETED; 305 $f_archived = TEST_TBL. "." .TEST_ARCHIVED; 306 307 $ts_assoc_tbl = TEST_TS_ASSOC_TBL; 308 $f_ts_assoc_id = TEST_TS_ASSOC_TBL. "." .TEST_TS_ASSOC_ID; 309 $f_ts_assoc_test_id = TEST_TS_ASSOC_TBL. "." .TEST_TS_ASSOC_TEST_ID; 310 311 $q = "SELECT $f_test_id, 312 $f_ts_assoc_id, 313 $f_status 314 FROM $ts_assoc_tbl 315 RIGHT JOIN $testsuite_tbl ON $f_ts_assoc_test_id = $f_test_id 316 WHERE $f_project_id = $project_id 317 AND $f_archived = 'N' 318 AND $f_deleted = 'N' 319 GROUP BY $f_test_id"; 320//print$q;exit; 321 $rs = db_query($db, $q); 322 323 while( $row = db_fetch_row($db, $rs) ) { 324 325// if( isset($row[$f_status]) ) { 326 327 # If the checkbox is ticked, then form an association between Test/TestSet 328 if( session_records_ischecked($property_set, $row[TEST_ID], $row[$f_status]) ) { 329 330 $checked_tests[$row[TEST_ID]] = "on"; 331 } 332// } 333 } 334 335 testset_edit( $testset_id, $checked_tests ); 336} 337 338# --------------------------------------------------------------------------- 339# Creates an array of selected tests and passes them to testset_edit. 340# --------------------------------------------------------------------------- 341function testset_add_tests_from_session( $testset_properties, $f_status, $property_set ) { 342 343 $checked_tests = array(); 344 $project_id = session_get_project_id(); 345 $s_user_properties = session_get_user_properties(); 346 $s_project_properties = session_get_project_properties(); 347 348 $testset_id = $testset_properties['testset_id']; 349 $testset_name = admin_get_testset_name($testset_id); 350 $build_id = $testset_properties['build_id']; 351 $build_name = admin_get_build_name($build_id); 352 $release_id = $testset_properties['release_id']; 353 $release_name = admin_get_release_name($release_id); 354 355 global $db; 356 $testsuite_tbl = TEST_TBL; 357 $f_test_id = TEST_TBL. "." .TEST_ID; 358 $f_project_id = TEST_TBL. "." .PROJECT_ID; 359 $f_deleted = TEST_TBL. "." .TEST_DELETED; 360 $f_archived = TEST_TBL. "." .TEST_ARCHIVED; 361 362 $ts_assoc_tbl = TEST_TS_ASSOC_TBL; 363 $f_ts_assoc_id = TEST_TS_ASSOC_TBL. "." .TEST_TS_ASSOC_ID; 364 $f_ts_assoc_test_id = TEST_TS_ASSOC_TBL. "." .TEST_TS_ASSOC_TEST_ID; 365 366 $q = "SELECT $f_test_id, 367 $f_ts_assoc_id, 368 $f_status 369 FROM $ts_assoc_tbl 370 RIGHT JOIN $testsuite_tbl ON $f_ts_assoc_test_id = $f_test_id 371 WHERE $f_project_id = $project_id 372 AND $f_archived = 'N' 373 AND $f_deleted = 'N' 374 GROUP BY $f_test_id"; 375 376 $rs = db_query($db, $q); 377 378 while( $row = db_fetch_row($db, $rs) ) { 379 if( isset($row[$f_status]) ) { 380 381 # If the checkbox is ticked, then form an association between Test/TestSet 382 if( session_records_ischecked($property_set, $row[TEST_ID], $row[$f_status]) ) { 383 384 $checked_tests[$row[TEST_ID]] = "on"; 385 } 386 } 387 } 388 389 testset_edit( $testset_id, $checked_tests ); 390 391} 392 393# ---------------------------------------------------------------------- 394# Get testset details for a specific build or testset 395# INPUT: 396# BuildID 397# OUTPUT: 398# returns an array with all the testsets associcated to a build 399# ---------------------------------------------------------------------- 400function testset_get_details_by_build($build_id, $testset_id, $order_by=null, $order_dir=null) { 401 402 global $db; 403 $ts_tbl = TS_TBL; 404 $ts_id = TS_ID; 405 $ts_name = TS_NAME; 406 $ts_status = TS_STATUS; 407 $ts_desc = TS_DESCRIPTION; 408 $ts_build_id = TS_BUILD_ID; 409 $ts_orderby = TS_ORDERBY; 410 $ts_archive = TS_ARCHIVE; 411 $ts_date_created = TS_DATE_CREATED; 412 $ts_signoff_date = TS_SIGNOFF_DATE; 413 $ts_signoff_by = TS_SIGNOFF_BY; 414 $ts_signoff_comment = TS_SIGNOFF_COMMENTS; 415 416 $q = "SELECT 417 $ts_id, 418 $ts_name, 419 $ts_status, 420 $ts_desc, 421 $ts_build_id, 422 $ts_orderby, 423 $ts_archive, 424 $ts_date_created, 425 $ts_signoff_date, 426 $ts_signoff_by, 427 $ts_signoff_comment 428 FROM $ts_tbl 429 WHERE $ts_build_id = '$build_id'"; 430 431 if( $testset_id != null ) { 432 $q .= " AND $ts_id = $testset_id"; 433 } 434 435 if ( $order_by != null && $order_dir != null ) { 436 $q .= " ORDER BY $order_by $order_dir"; 437 } 438 439 $rs = &db_query( $db, $q ); 440 441 if( $testset_id != null ) { 442 443 $row = db_fetch_row( $db, $rs ); 444 return $row; 445 } else { 446 447 $rows = db_fetch_array( $db, $rs ); 448 return $rows; 449 } 450} 451# ---------------------------------------------------------------------- 452# Get testset details for a specific testset 453# INPUT: 454# TestSetID and BuildID 455# OUTPUT: 456# Corresponding testset information 457# ---------------------------------------------------------------------- 458function testset_get( $testset_id, $build_id ) { 459 460 global $db; 461 462 $ts_tbl = TS_TBL; 463 $ts_id = TS_ID; 464 $ts_name = TS_NAME; 465 $ts_status = TS_STATUS; 466 $ts_desc = TS_DESCRIPTION; 467 $ts_build_id = TS_BUILD_ID; 468 $ts_orderby = TS_ORDERBY; 469 $ts_archive = TS_ARCHIVE; 470 $ts_date_created = TS_DATE_CREATED; 471 $ts_signoff_date = TS_SIGNOFF_DATE; 472 $ts_signoff_by = TS_SIGNOFF_BY; 473 $ts_signoff_comment = TS_SIGNOFF_COMMENTS; 474 475 $q = " SELECT $ts_id, 476 $ts_name, 477 $ts_status, 478 $ts_desc, 479 $ts_build_id, 480 $ts_orderby, 481 $ts_archive, 482 $ts_date_created, 483 $ts_signoff_date, 484 $ts_signoff_by, 485 $ts_signoff_comment 486 FROM $ts_tbl 487 WHERE $ts_id = '$testset_id' 488 AND $ts_build_id = '$build_id'"; 489 490 491 $rs = &db_query( $db, $q ); 492 $row = db_fetch_row( $db, $rs ) ; 493 494 return $row; 495} 496 497# ---------------------------------------------------------------------- 498# Get testset name for a specific testset_id 499# INPUT: 500# TestSetID 501# OUTPUT: 502# Corresponding testset name 503# ---------------------------------------------------------------------- 504function testset_get_name( $testset_id ) { 505 506 global $db; 507 508 $ts_tbl = TS_TBL; 509 $ts_id = TS_ID; 510 $ts_name = TS_NAME; 511 512 $q = "SELECT $ts_name 513 FROM $ts_tbl 514 WHERE $ts_id = '$testset_id'"; 515 516 517 $testset_name = db_get_one( $db, $q ); 518 519 return $testset_name; 520} 521 522# ---------------------------------------------------------------------- 523# Get test details from the testset_test_assoc table for a test in a testset 524# INPUT: 525# TestSetID and TestID 526# OUTPUT: 527# Corresponding test and testset information 528# ---------------------------------------------------------------------- 529function testset_query_test_details( $testset_id, $test_id ) { 530 531 global $db; 532 $ts_tbl = TS_TBL; 533 $f_ts_id = $ts_tbl .".". TS_ID; 534 535 $test_tbl = TEST_TBL; 536 $f_test_id = $test_tbl .".". TEST_ID; 537 $f_test_name = $test_tbl .".". TEST_NAME; 538 539 $assoc_tbl = TEST_TS_ASSOC_TBL; 540 $f_assoc_id = $assoc_tbl .".". TEST_TS_ASSOC_ID; 541 $f_assoc_ts_id = $assoc_tbl .".". TEST_TS_ASSOC_TS_ID; 542 $f_assoc_test_id = $assoc_tbl .".". TEST_TS_ASSOC_TEST_ID; 543 $f_status = $assoc_tbl .".". TEST_TS_ASSOC_STATUS; 544 $f_root_cause = $assoc_tbl .".". TEST_TS_ASSOC_ROOT_CAUSE; 545 $f_finished = $assoc_tbl .".". TEST_TS_ASSOC_FINISHED; 546 $f_assigned_to = $assoc_tbl .".". TEST_TS_ASSOC_ASSIGNED_TO; 547 $f_comments = $assoc_tbl .".". TEST_TS_ASSOC_COMMENTS; 548 549 $q = "SELECT 550 $f_test_id, 551 $f_ts_id, 552 $f_assoc_id, 553 $f_test_name, 554 $f_status, 555 $f_root_cause, 556 $f_finished, 557 $f_assigned_to, 558 $f_comments 559 FROM $ts_tbl, $test_tbl, $assoc_tbl 560 WHERE $f_assoc_ts_id = $f_ts_id 561 AND $f_assoc_test_id = $f_test_id 562 AND $f_ts_id = '$testset_id' 563 AND $f_test_id = '$test_id'"; 564 565 $rs = &db_query( $db, $q ); 566 $row = db_fetch_row( $db, $rs ) ; 567 568 return $row; 569 570} 571 572 573# ---------------------------------------------------------------------- 574# Get testset details 575# INPUT: 576# TestSetID and BuildID 577# OUTPUT: 578# Corresponding testset information 579# ---------------------------------------------------------------------- 580function testset_get_status() { 581 582 /* 583 global $db; 584 $ts_status = TESTSET_STATUS_TBL; 585 $status_id = TS_STATUS_ID; 586 $status_name = TS_STATUS_NAME; 587 588 $q = "SELECT $status_id, $status_name FROM $ts_status"; 589 590 $rs = &db_query( $db, $q ); 591 $num = db_num_rows( $db, $rs ); 592 593 $row = array(); 594 595 for ( $i=0 ; $i < $num ; $i++ ) { 596 array_push( $row, db_fetch_row( $db, $rs ) ); 597 } 598 599 return $row; 600 */ 601 $status = array('Accepted', 602 'Rejected', 603 'Under Review', 604 ''); 605 606 return $status; 607 608} 609 610 611# ---------------------------------------------------------------------- 612# Get last 5 created testsets, on condition that they have tests added. 613# Input: project id 614# Output: array of testsetsd limited to 5 615# ---------------------------------------------------------------------- 616function testset_get_last_5($project_id) { 617 618 global $db; 619 620 $tbl_release = RELEASE_TBL; 621 $tbl_build = BUILD_TBL; 622 $tbl_testset = TS_TBL; 623 $tbl_tsa = TEST_TS_ASSOC_TBL; 624 $f_testset_id = $tbl_testset.".".TS_ID; 625 $f_test_ts_id = $tbl_tsa.".".TEST_TS_ASSOC_TS_ID; 626 $f_testset_build_id = $tbl_testset.".".TS_BUILD_ID; 627 $f_build_id = $tbl_build.".".BUILD_ID; 628 $f_build_release_id = $tbl_build.".".BUILD_REL_ID; 629 $f_release_id = $tbl_release.".".RELEASE_ID; 630 $f_project_id = $tbl_release.".".RELEASE_PROJECT_ID ; 631 $f_date_created = $tbl_testset.".".TS_DATE_CREATED; 632 633 634 $q = "SELECT $f_testset_id, $f_date_created 635 FROM $tbl_testset, $tbl_build, $tbl_release 636 WHERE $f_testset_build_id = $f_build_id 637 AND $f_build_release_id = $f_release_id 638 AND $f_project_id = $project_id 639 GROUP BY $f_testset_id 640 ORDER BY $f_date_created DESC 641 LIMIT 5"; 642 643 $rs = db_query($db, $q); 644 645 return db_fetch_array($db, $rs); 646 647} 648 649# ---------------------------------------------------------------------- 650# Get all created testsets, on condition that they have tests added. 651# Input: project id 652# Output: array of testsetsd limited to 5 653# ---------------------------------------------------------------------- 654function testset_get_last($project_id) { 655 656 global $db; 657 658 $tbl_release = RELEASE_TBL; 659 $tbl_build = BUILD_TBL; 660 $tbl_testset = TS_TBL; 661 $tbl_tsa = TEST_TS_ASSOC_TBL; 662 $f_testset_id = $tbl_testset.".".TS_ID; 663 $f_test_ts_id = $tbl_tsa.".".TEST_TS_ASSOC_TS_ID; 664 $f_testset_build_id = $tbl_testset.".".TS_BUILD_ID; 665 $f_build_id = $tbl_build.".".BUILD_ID; 666 $f_build_release_id = $tbl_build.".".BUILD_REL_ID; 667 $f_release_id = $tbl_release.".".RELEASE_ID; 668 $f_project_id = $tbl_release.".".RELEASE_PROJECT_ID ; 669 $f_date_created = $tbl_testset.".".TS_DATE_CREATED; 670 671 672 $q = "SELECT $f_testset_id, $f_date_created 673 FROM $tbl_testset, $tbl_build, $tbl_release 674 WHERE $f_testset_build_id = $f_build_id 675 AND $f_build_release_id = $f_release_id 676 AND $f_project_id = $project_id 677 GROUP BY $f_testset_id 678 ORDER BY $f_date_created DESC"; 679 680 $rs = db_query($db, $q); 681 682 return db_fetch_array($db, $rs); 683 684} 685 686 687# ---------------------------------------------------------------------- 688# Update TestSet SignOff 689# ---------------------------------------------------------------------- 690function testset_update_testset_signoff ($testset_id, $build_id, $testset_status, 691 $signoff_date, $signoff_by, $signoff_comment) { 692 693 global $db; 694 $db_testset_tbl = TS_TBL; 695 $db_testset_id = TS_ID; 696 $db_build_id = TS_BUILD_ID; 697 $db_status = TS_STATUS; 698 $db_signoff_date = TS_SIGNOFF_DATE; 699 $db_signoff_by = TS_SIGNOFF_BY; 700 $db_signoff_comment = TS_SIGNOFF_COMMENTS; 701 702 $query = "UPDATE $db_testset_tbl 703 SET 704 $db_status = '$testset_status', 705 $db_signoff_date = '$signoff_date', 706 $db_signoff_by = '$signoff_by', 707 $db_signoff_comment = '$signoff_comment' 708 WHERE 709 $db_testset_id = '$testset_id' 710 AND 711 $db_build_id = $build_id"; 712 713 db_query( $db, $query ); 714} 715 716# ---------------------------------------------------------------------- 717# Get testsets associated to a build 718# INPUT: 719# TestSetID and BuildID 720# OUTPUT: 721# Corresponding testset information 722# ---------------------------------------------------------------------- 723function testset_get_testset_count_by_build( $release_id, $build_id, $project_id ) { 724 725 $testset_tbl = TS_TBL; 726 $build_tbl = BUILD_TBL; 727 $release_tbl = RELEASE_TBL; 728 $f_build_id = BUILD_TBL .".". BUILD_ID; 729 $f_release_id = RELEASE_TBL .".". RELEASE_ID; 730 $f_testset_id = TS_TBL .".". TS_ID; 731 $f_testset_name = TS_TBL .".". TS_NAME; 732 $f_testset_date_created = TS_TBL .".". TS_DATE_CREATED; 733 $f_testset_desc = TS_TBL .".". TS_DESCRIPTION; 734 $f_testset_status = TS_TBL .".". TS_STATUS; 735 $f_testset_signoff_by = TS_TBL .".". TS_SIGNOFF_BY; 736 $f_testset_signoff_date = TS_TBL .".". TS_SIGNOFF_DATE; 737 $f_testset_comments = TS_TBL .".". TS_SIGNOFF_COMMENTS; 738 $f_testset_orderby = TS_TBL .".". TS_ORDERBY; 739 $f_testset_build_id = TS_TBL .".". TS_BUILD_ID; 740 741 742 743 $q = " SELECT 744 $f_testset_id, 745 $f_testset_build_id, 746 $f_testset_name, 747 $f_testset_date_created, 748 $f_testset_desc, 749 $f_testset_status, 750 $f_testset_signoff_by, 751 $f_testset_signoff_date, 752 $f_testset_comments, 753 $f_testset_orderby 754 FROM $testset_tbl 755 WHERE $f_testset_build_id = '$_GET[build_id]' 756 ORDER BY $f_testset_orderby ASC"; 757 758 $num = db_num_rows( $db, db_query($db, $q) ); 759 print"$q"; 760 761} 762 763# ---------------------------------------------------------------------- 764# Get verification information associated to a test run 765# INPUT: 766# Test Run ID and Verification ID 767# OUTPUT: 768# Corresponding verification information 769# ---------------------------------------------------------------------- 770function testset_query_verfication_details( $test_run_id, $verification_id ) { 771 772 global $db; 773 $verify_tbl = VERIFY_RESULTS_TBL; 774 $f_verify_id = VERIFY_RESULTS_ID; 775 $f_ts_id = VERIFY_RESULTS_TS_UNIQUE_RUN_ID; 776 $f_action = VERIFY_RESULTS_ACTION; 777 $f_expected = VERIFY_RESULTS_EXPECTED_RESULT; 778 $f_actual = VERIFY_RESULTS_ACTUAL_RESULT; 779 $f_status = VERIFY_RESULTS_TEST_STATUS; 780 $f_comment = VERIFY_RESULTS_COMMENT; 781 $f_defect_id = VERIFY_RESULTS_DEFECT_ID; 782 783 $q = "SELECT 784 $f_action, 785 $f_expected, 786 $f_actual, 787 $f_status, 788 $f_comment, 789 $f_defect_id 790 FROM $verify_tbl 791 WHERE $f_ts_id = '$test_run_id' 792 AND $f_verify_id = '$verification_id'"; 793 $rs = db_query( $db, $q ); 794 $row = db_fetch_row( $db, $rs ); 795 796 return $row; 797 798} 799 800# ---------------------------------------------------------------------- 801# Get field value from test table that is associated in the test set assoc table 802# Useful for getting qa_owners, ba_owners, etc from tests that are in a test set 803# INPUT: 804# $project_id: 805# $testset_id 806# $field = field in test table you want to query 807# $blank: set equal to true if you want a blank added to the end of return value 808# OUTPUT: 809# array containing usernames of qa_owners 810# ---------------------------------------------------------------------- 811function testset_get_test_testset_value($project_id, $testset_id, $field, $blank=false) { 812 813 global $db; 814 $test_tbl = TEST_TBL; 815 $f_test_id = $test_tbl .".". TEST_ID; 816 $f_project_id = $test_tbl .".". TEST_PROJ_ID; 817 818 $assoc_tbl = TEST_TS_ASSOC_TBL; 819 $f_assoc_testset_id = $assoc_tbl .".". TEST_TS_ASSOC_TS_ID; 820 $f_assoc_test_id = $assoc_tbl .".". TEST_TS_ASSOC_TEST_ID; 821 $arr_value = array(); 822 823 $q = "SELECT DISTINCT($field) 824 FROM $test_tbl, $assoc_tbl 825 WHERE $f_assoc_test_id = $f_test_id 826 AND $f_project_id = '$project_id' 827 AND $f_assoc_testset_id = '$testset_id' 828 AND $field != '' 829 ORDER BY $field ASC"; 830 //print"$q<br>"; 831 832 $rs = & db_query( $db, $q ); 833 while($row = db_fetch_row( $db, $rs ) ) { ; 834 array_push($arr_value, $row[$field]); 835 } 836 837 if( $blank == true ) { 838 $arr_value[] = ""; 839 } 840 841 return $arr_value; 842 843} 844 845# ---------------------------------------------------------------------- 846# Returns a testset array 847# 848# INPUT: 849# testset id 850# OUTPUT: 851# array of the form TEST_ID => TEST_TESTTYPE 852# ---------------------------------------------------------------------- 853function testset_get_tests_testtype( $testset_id ) { 854 855 global $db; 856 857 $tbl_test = TEST_TBL; 858 $f_test_id = TEST_TBL. "." .TEST_ID; 859 $f_test_type = TEST_TBL. "." .TEST_TESTTYPE; 860 $f_deleted = TEST_TBL. "." .TEST_DELETED; 861 $f_archive = TEST_TBL. "." .TEST_ARCHIVED; 862 $f_status = TEST_TBL. "." .TEST_STATUS; 863 864 $ts_assoc_tbl = TEST_TS_ASSOC_TBL; 865 $f_ts_assoc_ts_id = TEST_TS_ASSOC_TBL. "." .TEST_TS_ASSOC_TS_ID; 866 $f_ts_assoc_test_id = TEST_TS_ASSOC_TBL. "." .TEST_TS_ASSOC_TEST_ID; 867 868 $q = " SELECT 869 $f_test_id, 870 $f_test_type 871 FROM $tbl_test 872 INNER JOIN $ts_assoc_tbl ON $f_ts_assoc_test_id = $f_test_id 873 WHERE $f_deleted = 'N' 874 AND $f_archive = 'N' 875 AND $f_ts_assoc_ts_id = $testset_id"; 876 877 $rs = db_query( $db, $q ); 878 879 $rows = array(); 880 while( $fields = db_fetch_row($db, $rs) ) { 881 882 $rows[$fields[TEST_ID]] = $fields[TEST_TESTTYPE]; 883 } 884 885 return $rows; 886} 887 888function testset_get_tests( $testset_id ) { 889 890 global $db; 891 892 $tbl_test = TEST_TBL; 893 $f_test_id = TEST_TBL. "." .TEST_ID; 894 $f_test_area = TEST_TBL. "." .TEST_AREA_TESTED; 895 $f_test_type = TEST_TBL. "." .TEST_TESTTYPE; 896 $f_deleted = TEST_TBL. "." .TEST_DELETED; 897 $f_archive = TEST_TBL. "." .TEST_ARCHIVED; 898 $f_status = TEST_TBL. "." .TEST_STATUS; 899 900 $ts_assoc_tbl = TEST_TS_ASSOC_TBL; 901 $f_ts_assoc_ts_id = TEST_TS_ASSOC_TBL. "." .TEST_TS_ASSOC_TS_ID; 902 $f_ts_assoc_test_id = TEST_TS_ASSOC_TBL. "." .TEST_TS_ASSOC_TEST_ID; 903 904 $q = " SELECT $f_test_id, 905 $f_test_area, 906 $f_test_type 907 FROM $tbl_test 908 LEFT JOIN $ts_assoc_tbl ON $f_ts_assoc_test_id = $f_test_id 909 WHERE $f_ts_assoc_ts_id = $testset_id"; 910 911 $rows = db_fetch_array( $db, db_query($db, $q) ); 912 913 return $rows; 914} 915 916# ---------------------------------------------------------------------- 917# Returns the number of tests in a testset 918# 919# INPUT: 920# testset id 921# OUTPUT: 922# number of tests in testset 923# ---------------------------------------------------------------------- 924function testset_number_of_tests( $testset_id ) { 925 926 global $db; 927 928 $tbl_ts_ts_assoc = TEST_TS_ASSOC_TBL; 929 $f_ts_testset_id = $tbl_ts_ts_assoc.".".TEST_TS_ASSOC_TS_ID; 930 $f_ts_test_id = $tbl_ts_ts_assoc.".".TEST_TS_ASSOC_TEST_ID; 931 932 $tbl_test = TEST_TBL; 933 $f_test_id = TEST_TBL.".".TEST_ID; 934 $f_test_deleted = TEST_TBL.".".TEST_DELETED; 935 $f_test_archive = TEST_TBL.".".TEST_ARCHIVED; 936 937 $q = " SELECT $f_ts_test_id 938 FROM $tbl_ts_ts_assoc 939 INNER JOIN $tbl_test ON 940 $f_test_id = $f_ts_test_id 941 WHERE 942 $f_test_deleted = 'N' 943 AND $f_test_archive = 'N' 944 AND $f_ts_testset_id = $testset_id"; 945 946 $rs = db_query($db, $q); 947 948 return db_num_rows($db, $rs); 949} 950 951# ---------------------------------------------------------------------- 952# Returns the testplans for a build 953# 954# INPUT: 955# build id 956# OUTPUT: 957# array of test plans 958# ---------------------------------------------------------------------- 959function testset_get_test_plans( $build_id ) { 960 961 global $db; 962 963 $tbl_test_plan = TEST_PLAN; 964 $f_test_plan_id = TEST_PLAN . "." . TEST_PLAN_ID; 965 $f_test_plan_build_id = TEST_PLAN . "." . TEST_PLAN_BUILDID; 966 $f_test_plan_name = TEST_PLAN . "." . TEST_PLAN_NAME; 967 968 $tbl_test_plan_version = TEST_PLAN_VERSION; 969 $f_test_plan_version_id = TEST_PLAN_VERSION . "." . TEST_PLAN_VERSION_ID; 970 $f_test_plan_version_test_plan_id = TEST_PLAN_VERSION . "." . TEST_PLAN_VERSION_TESTPLANID; 971 $f_version = TEST_PLAN_VERSION . "." . TEST_PLAN_VERSION_VERSION; 972 $f_uploaded_date = TEST_PLAN_VERSION . "." . TEST_PLAN_VERSION_UPLOADEDDATE; 973 $f_uploaded_by = TEST_PLAN_VERSION . "." . TEST_PLAN_VERSION_UPLOADEDBY; 974 $f_file_name = TEST_PLAN_VERSION . "." . TEST_PLAN_VERSION_FILENAME; 975 $f_comments = TEST_PLAN_VERSION . "." . TEST_PLAN_VERSION_COMMMENTS; 976 $f_latest = TEST_PLAN_VERSION . "." . TEST_PLAN_VERSION_LATEST; 977 978 $q = " SELECT $f_test_plan_id, 979 $f_test_plan_build_id, 980 $f_test_plan_name, 981 $f_test_plan_version_id, 982 $f_version, 983 $f_uploaded_date, 984 $f_uploaded_by, 985 $f_file_name, 986 $f_comments 987 FROM $tbl_test_plan 988 INNER JOIN $tbl_test_plan_version ON $f_test_plan_id = $f_test_plan_version_test_plan_id 989 WHERE $f_test_plan_build_id = $build_id 990 AND $f_latest = 'Y' 991 GROUP BY $f_test_plan_id 992 ORDER BY $f_version DESC"; 993 994 $rs = db_query($db, $q); 995 996 return db_fetch_array($db, $rs); 997} 998 999# ---------------------------------------------------------------------- 1000# Returns all the versions of a test plan 1001# 1002# INPUT: 1003# test plan id 1004# OUTPUT: 1005# array of all test plan versions 1006# ---------------------------------------------------------------------- 1007function testset_get_test_plan_log( $test_plan_id ) { 1008 1009 global $db; 1010 1011 $tbl_test_plan = TEST_PLAN; 1012 $f_test_plan_id = TEST_PLAN . "." . TEST_PLAN_ID; 1013 $f_test_plan_build_id = TEST_PLAN . "." . TEST_PLAN_BUILDID; 1014 $f_test_plan_name = TEST_PLAN . "." . TEST_PLAN_NAME; 1015 1016 $tbl_test_plan_version = TEST_PLAN_VERSION; 1017 $f_test_plan_version_id = TEST_PLAN_VERSION . "." . TEST_PLAN_VERSION_ID; 1018 $f_test_plan_version_test_plan_id = TEST_PLAN_VERSION . "." . TEST_PLAN_VERSION_TESTPLANID; 1019 $f_version = TEST_PLAN_VERSION . "." . TEST_PLAN_VERSION_VERSION; 1020 $f_uploaded_date = TEST_PLAN_VERSION . "." . TEST_PLAN_VERSION_UPLOADEDDATE; 1021 $f_uploaded_by = TEST_PLAN_VERSION . "." . TEST_PLAN_VERSION_UPLOADEDBY; 1022 $f_file_name = TEST_PLAN_VERSION . "." . TEST_PLAN_VERSION_FILENAME; 1023 $f_comments = TEST_PLAN_VERSION . "." . TEST_PLAN_VERSION_COMMMENTS; 1024 1025 $q = " SELECT $f_test_plan_id, 1026 $f_test_plan_build_id, 1027 $f_test_plan_name, 1028 $f_test_plan_version_id, 1029 $f_version, 1030 $f_uploaded_date, 1031 $f_uploaded_by, 1032 $f_file_name, 1033 $f_comments 1034 FROM $tbl_test_plan 1035 INNER JOIN $tbl_test_plan_version ON $f_test_plan_id = $f_test_plan_version_test_plan_id 1036 WHERE $f_test_plan_id = $test_plan_id 1037 ORDER BY $f_version DESC"; 1038 1039 $rs = db_query($db, $q); 1040 1041 return db_fetch_array($db, $rs); 1042} 1043 1044# ---------------------------------------------------------------------- 1045# Returns a test plan 1046# 1047# INPUT: 1048# test plan id 1049# OUTPUT: 1050# array of test plan fields 1051# ---------------------------------------------------------------------- 1052function testset_get_test_plan_details( $test_plan_id ) { 1053 1054 global $db; 1055 1056 $tbl_test_plan = TEST_PLAN; 1057 $f_test_plan_id = TEST_PLAN . "." . TEST_PLAN_ID; 1058 $f_test_plan_build_id = TEST_PLAN . "." . TEST_PLAN_BUILDID; 1059 $f_test_plan_name = TEST_PLAN . "." . TEST_PLAN_NAME; 1060 1061 $tbl_test_plan_version = TEST_PLAN_VERSION; 1062 $f_test_plan_version_id = TEST_PLAN_VERSION . "." . TEST_PLAN_VERSION_ID; 1063 $f_test_plan_version_test_plan_id = TEST_PLAN_VERSION . "." . TEST_PLAN_VERSION_TESTPLANID; 1064 $f_version = TEST_PLAN_VERSION . "." . TEST_PLAN_VERSION_VERSION; 1065 $f_uploaded_date = TEST_PLAN_VERSION . "." . TEST_PLAN_VERSION_UPLOADEDDATE; 1066 $f_uploaded_by = TEST_PLAN_VERSION . "." . TEST_PLAN_VERSION_UPLOADEDBY; 1067 $f_file_name = TEST_PLAN_VERSION . "." . TEST_PLAN_VERSION_FILENAME; 1068 $f_comments = TEST_PLAN_VERSION . "." . TEST_PLAN_VERSION_COMMMENTS; 1069 $f_latest = TEST_PLAN_VERSION . "." . TEST_PLAN_VERSION_LATEST; 1070 1071 $q = "SELECT 1072 $f_test_plan_id, 1073 $f_test_plan_build_id, 1074 $f_test_plan_name, 1075 $f_test_plan_version_id, 1076 $f_version, 1077 $f_file_name 1078 FROM $tbl_test_plan, $tbl_test_plan_version 1079 WHERE $f_test_plan_id = $f_test_plan_version_test_plan_id 1080 AND $f_test_plan_id = $test_plan_id 1081 AND $f_latest = 'Y'"; 1082 1083 $rs = db_query($db, $q); 1084 1085 return db_fetch_row($db, $rs); 1086} 1087 1088# ---------------------------------------------------------------------- 1089# Returns array of all test run statuses with optional blank value at end. 1090# 1091# OUTPUT: 1092# array of all unique test statuses. 1093# ---------------------------------------------------------------------- 1094function testset_get_run_statuses( $testset_id ) { 1095 1096 $tbl_test_ts_assoc = TEST_TS_ASSOC_TBL; 1097 $f_status = $tbl_test_ts_assoc .".". TEST_TS_ASSOC_STATUS; 1098 $f_testset_id = $tbl_test_ts_assoc .".". TEST_TS_ASSOC_TS_ID; 1099 1100 $q = " SELECT DISTINCT $f_status 1101 FROM $tbl_test_ts_assoc 1102 WHERE 1103 $f_status!='' 1104 AND $f_testset_id = $testset_id 1105 GROUP BY $f_status 1106 ORDER BY $f_status ASC"; 1107 1108 global $db; 1109 1110 $rows = db_fetch_array($db, db_query($db, $q)); 1111 1112 return $rows; 1113} 1114 1115function testset_email($project_id, $release_id, $build_id, $testset_id, $recipients, $action) { 1116 1117 $display_generic_info = true; 1118 $display_generic_url = true; 1119 1120 $generic_url = RTH_URL."login.php?project_id=$project_id&page=results_page.php&release_id=$release_id&build_id=$build_id&testset_id=$testset_id"; 1121 1122 $username = session_get_username(); 1123 $project_name = session_get_project_name(); 1124 $release_name = admin_get_release_name($release_id); 1125 $build_name = admin_get_build_name($build_id); 1126 1127 $user_details = user_get_name_by_username($username); 1128 $first_name = $user_details[USER_FNAME]; 1129 $last_name = $user_details[USER_LNAME]; 1130 1131 $testset_detail = testset_get_details_by_build( $build_id, $testset_id ); 1132 $testset_id = $testset_detail[TS_ID]; 1133 $testset_name = $testset_detail[TS_NAME]; 1134 $testset_date_created = $testset_detail[TS_DATE_CREATED]; 1135 $testset_description = $testset_detail[TS_DESCRIPTION]; 1136 1137 1138 # CREATE EMAIL SUBJECT AND MESSAGE 1139 switch($action) { 1140 case"new_testset": 1141 1142 $subject = "RTH: New TestSet for $project_name"; 1143 $message = "TestSet $testset_name has been created by $first_name $last_name". NEWLINE . NEWLINE; 1144 break; 1145 } 1146 1147 # Generic link to results page if the $generic_url variable has been set 1148 if( $display_generic_url ) { 1149 $message .= "Click the following link to view results:". NEWLINE . NEWLINE; 1150 $message .= "$generic_url". NEWLINE . NEWLINE; 1151 $message .= "Please update automated scripts with TESTSETID=$testset_id". NEWLINE . NEWLINE; 1152 } 1153 1154 if( $display_generic_info ) { 1155 $message .= "".lang_get("project_name").": $project_name". NEWLINE; 1156 $message .= "".lang_get("release").": $release_name". NEWLINE; 1157 $message .= "".lang_get("build").": $build_name". NEWLINE; 1158 $message .= "".lang_get("testset_name").": $testset_name". NEWLINE; 1159 $message .= "".lang_get("description").": $testset_description". NEWLINE; 1160 1161 $message .= NEWLINE. "If you do not wish to be notified of any new testsets created, please edit your User profile by navigating to the Users link in RTH."; 1162 } 1163 1164 # Convert any html entities stored in the DB back to characters. 1165 $message = util_unhtmlentities($message); 1166 1167 email_send($recipients, $subject, $message); 1168} 1169 1170function testset_delete_test_plan($testset_plan_id) { 1171 1172 global $db; 1173 1174 $tbl_test_plan = TEST_PLAN; 1175 $f_test_plan_id = TEST_PLAN . "." . TEST_PLAN_ID; 1176 $f_test_plan_build_id = TEST_PLAN . "." . TEST_PLAN_BUILDID; 1177 $f_test_plan_name = TEST_PLAN . "." . TEST_PLAN_NAME; 1178 1179 $tbl_test_plan_version = TEST_PLAN_VERSION; 1180 $f_test_plan_version_id = TEST_PLAN_VERSION . "." . TEST_PLAN_VERSION_ID; 1181 $f_test_plan_version_test_plan_id = TEST_PLAN_VERSION . "." . TEST_PLAN_VERSION_TESTPLANID; 1182 $f_version = TEST_PLAN_VERSION . "." . TEST_PLAN_VERSION_VERSION; 1183 $f_uploaded_date = TEST_PLAN_VERSION . "." . TEST_PLAN_VERSION_UPLOADEDDATE; 1184 $f_uploaded_by = TEST_PLAN_VERSION . "." . TEST_PLAN_VERSION_UPLOADEDBY; 1185 $f_file_name = TEST_PLAN_VERSION . "." . TEST_PLAN_VERSION_FILENAME; 1186 $f_comments = TEST_PLAN_VERSION . "." . TEST_PLAN_VERSION_COMMMENTS; 1187 1188 $project_properties = session_get_project_properties(); 1189 $test_plan_upload_path = $project_properties['test_plan_upload_path'] ; 1190 1191 1192 # Get the filenames of all the test plan versions to delete 1193 $q = "SELECT $f_file_name FROM $tbl_test_plan_version 1194 WHERE $f_test_plan_version_test_plan_id = $testset_plan_id"; 1195 1196 $rs = db_query( $db, $q ); 1197 1198 # delete test plans 1199 while( $row = db_fetch_row($db, $rs) ) { 1200 1201 $file = $test_plan_upload_path.$row[TEST_PLAN_VERSION_FILENAME]; 1202 unlink($file); 1203 } 1204 1205 # delete test plan record 1206 $q = "DELETE FROM $tbl_test_plan 1207 WHERE $f_test_plan_id = $testset_plan_id"; 1208 1209 db_query( $db, $q ); 1210 1211 # delete test plan version record 1212 $q = "DELETE FROM $tbl_test_plan_version 1213 WHERE $f_test_plan_version_test_plan_id = $testset_plan_id"; 1214 1215 db_query( $db, $q ); 1216} 1217 1218#------------------------------------------------------------------------------------------ 1219# Returns the actual status of testset lock 1220# 1221# INPUT: 1222# testset id 1223# OUTPUT: 1224# true: if testset is locked 1225# false: if testset is not locked 1226#------------------------------------------------------------------------------------------ 1227function testset_get_lock_status( $testset_id ) { 1228 1229 global $db; 1230 $testset_id_col = TS_ID; 1231 $testset_tbl = TS_TBL; 1232 $testset_lock = TS_LOCK; 1233 1234 $q = "select $testset_lock from $testset_tbl " . 1235 "where $testset_id_col = $testset_id"; 1236 1237 $rs = db_get_one($db,$q); 1238 1239 if($rs == 'N'){ 1240 return false; 1241 }else 1242 return true; 1243} 1244function testset_update_testset_lock($testset_id, $build_id, $date, $user_name, $comments){ 1245 global $db; 1246 $db_testset_tbl = TS_TBL; 1247 $db_testset_id = TS_ID; 1248 $db_build_id = TS_BUILD_ID; 1249 $db_lock_date = TS_LOCKCHANGE_DATE; 1250 $db_lock_by = TS_LOCK_BY; 1251 $db_lock_comment = TS_LOCK_COMMENT; 1252 $db_lock = TS_LOCK; 1253 $locked = testset_get_lock_status($testset_id); 1254 if($locked){ 1255 $lock = 'N'; 1256 }else{ 1257 $lock = 'Y'; 1258 } 1259 1260 $query = "UPDATE $db_testset_tbl 1261 SET 1262 $db_lock_date = '$date', 1263 $db_lock_by = '$user_name', 1264 $db_lock_comment = '$comments', 1265 $db_lock = '$lock' 1266 WHERE 1267 $db_testset_id = '$testset_id' 1268 AND 1269 $db_build_id = $build_id"; 1270 1271 db_query( $db, $query ); 1272 1273} 1274 1275# ------------------------------------ 1276# $Log: testset_api.php,v $ 1277# Revision 1.12 2008/08/04 06:55:01 peter_thal 1278# added sorting function to several tables 1279# 1280# Revision 1.11 2008/07/25 09:50:07 peter_thal 1281# added lock testset feature 1282# disabled detail column in test result, because functionality is not implemented yet 1283# 1284# Revision 1.10 2008/07/17 13:54:12 peter_thal 1285# added new feature: test sets status (overview) 1286# +fixed some bugs with project_id parameter in testdetail_page references 1287# 1288# Revision 1.9 2007/02/03 10:26:19 gth2 1289# no message 1290# 1291# Revision 1.8 2006/08/05 22:31:46 gth2 1292# adding NEWLINE constant to support mulitple OS - gth 1293# 1294# Revision 1.7 2006/06/30 00:55:43 gth2 1295# removing &$db from api files - gth 1296# 1297# Revision 1.6 2006/06/24 14:34:15 gth2 1298# updating changes lost with cvs problem. 1299# 1300# Revision 1.5 2006/02/27 17:24:13 gth2 1301# added autopass and testset duration functionality - gth 1302# 1303# Revision 1.4 2006/02/24 11:32:48 gth2 1304# minor bug fixes and enhancements for 1.5.1 release - gth 1305# 1306# Revision 1.3 2006/02/09 12:34:26 gth2 1307# changing db field names for consistency - gth 1308# 1309# Revision 1.2 2006/01/08 22:00:25 gth2 1310# bug fixes. missing some variables - gth 1311# 1312# Revision 1.1.1.1 2005/11/30 23:01:13 gth2 1313# importing initial version - gth 1314# 1315# ------------------------------------ 1316?>