3 +--------------------------------------------------------------------+
4 | Copyright CiviCRM LLC. All rights reserved. |
6 | This work is published under the GNU AGPLv3 license with some |
7 | permitted exceptions and without any warranty. For full license |
8 | and copyright information, see https://civicrm.org/licensing |
9 +--------------------------------------------------------------------+
13 * Test for CRM_Financial_Page_Ajax class.
16 class CRM_Financial_Page_AjaxTest
extends CiviUnitTestCase
{
18 public function tearDown(): void
{
19 $this->quickCleanUpFinancialEntities();
21 'civicrm_entity_batch',
28 * Test the ajax function to get financial transactions.
30 * Test focus is on ensuring changes to how labels are retrieved does not cause regression.
32 public function testGetFinancialTransactionsList(): void
{
33 $individualID = $this->individualCreate();
34 $this->contributionCreate(['contact_id' => $individualID, 'trxn_id' => 12345]);
35 $batch = $this->callAPISuccess('Batch', 'create', ['title' => 'test', 'status_id' => 'Open']);
36 CRM_Core_DAO
::executeQuery("
37 INSERT INTO civicrm_entity_batch (entity_table, entity_id, batch_id)
38 values('civicrm_financial_trxn', 1, 1)
40 $_REQUEST['sEcho'] = 1;
41 $_REQUEST['entityID'] = $batch['id'];
42 $_REQUEST['return'] = TRUE;
43 $json = CRM_Financial_Page_AJAX
::getFinancialTransactionsList();
44 $json = str_replace(rtrim(CIVICRM_UF_BASEURL
, '/'), 'http://FIX ME', $json);
45 $this->assertEquals('{"sEcho": 1, "iTotalRecords": 1, "iTotalDisplayRecords": 1, "aaData": [ ["","<a href=\"/index.php?q=civicrm/contact/view&reset=1&cid=3\" data-tooltip-url=\"/index.php?q=civicrm/profile/view&reset=1&gid=7&id=3&snippet=4&is_show_email_task=1\" class=\"crm-summary-link\"><div'
46 . ' class=\"icon crm-icon Individual-icon\"></div></a>","<a href=/index.php?q=civicrm/contact/view&reset=1&cid=3>Anderson, Anthony</a>","$100.00","12345","' . CRM_Utils_Date
::customFormat(date('Ymd')) . ' 12:00 AM","' . CRM_Utils_Date
::customFormat(date('Ymd')) . ' 12:00 AM",'
47 . '"Credit Card","Completed","Donation","<span><a href=\"/index.php?q=civicrm/contact/view/contribution&reset=1&id=1&cid=3&action=view&context=contribution&'
48 . 'selectedChild=contribute\" class=\"action-item crm-hover-button\" title=\'View Contribution\' >View</a></span>"]] }', $json);
52 * Test getting open batch.
54 public function testGetFinancialTransactionsListOpenBatch(): void
{
55 $individualID = $this->individualCreate();
56 $this->contributionCreate(['contact_id' => $individualID, 'trxn_id' => 12345]);
57 $batch = $this->callAPISuccess('Batch', 'create', ['title' => 'test', 'status_id' => 'Open']);
58 CRM_Core_DAO
::executeQuery("
59 INSERT INTO civicrm_entity_batch (entity_table, entity_id, batch_id)
60 values('civicrm_financial_trxn', 1, 1)
62 $_REQUEST['sEcho'] = 1;
63 $_REQUEST['entityID'] = $batch['id'];
64 $_REQUEST['statusID'] = 1;
65 $_REQUEST['notPresent'] = 1;
66 $_REQUEST['return'] = TRUE;
67 $json = CRM_Financial_Page_AJAX
::getFinancialTransactionsList();
68 $json = str_replace(rtrim(CIVICRM_UF_BASEURL
, '/'), 'http://FIX ME', $json);
69 $this->assertEquals('{"sEcho": 1, "iTotalRecords": 1, "iTotalDisplayRecords": 1, "aaData": [ ["<input type=\'checkbox\' id=\'mark_x_2\' name=\'mark_x_2\' value=\'1\' onclick=enableActions(\'x\')></input>","<a href=\"/index.php?q=civicrm/contact/view&reset=1&cid=3\" data-tooltip-url=\"/index.php?q=civicrm/profile/view&reset=1&gid=7&id=3&snippet=4&is_show_email_task=1\" class=\"crm-summary-link\"><div'
70 . ' class=\"icon crm-icon Individual-icon\"></div></a>","<a href=/index.php?q=civicrm/contact/view&reset=1&cid=3>Anderson, Anthony</a>","$5.00","12345","' . CRM_Utils_Date
::customFormat(date('Ymd')) . ' 12:00 AM","' . CRM_Utils_Date
::customFormat(date('Ymd')) . ' 12:00 AM",'
71 . '"Credit Card","Completed","Donation","<span><a href=\"/index.php?q=civicrm/contact/view/contribution&reset=1&id=1&cid=3&action=view&context=contribution&'
72 . 'selectedChild=contribute\" class=\"action-item crm-hover-button\" title=\'View Contribution\' >View</a><a href=\"#\" class=\"action-item crm-hover-button disable-action\" title=\'Assign Transaction\' onclick = \"assignRemove( 2,\'assign\' );\">Assign</a></span>"]] }', $json);