[ Index ]

PHP Cross Reference of MantisBT

title

Body

[close]

/tests/soap/ -> IssueMonitorTest.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 monitoring webservice methods.
  28   */
  29  class IssueMonitorTest extends SoapBase {
  30      /**
  31       * A test case that tests the following:
  32       * 1. Creates a new issue
  33       * 2. validates that the monitor list is empty
  34       */
  35  	public function testCreateIssueHasEmptyMonitorList() {
  36  
  37          $issueToAdd = $this->getIssueToAdd( 'IssueMonitorTest.testCreateIssueHasEmptyMonitorList' );
  38  
  39          $issueId = $this->client->mc_issue_add(
  40              $this->userName,
  41              $this->password,
  42              $issueToAdd);
  43              
  44          $this->deleteAfterRun( $issueId );
  45  
  46          $issue = $this->client->mc_issue_get(
  47              $this->userName,
  48              $this->password,
  49              $issueId);
  50  
  51          // no monitors on new issue
  52          $this->assertEquals(0, sizeof($issue->monitors));
  53      }
  54      
  55      /**
  56       * A test case that tests the following
  57       * 
  58       * 1. Creates a new issue
  59       * 2. Adds a monitor to it
  60       * 3. Retrieves the issue and verifies that the user is in the monitor list
  61       * 4. Removes a monitor from the issue
  62       * 5. Retrieves the issue and verifies that the user is not in the monitor list
  63       */
  64  	public function testAddMonitorWhenCreatingAnIssue() {
  65  
  66          $issueToAdd = $this->getIssueToAdd( 'IssueMonitorTest.testAddRemoveMonitorFromIssue' );
  67          $issueToAdd['monitors'] = array(
  68              array ('id' =>  $this->userId )
  69          );
  70  
  71          $issueId = $this->client->mc_issue_add(
  72              $this->userName,
  73              $this->password,
  74              $issueToAdd);
  75              
  76          $this->deleteAfterRun( $issueId );
  77          
  78          $issue = $this->client->mc_issue_get(
  79              $this->userName,
  80              $this->password,
  81              $issueId);        
  82          
  83          self::assertEquals(1, sizeof($issue->monitors));
  84          
  85          $monitor = $issue->monitors[0];
  86          
  87          self::assertEquals( $this->userId, $monitor->id );
  88          self::assertEquals( $this->userName, $monitor->name );
  89          
  90      }
  91      
  92      /**
  93       * A test case that tests the following
  94       * 
  95       * 1. Creates a new issue
  96       * 2. Adds a monitor to it
  97       * 3. Retrieves the issue and verifies that the user is in the monitor list
  98       */
  99  	public function testAddMonitorToExistingIssue() {
 100          
 101          $issueToAdd = $this->getIssueToAdd( 'IssueMonitorTest.testAddRemoveMonitorFromIssue' );
 102  
 103          $issueId = $this->client->mc_issue_add(
 104              $this->userName,
 105              $this->password,
 106              $issueToAdd);
 107              
 108          $this->deleteAfterRun( $issueId );
 109          
 110          $issue = $this->client->mc_issue_get(
 111              $this->userName,
 112              $this->password,
 113              $issueId);        
 114          
 115          $issue->monitors = array(
 116              array ('id' =>  $this->userId )
 117          );
 118          
 119          $this->client->mc_issue_update( $this->userName, $this->password, $issueId, $issue );
 120              
 121          $issue = $this->client->mc_issue_get( $this->userName, $this->password, $issueId);
 122          
 123          self::assertEquals(1, sizeof($issue->monitors));
 124          
 125          $monitor = $issue->monitors[0];
 126          
 127          self::assertEquals( $this->userId, $monitor->id );
 128          self::assertEquals( $this->userName, $monitor->name );
 129      }
 130      
 131      /**
 132       * A test case that tests the following
 133       * 
 134       * 1. Creates a new issue with a monitor
 135       * 2. Retrieves the issue
 136       * 3. Updates the monitor list to be empty
 137       * 4. Retrieves the issue and verifies that the monitors list is empty
 138       */
 139  	public function testRemoveMonitor() {
 140          
 141          $issueToAdd = $this->getIssueToAdd( 'IssueMonitorTest.testAddRemoveMonitorFromIssue' );
 142          $issueToAdd['monitors'] = array(
 143              array ('id' =>  $this->userId )
 144          );
 145  
 146          $issueId = $this->client->mc_issue_add(
 147              $this->userName,
 148              $this->password,
 149              $issueToAdd);
 150              
 151          $this->deleteAfterRun( $issueId );
 152          
 153          $issue = $this->client->mc_issue_get(
 154              $this->userName,
 155              $this->password,
 156              $issueId);
 157          
 158          $issue->monitors = array();
 159          
 160          $this->client->mc_issue_update( $this->userName, $this->password, $issueId, $issue );
 161              
 162          $issue = $this->client->mc_issue_get( $this->userName, $this->password, $issueId);
 163          
 164          self::assertEquals(0, sizeof($issue->monitors));
 165      }
 166      
 167      /**
 168       * A test case that tests the following
 169       * 
 170       * 1. Creates a new issue with a monitor
 171       * 2. Retrieves the issue
 172       * 3. Updates the issue ( no actual changes )
 173       * 4. Retrieves the issue and verifies that the monitors list is unchanged
 174       */
 175  	public function testUpdateKeepsMonitor() {
 176          
 177          $issueToAdd = $this->getIssueToAdd( 'IssueMonitorTest.testUpdateKeepsMonitor' );
 178          $issueToAdd['monitors'] = array(
 179              array ('id' =>  $this->userId )
 180          );
 181  
 182          $issueId = $this->client->mc_issue_add(
 183              $this->userName,
 184              $this->password,
 185              $issueToAdd);
 186              
 187          $this->deleteAfterRun( $issueId );
 188          
 189          $issue = $this->client->mc_issue_get(
 190              $this->userName,
 191              $this->password,
 192              $issueId);
 193          
 194          $this->client->mc_issue_update( $this->userName, $this->password, $issueId, $issue );
 195              
 196          $issue = $this->client->mc_issue_get( $this->userName, $this->password, $issueId);
 197          
 198          self::assertEquals(1, sizeof($issue->monitors));
 199      }        
 200  }


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