Merge pull request #7047 from johanv/CRM-17430-dont_change_domain_version_1st_attempt
[civicrm-core.git] / tests / phpunit / CiviTest / Membership.php
CommitLineData
6a488035
TO
1<?php
2require_once 'Contact.php';
aba1cd8b
EM
3
4/**
5 * Class Membership
6 */
6a488035
TO
7class 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',
b8644ae3 34 'member_of_contact_id' => $orgId,
6a488035
TO
35 );
36
37 $membershipType = CRM_Member_BAO_MembershipType::add($params, $ids);
38 $membershipType->orgnizationID = $orgId;
39 return $membershipType;
40 }
41
42 /**
eceb18cc 43 * Helper function to create membership block for contribution page.
1e1fdcf6
EM
44 * @param $membershipType
45 * @param $contributionPageId
46 * @return $this
6a488035 47 */
00be9182 48 public function createMembershipBlock($membershipType, $contributionPageId) {
6a488035
TO
49 $param = array(
50 'is_active' => 1,
51 'new_title' => 'Membership Fees',
52 'new_text' => 'text for membership fees',
53 'renewal_title' => 'Membership Renewal title',
54 'renewal_text' => 'Membership renewal text',
55 'is_required' => 1,
56 'display_min_fee' => 1,
57 'membership_type' => array(
58 $membershipType => 1,
59 ),
60 'membership_type_default' => NULL,
61 'membership_types' => $membershipType,
62 'is_separate_payment' => 0,
63 'entity_table' => 'civicrm_contribution_page',
64 'entity_id' => $contributionPageId,
65 );
66
67 $dao = new CRM_Member_DAO_MembershipBlock();
68 $dao->copyValues($param);
69 return $dao->save();
70 }
71
72 /**
eceb18cc 73 * Helper function to delete the membership block.
1e1fdcf6 74 * @param $blcokId
6a488035 75 */
00be9182 76 public function deleteMembershipBlock($blcokId) {
6a488035
TO
77 $dao = new CRM_Member_DAO_MembershipBlock();
78 $dao->id = $blcokId;
79 if ($dao->find(TRUE)) {
80 $dao->delete();
81 }
82 }
96025800 83
6a488035 84}