Created
November 14, 2019 17:07
-
-
Save MegaphoneJon/eaf4b446a3eda0d9bcd0825713a99df9 to your computer and use it in GitHub Desktop.
I tried and failed to write a CiviCRM ReportTemplate test that relied on custom fields.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
+ /** | |
+ * Ensure that a LEFT JOIN to a 1-to-many table doesn't multiply the statistics (reporting#21). | |
+ */ | |
+ public function testContributionDetailStatisticsMultiRecordCustomField() { | |
+ $customGroup = $this->CustomGroupMultipleCreateWithFields(); | |
+ $contactID = $this->individualCreate(); | |
+ $params = [ | |
+ 'entity_id' => $contactID, | |
+ 'custom_' . $customGroup['custom_field_id'][0] => 'value 1', | |
+ ]; | |
+ $this->callAPISuccess('CustomValue', 'create', $params); | |
+ $params = [ | |
+ 'entity_id' => $contactID, | |
+ 'custom_' . $customGroup['custom_field_id'][0] => 'value 2', | |
+ ]; | |
+ $this->callAPISuccess('CustomValue', 'create', $params); | |
+ $this->contributionCreate(['contact_id' => $contactID]); | |
+ $params = [ | |
+ 'report_id' => 'contribute/detail', | |
+ 'fields' => [ | |
+ 'custom_' . $customGroup['custom_field_id'][0] => '1', | |
+ 'id' => '1', | |
+ ], | |
+ ]; | |
+ $result = $this->callAPISuccess('report_template', 'getstatistics', $params); | |
+ print_r($result); | |
+ } | |
+ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment