478c39cf |
1 | <?php |
2 | /* |
3 | +--------------------------------------------------------------------+ |
3435af9a |
4 | | CiviCRM version 4.7 | |
478c39cf |
5 | +--------------------------------------------------------------------+ |
6 | | Copyright CiviCRM LLC (c) 2004-2015 | |
7 | +--------------------------------------------------------------------+ |
8 | | This file is a part of CiviCRM. | |
9 | | | |
10 | | CiviCRM is free software; you can copy, modify, and distribute it | |
11 | | under the terms of the GNU Affero General Public License | |
12 | | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. | |
13 | | | |
14 | | CiviCRM is distributed in the hope that it will be useful, but | |
15 | | WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 | | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | |
17 | | See the GNU Affero General Public License for more details. | |
18 | | | |
19 | | You should have received a copy of the GNU Affero General Public | |
20 | | License and the CiviCRM Licensing Exception along | |
21 | | with this program; if not, contact CiviCRM LLC | |
22 | | at info[AT]civicrm[DOT]org. If you have questions about the | |
23 | | GNU Affero General Public License or the licensing of CiviCRM, | |
24 | | see the CiviCRM license FAQ at http://civicrm.org/licensing | |
25 | +--------------------------------------------------------------------+ |
26 | */ |
478c39cf |
27 | |
28 | /** |
29 | * Test for CRM_Financial_Page_Ajax class. |
acb109b7 |
30 | * @group headless |
478c39cf |
31 | */ |
32 | class CRM_Financial_Page_AjaxTest extends CiviUnitTestCase { |
33 | |
34 | /** |
35 | * Test the ajax function to get financial transactions. |
36 | * |
37 | * Test focus is on ensuring changes to how labels are retrieved does not cause regression. |
38 | */ |
39 | public function testGetFinancialTransactionsList() { |
40 | $individualID = $this->individualCreate(); |
7fd21004 |
41 | $this->contributionCreate(array('contact_id' => $individualID)); |
478c39cf |
42 | $batch = $this->callAPISuccess('Batch', 'create', array('title' => 'test', 'status_id' => 'Open')); |
43 | CRM_Core_DAO::executeQuery(" |
44 | INSERT INTO civicrm_entity_batch (entity_table, entity_id, batch_id) |
45 | values('civicrm_financial_trxn', 1, 1) |
46 | "); |
47 | $_REQUEST['sEcho'] = 1; |
48 | $_REQUEST['entityID'] = $batch['id']; |
73416ad0 |
49 | $_REQUEST['return'] = TRUE; |
50 | $json = CRM_Financial_Page_AJAX::getFinancialTransactionsList(); |
31ea45d9 |
51 | $json = str_replace(rtrim(CIVICRM_UF_BASEURL, '/'), 'http://FIX ME', $json); |
478c39cf |
52 | $this->assertEquals($json, '{"sEcho": 1, "iTotalRecords": 1, "iTotalDisplayRecords": 1, "aaData": [ ["","<a href=\"/index.php?q=civicrm/profile/view&reset=1&gid=7&id=3&snippet=4\" class=\"crm-summary-link\"><div' |
872a35c1 |
53 | . ' 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",' |
478c39cf |
54 | . '"Credit Card","Completed","Donation","<span><a href=\"http://FIX ME/index.php?q=civicrm/contact/view/contribution&reset=1&id=1&cid=3&action=view&context=contribution&' |
55 | . 'selectedChild=contribute\" class=\"action-item crm-hover-button\" title=\'View Contribution\' >View</a></span>"]] }'); |
56 | } |
57 | |
58 | } |