Ejemplo n.º 1
0
 /**
  * CRM-18000 - Test start_date, end_date after renewal
  */
 public function testMembershipRenewalDates()
 {
     $form = new CRM_Batch_Form_Entry();
     foreach (array($this->_contactID, $this->_contactID2) as $contactID) {
         $membershipParams = array('membership_type_id' => $this->_membershipTypeID2, 'contact_id' => $contactID, 'start_date' => "01/01/2015", 'join_date' => "01/01/2010", 'end_date' => "12/31/2015");
         $this->contactMembershipCreate($membershipParams);
     }
     $params = $this->getMembershipData();
     //ensure membership renewal
     $params['member_option'] = array(1 => 2, 2 => 2);
     $params['field'][1]['membership_type'] = array(0 => $this->_orgContactID2, 1 => $this->_membershipTypeID2);
     $params['field'][1]['receive_date'] = date('Y-m-d');
     // explicitly specify start and end dates
     $params['field'][2]['membership_type'] = array(0 => $this->_orgContactID2, 1 => $this->_membershipTypeID2);
     $params['field'][2]['membership_start_date'] = "04/01/2016";
     $params['field'][2]['membership_end_date'] = "03/31/2017";
     $params['field'][2]['receive_date'] = "04/01/2016";
     $this->assertTrue($form->testProcessMembership($params));
     $result = $this->callAPISuccess('membership', 'get', array());
     // renewal dates should be from current if start_date and end_date is passed as NULL
     $this->assertEquals(date('Y-m-d'), $result['values'][1]['start_date']);
     $endDate = date("Y-m-d", strtotime(date("Y-m-d") . " +1 year -1 day"));
     $this->assertEquals($endDate, $result['values'][1]['end_date']);
     // verify if the modified dates asserts with the dates passed above
     $this->assertEquals('2016-04-01', $result['values'][2]['start_date']);
     $this->assertEquals('2017-03-31', $result['values'][2]['end_date']);
 }
Ejemplo n.º 2
0
 /**
  *  Test Import
  */
 function testProcessMembership()
 {
     $form = new CRM_Batch_Form_Entry();
     $params = $this->getMembershipData();
     $this->assertTrue($form->testProcessMembership($params));
     $result = $this->callAPISuccess('membership', 'get', array());
     $this->assertEquals(3, $result['count']);
     //check start dates #1 should default to 1 Jan this year, #2 should be as entered
     $this->assertEquals(date('Y-m-d', strtotime('first day of January 2013')), $result['values'][1]['start_date']);
     $this->assertEquals('2013-02-03', $result['values'][2]['start_date']);
     //check start dates #1 should default to 1 Jan this year, #2 should be as entered
     $this->assertEquals(date('Y-m-d', strtotime('last day of December 2013')), $result['values'][1]['end_date']);
     $this->assertEquals(date('Y-m-d', strtotime('last day of December 2013')), $result['values'][2]['end_date']);
     $this->assertEquals('2013-12-01', $result['values'][3]['end_date']);
     //check start dates #1 should default to 1 Jan this year, #2 should be as entered
     $this->assertEquals(date('Y-m-d', strtotime('07/22/2013')), $result['values'][1]['join_date']);
     $this->assertEquals(date('Y-m-d', strtotime('07/03/2013')), $result['values'][2]['join_date']);
     $this->assertEquals(date('Y-m-d', strtotime('now')), $result['values'][3]['join_date']);
 }
Ejemplo n.º 3
0
 /**
  *  Test Import.
  */
 public function testProcessMembership()
 {
     $form = new CRM_Batch_Form_Entry();
     $params = $this->getMembershipData();
     $this->assertTrue($form->testProcessMembership($params));
     $result = $this->callAPISuccess('membership', 'get', array());
     $this->assertEquals(3, $result['count']);
     //check start dates #1 should default to 1 Jan this year, #2 should be as entered
     $this->assertEquals(date('Y-m-d', strtotime('first day of January 2013')), $result['values'][1]['start_date']);
     $this->assertEquals('2013-02-03', $result['values'][2]['start_date']);
     //check start dates #1 should default to 1 Jan this year, #2 should be as entered
     $this->assertEquals(date('Y-m-d', strtotime('last day of December 2013')), $result['values'][1]['end_date']);
     $this->assertEquals(date('Y-m-d', strtotime('last day of December 2013')), $result['values'][2]['end_date']);
     $this->assertEquals('2013-12-01', $result['values'][3]['end_date']);
     //check start dates #1 should default to 1 Jan this year, #2 should be as entered
     $this->assertEquals(date('Y-m-d', strtotime('07/22/2013')), $result['values'][1]['join_date']);
     $this->assertEquals(date('Y-m-d', strtotime('07/03/2013')), $result['values'][2]['join_date']);
     $this->assertEquals(date('Y-m-d', strtotime('now')), $result['values'][3]['join_date']);
     $result = $this->callAPISuccess('contribution', 'get', array('return' => 'total_amount'));
     $this->assertEquals(3, $result['count']);
     foreach ($result['values'] as $contribution) {
         $this->assertEquals($this->callAPISuccess('line_item', 'getvalue', array('contribution_id' => $contribution['id'], 'return' => 'line_total')), $contribution['total_amount']);
     }
 }