Update XML files for membership fields to support date picker conversion
[civicrm-core.git] / tests / phpunit / CRM / Member / Selector / SearchTest.php
1 <?php
2 /*
3 +--------------------------------------------------------------------+
4 | CiviCRM version 5 |
5 +--------------------------------------------------------------------+
6 | Copyright CiviCRM LLC (c) 2004-2019 |
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 */
27
28 /**
29 * Class CRM_Member_BAO_MembershipTest
30 *
31 * @group headless
32 */
33 class CRM_Member_Selector_SearchTest extends CiviUnitTestCase {
34
35 /**
36 * Test results from getRows.
37 *
38 * @throws \CRM_Core_Exception
39 */
40 public function testSelectorGetRows() {
41 $this->_contactID = $this->individualCreate();
42 $this->_invoiceID = 1234;
43 $this->_contributionPageID = NULL;
44 $this->_paymentProcessorID = $this->paymentProcessorCreate();
45 $this->setupMembershipRecurringPaymentProcessorTransaction();
46 $membership = $this->callAPISuccessGetSingle('Membership', ['contact_id' => $this->_contactID]);
47 $membershipID = $membership['id'];
48 $params = [];
49 $selector = new CRM_Member_Selector_Search($params);
50 $rows = $selector->getRows(CRM_Core_Permission::VIEW, 0, 25, NULL);
51 $this->assertEquals([
52 'contact_id' => $this->_contactID,
53 'membership_id' => $membershipID,
54 'contact_type' => '<a href="/index.php?q=civicrm/profile/view&amp;reset=1&amp;gid=7&amp;id=' . $this->_contactID . '&amp;snippet=4" class="crm-summary-link"><div class="icon crm-icon Individual-icon"></div></a>',
55 'sort_name' => 'Anderson, Anthony',
56 'membership_type' => 'General',
57 'membership_join_date' => date('Y-m-d'),
58 'membership_start_date' => date('Y-m-d'),
59 'membership_end_date' => $membership['end_date'],
60 'membership_source' => 'Payment',
61 'member_is_test' => '0',
62 'owner_membership_id' => NULL,
63 'membership_status' => 'New',
64 'member_campaign_id' => NULL,
65 'campaign' => NULL,
66 'campaign_id' => NULL,
67 'checkbox' => 'mark_x_1',
68 'action' => '<span><a href="/index.php?q=civicrm/contact/view/membership&amp;reset=1&amp;id=1&amp;cid=' . $this->_contactID . '&amp;action=view&amp;context=search&amp;selectedChild=member&amp;compContext=membership" class="action-item crm-hover-button" title=\'View Membership\' >View</a><a href="/index.php?q=civicrm/contact/view/membership&amp;reset=1&amp;action=update&amp;id=' . $membershipID . '&amp;cid=' . $this->_contactID . '&amp;context=search&amp;compContext=membership" class="action-item crm-hover-button" title=\'Edit Membership\' >Edit</a></span><span class=\'btn-slide crm-hover-button\'>Renew...<ul class=\'panel\'><li><a href="/index.php?q=civicrm/contact/view/membership&amp;reset=1&amp;action=delete&amp;id=' . $membershipID . '&amp;cid=' . $this->_contactID . '&amp;context=search&amp;compContext=membership" class="action-item crm-hover-button small-popup" title=\'Delete Membership\' >Delete</a></li><li><a href="/index.php?q=civicrm/contact/view/membership&amp;reset=1&amp;action=renew&amp;id=' . $membershipID . '&amp;cid=' . $this->_contactID . '&amp;context=search&amp;compContext=membership" class="action-item crm-hover-button" title=\'Renew Membership\' >Renew</a></li><li><a href="/index.php?q=civicrm/contribute/unsubscribe&amp;reset=1&amp;mid=' . $membershipID . '&amp;context=search&amp;compContext=membership" class="action-item crm-hover-button" title=\'Cancel Auto Renew Subscription\' >Cancel Auto-renewal</a></li></ul></span>',
69 'auto_renew' => 1,
70 ], $rows[0]);
71 $this->assertCount(1, $rows);
72 }
73
74 }