[ Index ]

PHP Cross Reference of MantisBT

title

Body

[close]

/tests/soap/ -> EnumTest.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 enum related webservice method.
  28   */
  29  class EnumTest extends SoapBase {
  30      /**
  31       * Tests mc_enum_access_levels method.
  32       */
  33  	public function testAccessLevel() {
  34          $accessLevelsObjectRefs = $this->client->mc_enum_access_levels( $this->userName, $this->password);
  35  
  36          $accessLevels = EnumTest::ObjectRefsToAssoc( $accessLevelsObjectRefs );
  37  
  38          // '10:viewer,25:reporter,40:updater,55:developer,70:manager,90:administrator'
  39  
  40          $this->assertEquals( 6, count( $accessLevels ) );
  41          $this->assertEquals( 'viewer', $accessLevels[10] );
  42          $this->assertEquals( 'reporter', $accessLevels[25] );
  43          $this->assertEquals( 'updater', $accessLevels[40] );
  44          $this->assertEquals( 'developer', $accessLevels[55] );
  45          $this->assertEquals( 'manager', $accessLevels[70] );
  46          $this->assertEquals( 'administrator', $accessLevels[90] );
  47      }
  48  
  49      /**
  50       * Tests the mc_enum_access_levels with invalid credentials.
  51       *
  52       * @expectedException SoapFault
  53       */
  54  	public function testAccessLevelAccessDenied() {
  55          $this->client->mc_enum_access_levels( 'administrator', '' );
  56      }
  57  
  58      /**
  59       * Tests mc_enum_status method.
  60       */
  61  	public function testStatus() {
  62          $statusesObjectRefs = $this->client->mc_enum_status($this->userName, $this->password);
  63  
  64          $statuses = EnumTest::ObjectRefsToAssoc( $statusesObjectRefs );
  65  
  66          // '10:new,20:feedback,30:acknowledged,40:confirmed,50:assigned,80:resolved,90:closed'
  67  
  68          $this->assertEquals( 7, count( $statuses ) );
  69          $this->assertEquals( 'new', $statuses[10] );
  70          $this->assertEquals( 'feedback', $statuses[20] );
  71          $this->assertEquals( 'acknowledged', $statuses[30] );
  72          $this->assertEquals( 'confirmed', $statuses[40] );
  73          $this->assertEquals( 'assigned', $statuses[50] );
  74          $this->assertEquals( 'resolved', $statuses[80] );
  75          $this->assertEquals( 'closed', $statuses[90] );
  76      }
  77  
  78      /**
  79       * Tests mc_enum_status method with invalid credentials.
  80       *
  81       * @expectedException SoapFault
  82       */
  83  	public function testStatusAccessDenied() {
  84          $this->client->mc_enum_status( 'administrator', '' );
  85      }
  86  
  87      /**
  88       * Tests mc_enum_priorities method.
  89       */
  90  	public function testPriority() {
  91          $prioritiesObjectRefs = $this->client->mc_enum_priorities($this->userName, $this->password);
  92  
  93          $priorities = EnumTest::ObjectRefsToAssoc( $prioritiesObjectRefs );
  94  
  95          // '10:none,20:low,30:normal,40:high,50:urgent,60:immediate'
  96  
  97          $this->assertEquals( 6, count( $priorities ) );
  98          $this->assertEquals( 'none', $priorities[10] );
  99          $this->assertEquals( 'low', $priorities[20] );
 100          $this->assertEquals( 'normal', $priorities[30] );
 101          $this->assertEquals( 'high', $priorities[40] );
 102          $this->assertEquals( 'urgent', $priorities[50] );
 103          $this->assertEquals( 'immediate', $priorities[60] );
 104      }
 105  
 106      /**
 107       * Tests mc_enum_priorities method with invalid credentials.
 108       *
 109       * @expectedException SoapFault
 110       */
 111  	public function testPriorityAccessDenied() {
 112          $this->client->mc_enum_priorities( 'administrator', '' );
 113      }
 114  
 115      /**
 116       * Tests mc_enum_reproducibilities method.
 117       */
 118  	public function testReproducibility() {
 119          $reproducibilityObjectRefs = $this->client->mc_enum_reproducibilities($this->userName, $this->password);
 120  
 121          $reproducibilities = EnumTest::ObjectRefsToAssoc( $reproducibilityObjectRefs );
 122  
 123          // '10:always,30:sometimes,50:random,70:have not tried,90:unable to duplicate,100:N/A'
 124  
 125          $this->assertEquals( 6, count( $reproducibilities ) );
 126          $this->assertEquals( 'always', $reproducibilities[10] );
 127          $this->assertEquals( 'sometimes', $reproducibilities[30] );
 128          $this->assertEquals( 'random', $reproducibilities[50] );
 129          $this->assertEquals( 'have not tried', $reproducibilities[70] );
 130          $this->assertEquals( 'unable to reproduce', $reproducibilities[90] );
 131          $this->assertEquals( 'N/A', $reproducibilities[100] );
 132      }
 133  
 134      /**
 135       * Tests mc_enum_reproducibilities method with invalid credentials.
 136       *
 137       * @expectedException SoapFault
 138       */
 139  	public function testReproducibilityAccessDenied() {
 140          $this->client->mc_enum_reproducibilities( 'administrator', '' );
 141      }
 142  
 143      /**
 144       * Tests mc_enum_severities method.
 145       */
 146  	public function testSeverity() {
 147          $severityObjectRefs = $this->client->mc_enum_severities($this->userName, $this->password);
 148  
 149          $severities = EnumTest::ObjectRefsToAssoc( $severityObjectRefs );
 150  
 151          // '10:feature,20:trivial,30:text,40:tweak,50:minor,60:major,70:crash,80:block'
 152  
 153          $this->assertEquals( 8, count( $severities ) );
 154          $this->assertEquals( 'feature', $severities[10] );
 155          $this->assertEquals( 'trivial', $severities[20] );
 156          $this->assertEquals( 'text', $severities[30] );
 157          $this->assertEquals( 'tweak', $severities[40] );
 158          $this->assertEquals( 'minor', $severities[50] );
 159          $this->assertEquals( 'major', $severities[60] );
 160          $this->assertEquals( 'crash', $severities[70] );
 161          $this->assertEquals( 'block', $severities[80] );
 162      }
 163  
 164      /**
 165       * Tests mc_enum_severities method with invalid credentials.
 166       *
 167       * @expectedException SoapFault
 168       */
 169  	public function testSeverityAccessDenied() {
 170          $this->client->mc_enum_severities( 'administrator', '' );
 171      }
 172  
 173      /**
 174       * Tests mc_enum_projections method.
 175       */
 176  	public function testProjection() {
 177          $projectionObjectRefs = $this->client->mc_enum_projections($this->userName, $this->password);
 178  
 179          $projections = EnumTest::ObjectRefsToAssoc( $projectionObjectRefs );
 180  
 181          // '10:none,30:tweak,50:minor fix,70:major rework,90:redesign'
 182  
 183          $this->assertEquals( 5, count( $projections ) );
 184          $this->assertEquals( 'none', $projections[10] );
 185          $this->assertEquals( 'tweak', $projections[30] );
 186          $this->assertEquals( 'minor fix', $projections[50] );
 187          $this->assertEquals( 'major rework', $projections[70] );
 188          $this->assertEquals( 'redesign', $projections[90] );
 189      }
 190  
 191      /**
 192       * Tests mc_enum_projections method with invalid credentials.
 193       *
 194       * @expectedException SoapFault
 195       */
 196  	public function testProjectionAccessDenied() {
 197          $this->client->mc_enum_projections( 'administrator', '' );
 198      }
 199  
 200      /**
 201       * Tests mc_enum_etas method.
 202       */
 203  	public function testEta() {
 204          $etaObjectRefs = $this->client->mc_enum_etas($this->userName, $this->password);
 205  
 206          $etas = EnumTest::ObjectRefsToAssoc( $etaObjectRefs );
 207  
 208          // '10:none,20:< 1 day,30:2-3 days,40:< 1 week,50:< 1 month,60:> 1 month'
 209  
 210          $this->assertEquals( 6, count( $etas ) );
 211          $this->assertEquals( 'none', $etas[10] );
 212          $this->assertEquals( '< 1 day', $etas[20] );
 213          $this->assertEquals( '2-3 days', $etas[30] );
 214          $this->assertEquals( '< 1 week', $etas[40] );
 215          $this->assertEquals( '< 1 month', $etas[50] );
 216          $this->assertEquals( '> 1 month', $etas[60] );
 217      }
 218  
 219      /**
 220       * Tests mc_enum_etas method with invalid credentials.
 221       *
 222       * @expectedException SoapFault
 223       */
 224  	public function testEtaAccessDenied() {
 225          $this->client->mc_enum_etas( 'administrator', '' );
 226      }
 227  
 228      /**
 229       * Tests mc_enum_resolutions method.
 230       */
 231  	public function testResolution() {
 232          $resolutionObjectRefs = $this->client->mc_enum_resolutions($this->userName, $this->password);
 233  
 234          $resolutions = EnumTest::ObjectRefsToAssoc( $resolutionObjectRefs );
 235  
 236          // '10:open,20:fixed,30:reopened,40:unable to duplicate,50:not fixable,60:duplicate,70:not a bug,80:suspended,90:wont fix'
 237  
 238          $this->assertEquals( 9, count( $resolutions ) );
 239          $this->assertEquals( 'open', $resolutions[10] );
 240          $this->assertEquals( 'fixed', $resolutions[20] );
 241          $this->assertEquals( 'reopened', $resolutions[30] );
 242          $this->assertEquals( 'unable to reproduce', $resolutions[40] );
 243          $this->assertEquals( 'not fixable', $resolutions[50] );
 244          $this->assertEquals( 'duplicate', $resolutions[60] );
 245          $this->assertEquals( 'no change required', $resolutions[70] );
 246          $this->assertEquals( 'suspended', $resolutions[80] );
 247          $this->assertEquals( 'won\'t fix', $resolutions[90] );
 248      }
 249  
 250      /**
 251       * Tests mc_enum_resolutions method with invalid credentials.
 252       *
 253       * @expectedException SoapFault
 254       */
 255  	public function testResolutionAccessDenied() {
 256          $this->client->mc_enum_resolutions( 'administrator', '' );
 257      }
 258  
 259      // TODO: mc_enum_project_status
 260      // TODO: mc_enum_project_view_states
 261      // TODO: mc_enum_custom_field_types
 262  
 263      /**
 264       * Converts an array of ObjectRefs array into an associate
 265       * array with the enum id as the key and the enum label as
 266       * the value.
 267       */
 268  	private static function ObjectRefsToAssoc( $objectRefs ) {
 269          $assocArray = array();
 270  
 271          foreach ( $objectRefs as $objectRef ) {
 272              $assocArray[$objectRef->id] = $objectRef->name;
 273          }
 274  
 275          return $assocArray;
 276      }
 277      
 278      /**
 279       * Tests mc_enum_get with severities parameter
 280       */
 281  	public function testEnumGet() {
 282          
 283          $result = $this->client->mc_enum_get($this->userName, $this->password, 'severity');
 284          
 285          $this->assertEquals( '10:feature,20:trivial,30:text,40:tweak,50:minor,60:major,70:crash,80:block', $result);
 286      }
 287  }


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