Add Unit test to provde domain filtering is working with activeProviderCount
authorSeamus Lee <seamuslee001@gmail.com>
Mon, 31 Jul 2017 06:36:48 +0000 (16:36 +1000)
committerSeamus Lee <seamuslee001@gmail.com>
Mon, 31 Jul 2017 06:36:48 +0000 (16:36 +1000)
tests/phpunit/CRM/SMS/BAO/ProviderTest.php

index 185edf826bcb63bdc37f2d1d5721388f9047a86b..89ad4c9ae186dc26a6d341359aa8cf6213aa3474 100644 (file)
@@ -77,6 +77,32 @@ class CRM_SMS_BAO_ProviderTest extends CiviUnitTestCase {
     CRM_SMS_BAO_Provider::del($provider['id']);
   }
 
+  /**
+   * CRM-20989
+   * Add unit test to ensure that filtering by domain works in get Active Providers
+   */
+  public function testActiveProviderCount() {
+    $values = array(
+      'domain_id' => NULL,
+      'title' => 'test SMS provider',
+      'username' => 'test',
+      'password' => 'dummpy password',
+      'name' => 1,
+      'is_active' => 1,
+      'api_type' => 1,
+    );
+    $provider = $this->callAPISuccess('SmsProvider', 'create', $values);
+    $provider2 = $this->callAPISuccess('SmsProvider', 'create', array_merge($values, array('domain_id' => 2)));
+    $result = CRM_SMS_BAO_Provider::activeProviderCount();
+    $this->assertEquals(1, $result);
+    $provider3 = $this->callAPISuccess('SmsProvider', 'create', array_merge($values, array('domain_id' => 1)));
+    $result = CRM_SMS_BAO_Provider::activeProviderCount();
+    $this->assertEquals(2, $result);
+    CRM_SMS_BAO_Provider::del($provider['id']);
+    CRM_SMS_BAO_Provider::del($provider2['id']);
+    CRM_SMS_BAO_Provider::del($provider3['id']);
+  }
+
   /**
    * CRM-19961 Check that when a domain is not passed when saving it defaults to current domain when create
    */