CRM-13283 - add API unit tests to StatusPreference to support passing a string as...
authorJon goldberg <jon@palantetech.coop>
Mon, 27 Apr 2015 22:57:07 +0000 (16:57 -0600)
committerJon goldberg <jon@palantetech.coop>
Tue, 21 Jul 2015 20:37:37 +0000 (16:37 -0400)
tests/phpunit/api/v3/StatusPreferenceTest.php

index 3091e967fb6347ee917d0bfedc7baebad801c138..804cff324a4a970f0fe36c0933b1ed4ff47b3133 100644 (file)
@@ -108,4 +108,23 @@ class api_v3_StatusPreferenceTest extends CiviUnitTestCase {
     $result = $this->callAPIFailure('StatusPreference', 'create', $this->_params);
   }
 
+  /**
+   * Test creating a severity by name, not integer.
+   */
+  public function testCreateSeverityByName() {
+    // Any permutation of uppercase/lowercase should work.
+    $this->_params['minimum_report_severity'] = 'cRItical';
+    $result = $this->callAPIAndDocument('StatusPreference', 'create', $this->_params, __FUNCTION__, __FILE__);
+    $id = $result['id'];
+    $this->assertEquals(5, $result['values'][$id]['minimum_report_severity'], 'In line ' . __LINE__);
+  }
+
+  /**
+   * Test creating an invalid severity by name.
+   */
+  public function testCreateSeverityWithInvalidName() {
+    $this->_params['minimum_report_severity'] = 'wdsadasdarning';
+    $result = $this->callAPIFailure('StatusPreference', 'create', $this->_params);
+  }
+
 }