add tests for contact subtype null and not null report filters
authorEli Lisseck <lisseck@gmail.com>
Thu, 11 Jul 2019 23:41:33 +0000 (16:41 -0700)
committerEli Lisseck <lisseck@gmail.com>
Thu, 11 Jul 2019 23:41:33 +0000 (16:41 -0700)
tests/phpunit/api/v3/ReportTemplateTest.php

index beae3d5b16cae23bc4960bf6a419ef70b0ac0aef..1c110734fad1591ba10e1bf2c9634055586331ee 100644 (file)
@@ -1123,6 +1123,44 @@ class api_v3_ReportTemplateTest extends CiviUnitTestCase {
     $this->assertEquals(1, $rows['count']);
   }
 
+  /**
+   * Test contact subtype filter on summary report.
+   *
+   * @throws \CRM_Core_Exception
+   */
+  public function testContactSubtypeNotNull() {
+    $this->individualCreate(['contact_sub_type' => ['Student', 'Parent']]);
+    $this->individualCreate();
+
+    $rows = $this->callAPISuccess('report_template', 'getrows', [
+      'report_id' => 'contact/summary',
+      'contact_sub_type_op' => 'nnll',
+      'contact_sub_type_value' => [],
+      'contact_type_op' => 'eq',
+      'contact_type_value' => 'Individual',
+    ]);
+    $this->assertEquals(1, $rows['count']);
+  }
+
+  /**
+   * Test contact subtype filter on summary report.
+   *
+   * @throws \CRM_Core_Exception
+   */
+  public function testContactSubtypeNull() {
+    $this->individualCreate(['contact_sub_type' => ['Student', 'Parent']]);
+    $this->individualCreate();
+
+    $rows = $this->callAPISuccess('report_template', 'getrows', [
+      'report_id' => 'contact/summary',
+      'contact_sub_type_op' => 'nll',
+      'contact_sub_type_value' => [],
+      'contact_type_op' => 'eq',
+      'contact_type_value' => 'Individual',
+    ]);
+    $this->assertEquals(1, $rows['count']);
+  }
+
   /**
    * Test PCP report to ensure total donors and total committed is accurate.
    */