public function processReportMode() {
$this->setOutputMode();
- $buttonName = $this->controller->getButtonName();
$this->_sendmail
= CRM_Utils_Request::retrieve(
'sendmail',
* is that we might print a bar chart as a pdf.
*/
protected function setOutputMode() {
- $buttonName = $this->controller->getButtonName();
$this->_outputMode = str_replace('report_instance.', '', CRM_Utils_Request::retrieve(
'output',
'String',
FALSE,
CRM_Utils_Array::value('task', $this->_params)
));
+ // if contacts are added to group
+ if (!empty($this->_params['groups']) && empty($this->_outputMode)) {
+ $this->_outputMode = 'group';
+ }
if (isset($this->_params['task'])) {
unset($this->_params['task']);
}
- if ($this->_groupButtonName == $buttonName) {
- $this->_outputMode = 'group';
- }
}
/**
$this->assertCsvArraysEqual($expectedOutputCsvArray, $reportCsvArray);
}
+ /**
+ * Test processReportMode() Function in Reports
+ */
+ public function testOutputMode() {
+ $clazz = new ReflectionClass('CRM_Report_Form');
+ $reportForm = new CRM_Report_Form();
+
+ $params = $clazz->getProperty('_params');
+ $params->setAccessible(TRUE);
+ $outputMode = $clazz->getProperty('_outputMode');
+ $outputMode->setAccessible(TRUE);
+
+ $params->setValue($reportForm, array('groups' => 4));
+ $reportForm->processReportMode();
+ $this->assertEquals('group', $outputMode->getValue($reportForm));
+
+ $params->setValue($reportForm, array('task' => 'copy'));
+ $reportForm->processReportMode();
+ $this->assertEquals('copy', $outputMode->getValue($reportForm));
+
+ $params->setValue($reportForm, array('task' => 'print'));
+ $reportForm->processReportMode();
+ $this->assertEquals('print', $outputMode->getValue($reportForm));
+ }
+
}