Commit | Line | Data |
---|---|---|
6a488035 TO |
1 | <?php |
2 | require_once 'Contact.php'; | |
aba1cd8b EM |
3 | |
4 | /** | |
5 | * Class Membership | |
6 | */ | |
6a488035 TO |
7 | class Membership extends PHPUnit_Framework_Testcase { |
8 | /** | |
eceb18cc | 9 | * Helper function to create membership type. |
6a488035 | 10 | */ |
00be9182 | 11 | public function createMembershipType() { |
6a488035 TO |
12 | $orgId = Contact::createOrganisation(); |
13 | ||
14 | $ids = array('memberOfContact' => $orgId); | |
15 | ||
16 | $params = array( | |
17 | 'name' => 'Test Type', | |
18 | 'description' => 'test membership type', | |
19 | 'minimum_fee' => 111, | |
20 | 'duration_unit' => 'year', | |
21 | 'period_type' => 'rolling', | |
22 | 'duration_interval' => 1, | |
23 | 'member_org' => NULL, | |
24 | 'fixed_period_start_day' => NULL, | |
25 | 'fixed_period_rollover_day' => NULL, | |
26 | 'action' => 1, | |
27 | 'financial_type_id' => 1, | |
28 | 'relationship_type_id' => 4, | |
29 | 'visibility' => 'Public', | |
30 | 'weight' => 4, | |
31 | 'is_active' => 1, | |
32 | 'contact_check' => 1, | |
33 | 'relationship_direction' => 'a_b', | |
34 | ); | |
35 | ||
36 | $membershipType = CRM_Member_BAO_MembershipType::add($params, $ids); | |
37 | $membershipType->orgnizationID = $orgId; | |
38 | return $membershipType; | |
39 | } | |
40 | ||
41 | /** | |
eceb18cc | 42 | * Helper function to create membership block for contribution page. |
1e1fdcf6 EM |
43 | * @param $membershipType |
44 | * @param $contributionPageId | |
45 | * @return $this | |
6a488035 | 46 | */ |
00be9182 | 47 | public function createMembershipBlock($membershipType, $contributionPageId) { |
6a488035 TO |
48 | $param = array( |
49 | 'is_active' => 1, | |
50 | 'new_title' => 'Membership Fees', | |
51 | 'new_text' => 'text for membership fees', | |
52 | 'renewal_title' => 'Membership Renewal title', | |
53 | 'renewal_text' => 'Membership renewal text', | |
54 | 'is_required' => 1, | |
55 | 'display_min_fee' => 1, | |
56 | 'membership_type' => array( | |
57 | $membershipType => 1, | |
58 | ), | |
59 | 'membership_type_default' => NULL, | |
60 | 'membership_types' => $membershipType, | |
61 | 'is_separate_payment' => 0, | |
62 | 'entity_table' => 'civicrm_contribution_page', | |
63 | 'entity_id' => $contributionPageId, | |
64 | ); | |
65 | ||
66 | $dao = new CRM_Member_DAO_MembershipBlock(); | |
67 | $dao->copyValues($param); | |
68 | return $dao->save(); | |
69 | } | |
70 | ||
71 | /** | |
eceb18cc | 72 | * Helper function to delete the membership block. |
1e1fdcf6 | 73 | * @param $blcokId |
6a488035 | 74 | */ |
00be9182 | 75 | public function deleteMembershipBlock($blcokId) { |
6a488035 TO |
76 | $dao = new CRM_Member_DAO_MembershipBlock(); |
77 | $dao->id = $blcokId; | |
78 | if ($dao->find(TRUE)) { | |
79 | $dao->delete(); | |
80 | } | |
81 | } | |
96025800 | 82 | |
6a488035 | 83 | } |