Add in unit test of Campaign BAO query voter clause
authorSeamus Lee <seamuslee001@gmail.com>
Thu, 21 Nov 2019 06:29:41 +0000 (17:29 +1100)
committerSeamus Lee <seamuslee001@gmail.com>
Thu, 21 Nov 2019 06:29:41 +0000 (17:29 +1100)
CRM/Campaign/BAO/Query.php
tests/phpunit/CRM/Campaign/BAO/QueryTest.php [new file with mode: 0644]

index 02e251f760f50b7b516d4201c147d1f16a1cc3f8..8e3191cbcc5fbfca38d7138d0347b0d7e593b5c5 100644 (file)
@@ -505,7 +505,7 @@ INNER JOIN  civicrm_custom_group grp on fld.custom_group_id = grp.id
         $tempTable = CRM_Utils_SQL_TempTable::build();
         $tempTableName = $tempTable->getName();
         CRM_Core_DAO::executeQuery("DROP TEMPORARY TABLE IF EXISTS {$tempTableName}");
-        $tempTable->createWithColumns('id int unsigned NOT NULL AUTO_INCREMENT, survey_contact_id int unsigned NOT NULL, PRIMARY KEY ( id )')
+        $tempTable->createWithColumns('id int unsigned NOT NULL AUTO_INCREMENT, survey_contact_id int unsigned NOT NULL, PRIMARY KEY ( id )');
 
         $batch = 100;
         $insertedCount = 0;
diff --git a/tests/phpunit/CRM/Campaign/BAO/QueryTest.php b/tests/phpunit/CRM/Campaign/BAO/QueryTest.php
new file mode 100644 (file)
index 0000000..21ecce3
--- /dev/null
@@ -0,0 +1,39 @@
+<?php
+/*
+ +--------------------------------------------------------------------+
+ | Copyright CiviCRM LLC. All rights reserved.                        |
+ |                                                                    |
+ | This work is published under the GNU AGPLv3 license with some      |
+ | permitted exceptions and without any warranty. For full license    |
+ | and copyright information, see https://civicrm.org/licensing       |
+ +--------------------------------------------------------------------+
+ */
+
+/**
+ *  Test APIv3 civicrm_contribute_* functions
+ *
+ * @package CiviCRM_APIv3
+ * @subpackage API_Contribution
+ * @group headless
+ */
+class CRM_Campaign_BAO_QueryTest extends CiviUnitTestCase {
+
+  public function testCampaignVoterClause() {
+    $loggedInContact = $this->createLoggedInUser();
+    $contact = $this->individualCreate();
+    $activityType = CRM_Core_PseudoConstant::getKey('CRM_Activity_BAO_Activity', 'activity_type_id', 'survey');
+    $surveyParams = [
+      'title' => 'Test Survey',
+      'activity_type_id' => $activityType,
+      'created_id' => $loggedInContact,
+    ];
+    $survery = CRM_Campaign_BAO_Survey::create($surveyParams);
+    $voterClauseParams = [
+      'campaign_search_voter_for' => 'reserve',
+      'campaign_survey_id' => $survery->id,
+      'survey_interviewer_id' => $loggedInContact,
+    ];
+    CRM_Campaign_BAO_Query::voterClause($voterClauseParams);
+  }
+
+}