4 +--------------------------------------------------------------------+
5 | Copyright CiviCRM LLC. All rights reserved. |
7 | This work is published under the GNU AGPLv3 license with some |
8 | permitted exceptions and without any warranty. For full license |
9 | and copyright information, see https://civicrm.org/licensing |
10 +--------------------------------------------------------------------+
14 * Test CRM_Report_Utils_Report functions.
18 class CRM_Report_Utils_ReportTest
extends CiviUnitTestCase
{
23 public function testMakeCsv() {
24 $form = new CRM_Report_Form();
25 $form->_columnHeaders
= [
26 'civicrm_activity_activity_type_id' => [
27 'title' => 'Activity Type',
30 'civicrm_activity_activity_subject' => [
34 'civicrm_activity_details' => [
35 'title' => 'Activity Details',
40 $details = <<<ENDDETAILS
41 <p>Here's some typical data from an activity details field.
43 <p>дè some non-ascii and <strong>html</strong> styling and these ̋“weird” quotes’s.
45 <p>Also some named entities "hello". And & é. Also some math like 2 < 4.
49 $expectedOutput = <<<ENDOUTPUT
50 \xEF\xBB\xBF"Activity Type","Subject","Activity Details"\r
51 "Meeting","Meeting with the apostrophe's and that person who does ""air quotes"". Some non-ascii characters: дè","Here's some typical data from an activity details field.
53 дè some non-ascii and html styling and these ̋“weird” quotes’s.
55 Also some named entities ""hello"". And & é. Also some math like 2 < 4.
62 'civicrm_activity_activity_type_id' => 'Meeting',
63 'civicrm_activity_activity_subject' => 'Meeting with the apostrophe\'s and that person who does "air quotes". Some non-ascii characters: дè',
64 'civicrm_activity_details' => $details,
68 $csvString = CRM_Report_Utils_Report
::makeCsv($form, $rows);
69 $this->assertEquals($expectedOutput, $csvString);