* and redirect stdin to a temporary file
*/
public function setUp() {
+ $this->_apiversion = 3;
// Connect to the database
parent::setUp();
- $this->quickCleanup(
- array(
- 'civicrm_address_format',
- 'civicrm_currency',
- 'civicrm_domain',
- 'civicrm_file',
- 'civicrm_financial_account',
- 'civicrm_financial_trxn',
- 'civicrm_job',
- 'civicrm_job_log',
- 'civicrm_location_type',
- 'civicrm_mail_settings',
- 'civicrm_mapping',
- 'civicrm_navigation',
- 'civicrm_option_group',
- 'civicrm_payment_processor',
- 'civicrm_payment_processor_type',
- 'civicrm_preferences_date',
- 'civicrm_worldregion',
- 'civicrm_component',
- 'civicrm_persistent',
- 'civicrm_prevnext_cache',
- 'civicrm_action_mapping',
- 'civicrm_acl',
- 'civicrm_acl_entity_role',
- 'civicrm_contact',
- 'civicrm_acl_contact_cache',
- 'civicrm_relationship_type',
- 'civicrm_saved_search',
- 'civicrm_mailing_component',
- 'civicrm_mailing_bounce_type',
- 'civicrm_mailing_bounce_pattern',
- 'civicrm_financial_type',
- 'civicrm_premiums',
- 'civicrm_product',
- 'civicrm_premiums_product',
- 'civicrm_sms_provider',
- 'civicrm_membership_status',
- 'civicrm_campaign',
- 'civicrm_campaign_group',
- 'civicrm_survey',
- 'civicrm_participant_status_type',
- 'civicrm_event_carts',
- 'civicrm_dedupe_rule_group',
- 'civicrm_dedupe_rule',
- 'civicrm_dedupe_exception',
- 'civicrm_case',
- 'civicrm_case_contact',
- 'civicrm_grant',
- 'civicrm_tell_friend',
- 'civicrm_pledge_block',
- 'civicrm_queue_item',
- 'civicrm_report_instance',
- 'civicrm_price_set',
- 'civicrm_price_set_entity',
- 'civicrm_pcp',
- 'civicrm_batch',
- 'civicrm_cache',
- 'civicrm_country',
- 'civicrm_custom_group',
- 'civicrm_custom_field',
- 'civicrm_dashboard',
- 'civicrm_email',
- 'civicrm_entity_batch',
- 'civicrm_entity_file',
- 'civicrm_entity_financial_trxn',
- 'civicrm_im',
- 'civicrm_log',
- 'civicrm_mapping_field',
- 'civicrm_menu',
- 'civicrm_note',
- 'civicrm_option_value',
- 'civicrm_phone',
- 'civicrm_state_province',
- 'civicrm_tag',
- 'civicrm_uf_match',
- 'civicrm_timezone',
- 'civicrm_openid',
- 'civicrm_discount',
- 'civicrm_website',
- 'civicrm_setting',
- 'civicrm_acl_cache',
- 'civicrm_dashboard_contact',
- 'civicrm_group',
- 'civicrm_subscription_history',
- 'civicrm_group_contact_cache',
- 'civicrm_group_nesting',
- 'civicrm_group_organization',
- 'civicrm_relationship',
- 'civicrm_mailing_event_subscribe',
- 'civicrm_mailing_event_confirm',
- 'civicrm_contribution_recur',
- 'civicrm_contribution_page',
- 'civicrm_contribution_widget',
- 'civicrm_activity',
- 'civicrm_activity_contact',
- 'civicrm_case_activity',
- 'civicrm_pledge',
- 'civicrm_price_field',
- 'civicrm_county',
- 'civicrm_entity_tag',
- 'civicrm_msg_template',
- 'civicrm_uf_group',
- 'civicrm_uf_field',
- 'civicrm_uf_join',
- 'civicrm_action_schedule',
- 'civicrm_action_log',
- 'civicrm_mailing',
- 'civicrm_mailing_group',
- 'civicrm_mailing_trackable_url',
- 'civicrm_mailing_job',
- 'civicrm_mailing_recipients',
- 'civicrm_mailing_spool',
- 'civicrm_mailing_event_queue',
- 'civicrm_mailing_event_bounce',
- 'civicrm_mailing_event_delivered',
- 'civicrm_mailing_event_forward',
- 'civicrm_mailing_event_opened',
- 'civicrm_mailing_event_reply',
- 'civicrm_mailing_event_trackable_url_open',
- 'civicrm_mailing_event_unsubscribe',
- 'civicrm_membership_type',
- 'civicrm_membership',
- 'civicrm_membership_block',
- 'civicrm_membership_log',
- 'civicrm_price_field_value',
- 'civicrm_line_item',
- 'civicrm_pcp_block',
- 'civicrm_address',
- 'civicrm_loc_block',
- 'civicrm_group_contact',
- 'civicrm_contribution',
- 'civicrm_contribution_product',
- 'civicrm_contribution_soft',
- 'civicrm_membership_payment',
- 'civicrm_event',
- 'civicrm_participant',
- 'civicrm_participant_payment',
- 'civicrm_events_in_carts',
- 'civicrm_pledge_payment',
- )
- );
-
+ $this->_individualId = $this->individualCreate();
+ $this->_paymentProcessorID = $this->processorCreate();
// Insert test data
$op = new PHPUnit_Extensions_Database_Operation_Insert();
$op->execute($this->_dbconn,
);
}
+ /**
+ * Clean up after each test.
+ */
+ public function tearDown() {
+ $this->quickCleanUpFinancialEntities();
+ $this->quickCleanup(
+ array(
+ 'civicrm_relationship',
+ 'civicrm_membership_type',
+ 'civicrm_membership',
+ )
+ );
+ $this->callAPISuccess('contact', 'delete', array('id' => 17, 'skip_undelete' => TRUE));
+ $this->callAPISuccess('contact', 'delete', array('id' => 23, 'skip_undelete' => TRUE));
+ $this->callAPISuccess('relationship_type', 'delete', array('id' => 20));
+ }
+
/**
* Test CRM_Member_Form_Membership::buildQuickForm()
*/
$files = array();
$obj = new CRM_Member_Form_Membership();
$rc = $obj->formRule($params, $files, $obj);
- $this->assertType('array', $rc,
- 'In line ' . __LINE__
- );
- $this->assertTrue(array_key_exists('membership_type_id', $rc),
- 'In line ' . __LINE__
- );
+ $this->assertType('array', $rc);
+ $this->assertTrue(array_key_exists('membership_type_id', $rc));
$params['membership_type_id'] = array(1 => 3);
$rc = $obj->formRule($params, $files, $obj);
- $this->assertType('array', $rc,
- 'In line ' . __LINE__
- );
- $this->assertTrue(array_key_exists('join_date', $rc),
- 'In line ' . __LINE__
- );
+ $this->assertType('array', $rc);
+ $this->assertTrue(array_key_exists('join_date', $rc));
}
/**
- * Test CRM_Member_Form_Membership::formRule() with a parameter
- * that has an start date before the join date and a rolling
- * membership type
+ * Test that form rule fails if start date is before join date.
+ *
+ * Test CRM_Member_Form_Membership::formRule() with a parameter
+ * that has an start date before the join date and a rolling
+ * membership type.
*/
public function testFormRuleRollingEarlyStart() {
$unixNow = time();
'join_date' => $ymdNow,
'start_date' => $ymdYesterday,
'end_date' => '',
- 'membership_type_id' => array('23', '3'),
+ 'membership_type_id' => array('23', '15'),
);
$files = array();
$obj = new CRM_Member_Form_Membership();
$rc = call_user_func(array('CRM_Member_Form_Membership', 'formRule'),
$params, $files, $obj
);
- $this->assertType('array', $rc,
- 'In line ' . __LINE__
- );
- $this->assertTrue(array_key_exists('start_date', $rc),
- 'In line ' . __LINE__
- );
+ $this->assertType('array', $rc);
+ $this->assertTrue(array_key_exists('start_date', $rc));
}
/**
'join_date' => $ymdNow,
'start_date' => $ymdNow,
'end_date' => $ymdYesterday,
- 'membership_type_id' => array('23', '3'),
+ 'membership_type_id' => array('23', '15'),
);
$files = array();
$obj = new CRM_Member_Form_Membership();
'join_date' => $ymdNow,
'start_date' => '',
'end_date' => $ymdYearFromNow,
- 'membership_type_id' => array('23', '3'),
+ 'membership_type_id' => array('23', '15'),
);
$files = array();
$obj = new CRM_Member_Form_Membership();
'end_date' => date('m/d/Y',
$unixYearFromNow
),
- 'membership_type_id' => array('23', '13'),
+ 'membership_type_id' => array('23', '25'),
);
$files = array();
$obj = new CRM_Member_Form_Membership();
$unixYearFromNow = $unixNow + (365 * 24 * 60 * 60);
$params = array(
'join_date' => date('m/d/Y', $unixNow),
- 'membership_type_id' => array('23', '13'),
+ 'membership_type_id' => array('23', '25'),
'is_override' => TRUE,
);
$files = array();
'join_date' => date('m/d/Y', $unix1MFmNow),
'start_date' => '',
'end_date' => '',
- 'membership_type_id' => array('23', '3'),
+ 'membership_type_id' => array('23', '15'),
);
$files = array();
$obj = new CRM_Member_Form_Membership();
'join_date' => date('m/d/Y', $unixNow),
'start_date' => '',
'end_date' => '',
- 'membership_type_id' => array('23', '3'),
+ 'membership_type_id' => array('23', '15'),
);
$files = array();
$obj = new CRM_Member_Form_Membership();
'join_date' => date('m/d/Y', $unix1MAgo),
'start_date' => '',
'end_date' => '',
- 'membership_type_id' => array('23', '3'),
+ 'membership_type_id' => array('23', '15'),
);
$files = array();
$obj = new CRM_Member_Form_Membership();
'join_date' => date('m/d/Y', $unix6MAgo),
'start_date' => '',
'end_date' => '',
- 'membership_type_id' => array('23', '3'),
+ 'membership_type_id' => array('23', '15'),
);
$files = array();
$obj = new CRM_Member_Form_Membership();
'join_date' => date('m/d/Y', $unix1YAgo),
'start_date' => '',
'end_date' => '',
- 'membership_type_id' => array('23', '3'),
+ 'membership_type_id' => array('23', '15'),
);
$files = array();
$obj = new CRM_Member_Form_Membership();
'join_date' => date('m/d/Y', $unix2YAgo),
'start_date' => '',
'end_date' => '',
- 'membership_type_id' => array('23', '3'),
+ 'membership_type_id' => array('23', '15'),
);
$files = array();
$obj = new CRM_Member_Form_Membership();
$rc = $obj->formRule($params, $files, $obj);
// Should have found Current membership status
- $this->assertTrue($rc, 'In line ' . __LINE__);
+ $this->assertTrue($rc);
}
}