| [ Index ] |
PHP Cross Reference of MantisBT |
[Summary view] [Print] [Text view]
1 <?php 2 # MantisBT - A PHP based bugtracking system 3 4 # MantisBT is free software: you can redistribute it and/or modify 5 # it under the terms of the GNU General Public License as published by 6 # the Free Software Foundation, either version 2 of the License, or 7 # (at your option) any later version. 8 # 9 # MantisBT is distributed in the hope that it will be useful, 10 # but WITHOUT ANY WARRANTY; without even the implied warranty of 11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 # GNU General Public License for more details. 13 # 14 # You should have received a copy of the GNU General Public License 15 # along with MantisBT. If not, see <http://www.gnu.org/licenses/>. 16 17 /** 18 * @package Tests 19 * @subpackage UnitTests 20 * @copyright Copyright (C) 2002 - 2011 MantisBT Team - mantisbt-dev@lists.sourceforge.net 21 * @link http://www.mantisbt.org 22 */ 23 24 require_once 'SoapBase.php'; 25 26 /** 27 * Test fixture for issue update webservice methods. 28 */ 29 class IssueUpdateTest extends SoapBase { 30 /** 31 * A test case that tests the following: 32 * 1. Ability to create an issue with only the mandatory parameters. 33 * 2. Ability to retrieve the issue just added. 34 * 3. Ability to modify the summary of the retrieved issue and update it in MantisBT. 35 * 4. Ability to delete the issue. 36 */ 37 public function testUpdateSummaryBasedOnPreviousGet() { 38 $issueToAdd = $this->getIssueToAdd( 'IssueUpdateTest.testUpdateSummary' ); 39 40 $issueId = $this->client->mc_issue_add( 41 $this->userName, 42 $this->password, 43 $issueToAdd); 44 45 $this->deleteAfterRun( $issueId ); 46 47 $createdIssue = $this->client->mc_issue_get( 48 $this->userName, 49 $this->password, 50 $issueId); 51 52 $t_summary_update = $issueToAdd['summary'] . ' - updated'; 53 54 $issueToUpdate = $createdIssue; 55 $issueToUpdate->summary = $t_summary_update; 56 57 $this->client->mc_issue_update( 58 $this->userName, 59 $this->password, 60 $issueId, 61 $issueToUpdate); 62 63 $updatedIssue = $this->client->mc_issue_get( 64 $this->userName, 65 $this->password, 66 $issueId); 67 68 $issue = $updatedIssue; 69 70 // explicitly specified fields 71 $this->assertEquals( $issueToAdd['category'], $issue->category ); 72 $this->assertEquals( $t_summary_update, $issue->summary ); 73 $this->assertEquals( $issueToAdd['description'], $issue->description ); 74 $this->assertEquals( $issueToAdd['project']['id'], $issue->project->id ); 75 76 // defaulted fields 77 $this->assertEquals( $issueId, $issue->id ); 78 $this->assertEquals( 10, $issue->view_state->id ); 79 $this->assertEquals( 'public', $issue->view_state->name ); 80 $this->assertEquals( 30, $issue->priority->id ); 81 $this->assertEquals( 'normal', $issue->priority->name ); 82 $this->assertEquals( 50, $issue->severity->id ); 83 $this->assertEquals( 'minor', $issue->severity->name ); 84 $this->assertEquals( 10, $issue->status->id ); 85 $this->assertEquals( 'new', $issue->status->name ); 86 $this->assertEquals( $this->userName, $issue->reporter->name ); 87 $this->assertEquals( 70, $issue->reproducibility->id ); 88 $this->assertEquals( 'have not tried', $issue->reproducibility->name ); 89 $this->assertEquals( 0, $issue->sponsorship_total ); 90 $this->assertEquals( 10, $issue->projection->id ); 91 $this->assertEquals( 'none', $issue->projection->name ); 92 $this->assertEquals( 10, $issue->eta->id ); 93 $this->assertEquals( 'none', $issue->eta->name ); 94 $this->assertEquals( 10, $issue->resolution->id ); 95 $this->assertEquals( 'open', $issue->resolution->name ); 96 } 97 98 /** 99 * A test case that tests the following: 100 * 1. Ability to create an issue with only the mandatory parameters. 101 * 2. Ability to update the summary of the issue while only supplying the mandatory fields. 102 * 3. Ability to delete the issue. 103 */ 104 public function testUpdateSummaryBasedOnMandatoryFields() { 105 $issueToAdd = $this->getIssueToAdd( 'IssueUpdateTest.testUpdateSummaryBasedOnMandatoryFields' ); 106 107 $issueId = $this->client->mc_issue_add( 108 $this->userName, 109 $this->password, 110 $issueToAdd); 111 112 $this->deleteAfterRun( $issueId ); 113 114 $issueToUpdate = $this->getIssueToAdd( 'IssueUpdateTest.testUpdateSummaryBasedOnMandatoryFields' ); 115 116 $this->client->mc_issue_update( 117 $this->userName, 118 $this->password, 119 $issueId, 120 $issueToUpdate); 121 122 $updatedIssue = $this->client->mc_issue_get( 123 $this->userName, 124 $this->password, 125 $issueId); 126 127 $issue = $updatedIssue; 128 129 // explicitly specified fields 130 $this->assertEquals( $issueToUpdate['category'], $issue->category ); 131 $this->assertEquals( $issueToUpdate['summary'], $issue->summary ); 132 $this->assertEquals( $issueToUpdate['description'], $issue->description ); 133 $this->assertEquals( $issueToUpdate['project']['id'], $issue->project->id ); 134 135 // defaulted fields 136 $this->assertEquals( $issueId, $issue->id ); 137 $this->assertEquals( 10, $issue->view_state->id ); 138 $this->assertEquals( 'public', $issue->view_state->name ); 139 $this->assertEquals( 30, $issue->priority->id ); 140 $this->assertEquals( 'normal', $issue->priority->name ); 141 $this->assertEquals( 50, $issue->severity->id ); 142 $this->assertEquals( 'minor', $issue->severity->name ); 143 $this->assertEquals( 10, $issue->status->id ); 144 $this->assertEquals( 'new', $issue->status->name ); 145 $this->assertEquals( $this->userName, $issue->reporter->name ); 146 $this->assertEquals( 70, $issue->reproducibility->id ); 147 $this->assertEquals( 'have not tried', $issue->reproducibility->name ); 148 $this->assertEquals( 0, $issue->sponsorship_total ); 149 $this->assertEquals( 10, $issue->projection->id ); 150 $this->assertEquals( 'none', $issue->projection->name ); 151 $this->assertEquals( 10, $issue->eta->id ); 152 $this->assertEquals( 'none', $issue->eta->name ); 153 $this->assertEquals( 10, $issue->resolution->id ); 154 $this->assertEquals( 'open', $issue->resolution->name ); 155 } 156 157 /** 158 * This test case tests the following: 159 * 1. Creation of an issue. 160 * 2. Adding a note to the issue. 161 * 3. Getting the issue and calling update - making sure the note is not duplicated. 162 * 4. Getting the issue, adding a new note and making sure that the first is not duplicated, but second is added. 163 * 5. Deleting the issue. 164 */ 165 public function testUpdateWithNewNote() { 166 $issueToAdd = $this->getIssueToAdd( 'IssueUpdateTest.testUpdateWithNewNote' ); 167 168 $issueId = $this->client->mc_issue_add( 169 $this->userName, 170 $this->password, 171 $issueToAdd); 172 173 $this->deleteAfterRun( $issueId ); 174 175 $createdIssue = $this->client->mc_issue_get( 176 $this->userName, 177 $this->password, 178 $issueId); 179 180 $noteData = array( 181 'text' => "first note", 182 ); 183 184 $this->client->mc_issue_note_add( 185 $this->userName, 186 $this->password, 187 $issueId, 188 $noteData); 189 190 $issueWithNote = $this->client->mc_issue_get( 191 $this->userName, 192 $this->password, 193 $issueId); 194 195 $this->assertEquals( 1, count( $issueWithNote->notes ) ); 196 197 $this->client->mc_issue_update( 198 $this->userName, 199 $this->password, 200 $issueId, 201 $issueWithNote); 202 203 $issueWithNoteAfterUpdate = $this->client->mc_issue_get( 204 $this->userName, 205 $this->password, 206 $issueId); 207 208 $this->assertEquals( 1, count( $issueWithNoteAfterUpdate->notes ) ); 209 210 $issueWithOneNewNote = $issueWithNoteAfterUpdate; 211 $issueWithOneNewNote->notes[] = array( 'text' => 'second note', 'note_type' => 2, 'note_attr' => 'attr_value' ); 212 213 $this->client->mc_issue_update( 214 $this->userName, 215 $this->password, 216 $issueId, 217 $issueWithOneNewNote); 218 219 $issueWithTwoNotes = $this->client->mc_issue_get( 220 $this->userName, 221 $this->password, 222 $issueId); 223 224 $this->assertEquals( 2, count( $issueWithTwoNotes->notes ) ); 225 226 $newNote = $issueWithTwoNotes->notes[1]; 227 228 $this->assertEquals( 'second note', $newNote->text ); 229 $this->assertEquals( 2, $newNote->note_type ); 230 $this->assertEquals( 'attr_value', $newNote->note_attr ); 231 232 } 233 234 /** 235 * This issue tests the following: 236 * 1. Retrieving all the administrator users, and verifying only one is present 237 * 2. Creating an issue 238 * 3. Retrieving the issue after it is created 239 * 4. Updating the issue to add a handler 240 * 5. Verifying that the correct handler is passed 241 * 6. Deleting the issue 242 */ 243 public function testUpdateIssueWithHandler() { 244 245 $adminUsers = $this->client->mc_project_get_users($this->userName, $this->password, $this->getProjectId(), 90); 246 247 $this->assertTrue(count($adminUsers) >= 1 , "count(adminUsers) >= 1"); 248 249 $issueToAdd = $this->getIssueToAdd( 'IssueUpdateTest.testUpdateIssueWithHandler' ); 250 251 $adminUser = $adminUsers[0]; 252 253 $issueId = $this->client->mc_issue_add( 254 $this->userName, 255 $this->password, 256 $issueToAdd); 257 258 $this->deleteAfterRun( $issueId ); 259 260 $issue = $this->client->mc_issue_get( 261 $this->userName, 262 $this->password, 263 $issueId); 264 265 $issue->handler = $adminUser; 266 267 $this->client->mc_issue_update( 268 $this->userName, 269 $this->password, 270 $issueId, 271 $issue); 272 273 $updatedIssue = $this->client->mc_issue_get( 274 $this->userName, 275 $this->password, 276 $issueId); 277 278 $this->assertEquals( $adminUser->id, $updatedIssue->handler->id, 'handler.id' ); 279 } 280 281 /** 282 * This issue tests the following 283 * 284 * 1. Creating an issue 285 * 2. Retrieving the issue 286 * 3. Updating the issue with a new date 287 * 4. Re-retrieving the issue 288 * 5. Validating the value of the due date 289 */ 290 public function testUpdateIssueDueDate() { 291 $this->skipIfDueDateIsNotEnabled(); 292 293 $date = '2015-10-29T12:59:14Z'; 294 295 $issueToAdd = $this->getIssueToAdd( 'IssueUpdateTest.testUpdateIssueDueDate' ); 296 297 $issueId = $this->client->mc_issue_add( 298 $this->userName, 299 $this->password, 300 $issueToAdd); 301 302 $this->deleteAfterRun( $issueId ); 303 304 $issue = $this->client->mc_issue_get( 305 $this->userName, 306 $this->password, 307 $issueId); 308 309 $issue->due_date = $date; 310 311 $this->client->mc_issue_update( 312 $this->userName, 313 $this->password, 314 $issueId, 315 $issue); 316 317 $updatedIssue = $this->client->mc_issue_get( 318 $this->userName, 319 $this->password, 320 $issueId); 321 322 $this->assertEquals( $date, $updatedIssue->due_date, "due_date"); 323 } 324 325 /** 326 * This issue tests the following 327 * 328 * 1. Creating an issue with no category 329 * 2. Updating the issue to unset the category 330 * 3. Retrieving the issue 331 * 4. Verifying that the category is empty. 332 */ 333 public function testUpdateBugWithNoCategory() { 334 $this->skipIfAllowNoCategoryIsDisabled(); 335 336 $issueToAdd = $this->getIssueToAdd( 'IssueUpdateTest.testUpdateBugWithNoCategory' ); 337 338 $issueId = $this->client->mc_issue_add( 339 $this->userName, 340 $this->password, 341 $issueToAdd); 342 343 $this->deleteAfterRun( $issueId ); 344 345 $issueToUpdate = $this->client->mc_issue_get( 346 $this->userName, 347 $this->password, 348 $issueId); 349 350 unset ( $issueToUpdate->category ); 351 352 $this->client->mc_issue_update( 353 $this->userName, 354 $this->password, 355 $issueId, 356 $issueToUpdate); 357 358 $issue = $this->client->mc_issue_get( 359 $this->userName, 360 $this->password, 361 $issueId); 362 363 $this->assertEquals( '', $issue->category, 'category' ); 364 } 365 366 /* 367 * This test case tests the following: 368 * 1. Creation of an issue. 369 * 2. Updating the issue with a time tracking note 370 * 3. Verifying that the time tracking note on the issue is preseved 371 * 4. Deleting the issue. 372 */ 373 public function testUpdateWithTimeTrackingNote() { 374 375 $this->skipIfTimeTrackingIsNotEnabled(); 376 377 $issueToAdd = $this->getIssueToAdd( 'IssueUpdateTest.testUpdateWithTimeTrackingNote' ); 378 379 $issueId = $this->client->mc_issue_add( 380 $this->userName, 381 $this->password, 382 $issueToAdd); 383 384 $this->deleteAfterRun( $issueId ); 385 386 $issue = $this->client->mc_issue_get( 387 $this->userName, 388 $this->password, 389 $issueId); 390 391 $issue->notes = array( 392 array ( 393 'text' => "first note", 394 'time_tracking' => "30" 395 ) 396 ); 397 398 $this->client->mc_issue_update( 399 $this->userName, 400 $this->password, 401 $issueId, 402 $issue); 403 404 $issueWithNote = $this->client->mc_issue_get( 405 $this->userName, 406 $this->password, 407 $issueId); 408 409 $this->assertEquals( 1, count( $issueWithNote->notes ) ); 410 411 $this->assertEquals( 30, $issueWithNote->notes[0]->time_tracking); 412 } 413 414 /* 415 * This test case tests the following: 416 * 1. Creation of an issue. 417 * 2. Updating the issue with rare fields 418 * 3. Getting the issue 419 * 4. Verifying that the rare field values are preserved 420 * 5. Deleting the issue. 421 */ 422 public function testUpdateWithRareFields() { 423 424 $this->skipIfTimeTrackingIsNotEnabled(); 425 426 $issueToAdd = $this->getIssueToAdd( 'IssueUpdateTest.testUpdateWithRareFields' ); 427 428 $issueId = $this->client->mc_issue_add( 429 $this->userName, 430 $this->password, 431 $issueToAdd); 432 433 $this->deleteAfterRun( $issueId ); 434 435 $issue = $this->client->mc_issue_get( 436 $this->userName, 437 $this->password, 438 $issueId); 439 440 $issue->build = 'build'; 441 $issue->platform = 'platform'; 442 $issue->os_build = 'os_build'; 443 $issue->os = 'os'; 444 445 $this->client->mc_issue_update( 446 $this->userName, 447 $this->password, 448 $issueId, 449 $issue); 450 451 $retrievedIssue = $this->client->mc_issue_get( 452 $this->userName, 453 $this->password, 454 $issueId); 455 456 $this->assertEquals( 'build', $retrievedIssue->build ); 457 $this->assertEquals( 'platform', $retrievedIssue->platform ); 458 $this->assertEquals( 'os', $retrievedIssue->os ); 459 $this->assertEquals( 'os_build', $retrievedIssue->os_build); 460 } 461 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Thu Jul 28 15:48:31 2011 | Cross-referenced by PHPXref 0.7 |