[ Index ]

PHP Cross Reference of MantisBT

title

Body

[close]

/tests/soap/ -> IssueNoteTest.php (source)

   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 notes webservice methods.
  28   */
  29  class IssueNoteTest extends SoapBase {
  30      /**
  31       * A test case that tests the following:
  32       * 1. Create an issue.
  33       * 2. Add a note to the issue by only specifying the text.
  34       * 3. Get the issue.
  35       * 4. Verify the note id against the one returned when adding the note.
  36       * 5. Verify the text as per specified earlier.
  37       * 6. Verify the defaulting of the rest of the fields.
  38       * 7. Verify that submitted / last updated times are the same.
  39       * 8. Verify that submitted / last updated matches today.
  40       * 9. Delete the issue.
  41       */
  42  	public function testAddNote() {
  43          $issueToAdd = $this->getIssueToAdd( 'IssueNoteTest.testAddNote' );
  44  
  45          $issueId = $this->client->mc_issue_add(
  46              $this->userName,
  47              $this->password,
  48              $issueToAdd);
  49  
  50          $this->deleteAfterRun( $issueId );
  51  
  52          $createdIssue = $this->client->mc_issue_get(
  53              $this->userName,
  54              $this->password,
  55              $issueId);
  56  
  57          $noteData = array(
  58              'text' => "first note",
  59              'note_type' => 2,
  60              'note_attr' => 'attr_value'
  61          );
  62  
  63          $issueNoteId = $this->client->mc_issue_note_add(
  64              $this->userName,
  65              $this->password,
  66              $issueId,
  67              $noteData);
  68  
  69          $issueWithNote = $this->client->mc_issue_get(
  70              $this->userName,
  71              $this->password,
  72              $issueId);
  73  
  74          $this->assertEquals( 1, count( $issueWithNote->notes ) );
  75  
  76          $note = $issueWithNote->notes[0];
  77  
  78          $this->assertEquals( $issueNoteId, $note->id );
  79          $this->assertEquals( $this->userName, $note->reporter->name );
  80          $this->assertEquals( $noteData['text'], $note->text );
  81          $this->assertEquals( 10, $note->view_state->id );
  82          $this->assertEquals( 'public', $note->view_state->name );
  83          $this->assertEquals( $note->date_submitted, $note->last_modified );
  84          $this->assertEquals( 2, $note->note_type );
  85          $this->assertEquals( 'attr_value', $note->note_attr );
  86  
  87          /*
  88          $timestamp = strtotime( $note->date_submitted );
  89          $t_submited_date = date( "ymd", $timestamp );
  90          $t_today_date = date( "ymd" );
  91  
  92          $this->assertEquals( $t_today_date, $t_submited_date );
  93          */
  94      }
  95  
  96      /**
  97       * A test case that tests the following:
  98       * 1. Create an issue.
  99       * 2. Add a note to the issue by specifying the text and time_tracking.
 100       * 3. Get the issue.
 101       * 4. Verify the note id against the one returned when adding the note.
 102       * 5. Verify the time_tracking entry
 103       * 6. Delete the issue.
 104       */
 105  	public function testAddNoteWithTimeTracking() {
 106  
 107          $this->skipIfTimeTrackingIsNotEnabled();
 108  
 109          $issueToAdd = $this->getIssueToAdd( 'IssueNoteTest.testAddNoteWithTimeTracking' );
 110  
 111          $issueId = $this->client->mc_issue_add(
 112              $this->userName,
 113              $this->password,
 114              $issueToAdd);
 115  
 116          $noteData = array(
 117              'text' => "first note",
 118              'time_tracking' => "30"
 119          );
 120  
 121          $issueNoteId = $this->client->mc_issue_note_add(
 122              $this->userName,
 123              $this->password,
 124              $issueId,
 125              $noteData);
 126  
 127          $issueWithNote = $this->client->mc_issue_get(
 128              $this->userName,
 129              $this->password,
 130              $issueId);
 131  
 132          $this->assertEquals( 1, count( $issueWithNote->notes ) );
 133  
 134          $note = $issueWithNote->notes[0];
 135  
 136          $this->assertEquals( 30, $note->time_tracking );
 137  
 138          $this->client->mc_issue_delete(
 139              $this->userName,
 140              $this->password,
 141              $issueId);
 142  
 143      }
 144  
 145      /**
 146       * A test case that tests the following:
 147       * 1. Create an issue.
 148       * 2. Add a note to the issue.
 149       * 3. Get the issue.
 150       * 4. Verify that the issue has one note.
 151       * 5.  Update this note
 152       * 6.  Verify that the note has been updated
 153       * 7.  Delete the note.
 154       * 8.  Get the issue.
 155       * 9.  Verify that the issue has no notes.
 156       * 10. Delete the issue.
 157       */
 158  	public function testAddThenUpdateThenDeleteNote() {
 159          $issueToAdd = $this->getIssueToAdd( 'IssueNoteTest.testAddThenUpdateThenDeleteNote' );
 160  
 161          $issueId = $this->client->mc_issue_add(
 162              $this->userName,
 163              $this->password,
 164              $issueToAdd);
 165  
 166          $this->deleteAfterRun( $issueId );
 167  
 168          $createdIssue = $this->client->mc_issue_get(
 169              $this->userName,
 170              $this->password,
 171              $issueId);
 172  
 173          $noteData = array(
 174              'text' => "some note",
 175          );
 176  
 177          $issueNoteId = $this->client->mc_issue_note_add(
 178              $this->userName,
 179              $this->password,
 180              $issueId,
 181              $noteData);
 182  
 183          $issueWithNote = $this->client->mc_issue_get(
 184              $this->userName,
 185              $this->password,
 186              $issueId);
 187  
 188          $this->assertEquals( 1, count( $issueWithNote->notes ) );
 189          
 190          $noteDataNew = array(
 191              'id' => $issueNoteId,
 192              'text' => "some new note"
 193          );
 194  
 195          $this->client->mc_issue_note_update(
 196              $this->userName,
 197              $this->password,
 198              $noteDataNew);
 199  
 200          $issueWithNewNote = $this->client->mc_issue_get(
 201              $this->userName,
 202              $this->password,
 203              $issueId);
 204  
 205          $this->assertEquals( 1, count( $issueWithNote->notes ) );        
 206  
 207          $this->client->mc_issue_note_delete(
 208              $this->userName,
 209              $this->password,
 210              $issueNoteId);
 211  
 212          $issueWithNote = $this->client->mc_issue_get(
 213              $this->userName,
 214              $this->password,
 215              $issueId);
 216  
 217          $this->assertFalse( isset( $issueWithNote->notes ) );
 218      }
 219  
 220      /**
 221       * A test case that tests the following:
 222       * 1. Create an issue.
 223       * 2. Attempt to add a note with no text.
 224       * 3. Make sure the SoapFault exception is thrown.
 225       * 4. Delete the issue.
 226       */
 227  	public function testAddNoteWithNoText() {
 228          $issueToAdd = $this->getIssueToAdd( 'IssueNoteTest.testAddNote' );
 229  
 230          $issueId = $this->client->mc_issue_add(
 231              $this->userName,
 232              $this->password,
 233              $issueToAdd);
 234  
 235          $this->deleteAfterRun( $issueId );
 236  
 237          $createdIssue = $this->client->mc_issue_get(
 238              $this->userName,
 239              $this->password,
 240              $issueId);
 241  
 242          $noteData = array(
 243          );
 244  
 245          try {
 246              $issueNoteId = $this->client->mc_issue_note_add(
 247                  $this->userName,
 248                  $this->password,
 249                  $issueId,
 250                  $noteData);
 251  
 252              $this->assertTrue(false);
 253          } catch ( SoapFault $e ) {
 254          }
 255      }
 256  }


Generated: Thu Jul 28 15:48:31 2011 Cross-referenced by PHPXref 0.7