$this->assertContains("mainTabContainer", $contents);
}
+ /**
+ * Test AdditionalInfo::postProcessCommon
+ * @dataProvider additionalInfoProvider
+ * @param array $input
+ * @param array $expectedFormatted
+ */
+ public function testAdditionalInfoPostProcessCommon(array $input, array $expectedFormatted) {
+ $formatted = [];
+ $dummy = new CRM_Contribute_Form_AdditionalInfo();
+ CRM_Contribute_Form_AdditionalInfo::postProcessCommon($input, $formatted, $dummy);
+ $this->assertEquals($expectedFormatted, $formatted);
+ }
+
+ /**
+ * Dataprovider for testAdditionalInfoPostProcessCommon
+ * @return array
+ */
+ public function additionalInfoProvider(): array {
+ return [
+ 'no-date' => [
+ 'input' => [
+ 'qfKey' => 'CRMContributeFormContributionu2pbzqqmz74oscck4ss4osccw4wgccc884wkk4ws0o8wgss4w_8953',
+ 'entryURL' => 'http://example.org/civicrm/contact/view/contribution?reset=1&action=add&cid=1&context=contribution',
+ 'check_number' => '',
+ 'frequency_interval' => '1',
+ 'hidden_AdditionalDetail' => '1',
+ 'contact_id' => '1',
+ 'financial_type_id' => '1',
+ 'payment_instrument_id' => '4',
+ 'trxn_id' => '',
+ 'from_email_address' => '2',
+ 'contribution_status_id' => '1',
+ // This is unused here but is iffy to put in a dataprovider
+ 'receive_date' => '2021-01-14 11:12:13',
+ 'receipt_date' => '',
+ 'cancel_date' => '',
+ 'cancel_reason' => '',
+ 'price_set_id' => '',
+ 'total_amount' => 10,
+ 'currency' => 'USD',
+ 'source' => 'a source',
+ 'soft_credit_contact_id' => [
+ 1 => '',
+ 2 => '',
+ 3 => '',
+ 4 => '',
+ 5 => '',
+ 6 => '',
+ 7 => '',
+ 8 => '',
+ 9 => '',
+ 10 => '',
+ ],
+ 'soft_credit_amount' => [
+ 1 => '',
+ 2 => '',
+ 3 => '',
+ 4 => '',
+ 5 => '',
+ 6 => '',
+ 7 => '',
+ 8 => '',
+ 9 => '',
+ 10 => '',
+ ],
+ 'soft_credit_type' => [
+ 1 => '',
+ 2 => '',
+ 3 => '',
+ 4 => '',
+ 5 => '',
+ 6 => '',
+ 7 => '',
+ 8 => '',
+ 9 => '',
+ 10 => '',
+ ],
+ 'sct_default_id' => '3',
+ 'MAX_FILE_SIZE' => '2097152',
+ 'ip_address' => '127.0.0.1',
+ 'price_1' => [
+ 1 => 1,
+ ],
+ 'amount' => 10,
+ ],
+ 'expected' => [
+ 'non_deductible_amount' => NULL,
+ 'total_amount' => 10,
+ 'fee_amount' => NULL,
+ 'trxn_id' => '',
+ 'invoice_id' => NULL,
+ 'creditnote_id' => NULL,
+ 'campaign_id' => NULL,
+ 'contribution_page_id' => NULL,
+ 'thankyou_date' => NULL,
+ 'custom' => [],
+ ],
+ ],
+
+ 'date-no-time' => [
+ 'input' => [
+ 'qfKey' => 'CRMContributeFormContributionu2pbzqqmz74oscck4ss4osccw4wgccc884wkk4ws0o8wgss4w_8953',
+ 'entryURL' => 'http://example.org/civicrm/contact/view/contribution?reset=1&action=add&cid=1&context=contribution',
+ 'id' => '40',
+ 'frequency_interval' => '1',
+ 'hidden_AdditionalDetail' => '1',
+ 'thankyou_date' => '2021-01-14',
+ 'non_deductible_amount' => '0.00',
+ 'fee_amount' => '0.00',
+ 'invoice_id' => '',
+ 'creditnote_id' => '',
+ 'contribution_page_id' => '',
+ 'note' => '',
+ 'contact_id' => '1',
+ 'financial_type_id' => '1',
+ 'from_email_address' => '2',
+ 'contribution_status_id' => '1',
+ // This is unused here but is iffy to put in a dataprovider
+ 'receive_date' => '2021-01-14 11:12:13',
+ 'receipt_date' => '',
+ 'cancel_date' => '',
+ 'cancel_reason' => '',
+ 'price_set_id' => '',
+ 'total_amount' => '10.00',
+ 'currency' => 'USD',
+ 'source' => 'a source',
+ 'soft_credit_contact_id' => [
+ 1 => '',
+ 2 => '',
+ 3 => '',
+ 4 => '',
+ 5 => '',
+ 6 => '',
+ 7 => '',
+ 8 => '',
+ 9 => '',
+ 10 => '',
+ ],
+ 'soft_credit_amount' => [
+ 1 => '',
+ 2 => '',
+ 3 => '',
+ 4 => '',
+ 5 => '',
+ 6 => '',
+ 7 => '',
+ 8 => '',
+ 9 => '',
+ 10 => '',
+ ],
+ 'soft_credit_type' => [
+ 1 => '',
+ 2 => '',
+ 3 => '',
+ 4 => '',
+ 5 => '',
+ 6 => '',
+ 7 => '',
+ 8 => '',
+ 9 => '',
+ 10 => '',
+ ],
+ 'sct_default_id' => '3',
+ 'MAX_FILE_SIZE' => '2097152',
+ 'ip_address' => '127.0.0.1',
+ // leaving out since don't want to enforce string 'null' in a test
+ //'tax_amount' => 'null',
+ ],
+ 'expected' => [
+ 'non_deductible_amount' => '0.00',
+ 'total_amount' => '10.00',
+ 'fee_amount' => '0.00',
+ 'trxn_id' => NULL,
+ 'invoice_id' => '',
+ 'creditnote_id' => '',
+ 'campaign_id' => NULL,
+ 'contribution_page_id' => NULL,
+ 'thankyou_date' => '20210114000000',
+ 'custom' => [],
+ ],
+ ],
+
+ 'date-and-time' => [
+ 'input' => [
+ 'qfKey' => 'CRMContributeFormContributionu2pbzqqmz74oscck4ss4osccw4wgccc884wkk4ws0o8wgss4w_8953',
+ 'entryURL' => 'http://example.org/civicrm/contact/view/contribution?reset=1&action=add&cid=1&context=contribution',
+ 'id' => '40',
+ 'frequency_interval' => '1',
+ 'hidden_AdditionalDetail' => '1',
+ 'thankyou_date' => '2021-01-14 10:11:12',
+ 'non_deductible_amount' => '0.00',
+ 'fee_amount' => '0.00',
+ 'invoice_id' => '',
+ 'creditnote_id' => '',
+ 'contribution_page_id' => '',
+ 'note' => '',
+ 'contact_id' => '1',
+ 'financial_type_id' => '1',
+ 'from_email_address' => '2',
+ 'contribution_status_id' => '1',
+ // This is unused here but is iffy to put in a dataprovider
+ 'receive_date' => '2021-01-14 11:12:13',
+ 'receipt_date' => '',
+ 'cancel_date' => '',
+ 'cancel_reason' => '',
+ 'price_set_id' => '',
+ 'total_amount' => '10.00',
+ 'currency' => 'USD',
+ 'source' => 'a source',
+ 'soft_credit_contact_id' => [
+ 1 => '',
+ 2 => '',
+ 3 => '',
+ 4 => '',
+ 5 => '',
+ 6 => '',
+ 7 => '',
+ 8 => '',
+ 9 => '',
+ 10 => '',
+ ],
+ 'soft_credit_amount' => [
+ 1 => '',
+ 2 => '',
+ 3 => '',
+ 4 => '',
+ 5 => '',
+ 6 => '',
+ 7 => '',
+ 8 => '',
+ 9 => '',
+ 10 => '',
+ ],
+ 'soft_credit_type' => [
+ 1 => '',
+ 2 => '',
+ 3 => '',
+ 4 => '',
+ 5 => '',
+ 6 => '',
+ 7 => '',
+ 8 => '',
+ 9 => '',
+ 10 => '',
+ ],
+ 'sct_default_id' => '3',
+ 'MAX_FILE_SIZE' => '2097152',
+ 'ip_address' => '127.0.0.1',
+ // leaving out since don't want to enforce string 'null' in a test
+ //'tax_amount' => 'null',
+ ],
+ 'expected' => [
+ 'non_deductible_amount' => '0.00',
+ 'total_amount' => '10.00',
+ 'fee_amount' => '0.00',
+ 'trxn_id' => NULL,
+ 'invoice_id' => '',
+ 'creditnote_id' => '',
+ 'campaign_id' => NULL,
+ 'contribution_page_id' => NULL,
+ 'thankyou_date' => '20210114101112',
+ 'custom' => [],
+ ],
+ ],
+ ];
+ }
+
}