Fix PCP getPcpDashboardInfo to be tested & use sensible functions
[civicrm-core.git] / tests / phpunit / CRMTraits / PCP / PCPTestTrait.php
1 <?php
2 /*
3 +--------------------------------------------------------------------+
4 | Copyright CiviCRM LLC. All rights reserved. |
5 | |
6 | This work is published under the GNU AGPLv3 license with some |
7 | permitted exceptions and without any warranty. For full license |
8 | and copyright information, see https://civicrm.org/licensing |
9 +--------------------------------------------------------------------+
10 */
11
12 /**
13 * Trait CRMTraits_PCP_PCPTestTrait
14 *
15 * Traits for testing PCP pages.
16 */
17 trait CRMTraits_PCP_PCPTestTrait {
18
19 /**
20 * Build and return pcpBlock params.
21 *
22 * Create the necessary initial objects for a pcpBlock, then return the
23 * params needed to create the pcpBlock.
24 *
25 */
26 public function pcpBlockParams() {
27 $contribPage = CRM_Core_DAO::createTestObject('CRM_Contribute_DAO_ContributionPage');
28 $contribPageId = $contribPage->id;
29 $supporterProfile = CRM_Core_DAO::createTestObject('CRM_Core_DAO_UFGroup');
30 $supporterProfileId = $supporterProfile->id;
31
32 $params = [
33 'entity_table' => 'civicrm_contribution_page',
34 'entity_id' => $contribPageId,
35 'supporter_profile_id' => $supporterProfileId,
36 'target_entity_id' => 1,
37 'is_approval_needed' => 1,
38 'is_tellfriend_enabled' => 1,
39 'tellfriend_limit' => 1,
40 'link_text' => 'Create your own PCP',
41 'is_active' => 1,
42 ];
43
44 return $params;
45 }
46
47 /**
48 * Build and return pcp params.
49 *
50 * Create the necessary initial objects for a pcp page, then return the
51 * params needed to create the pcp page.
52 */
53 public function pcpParams() {
54 $contact = CRM_Core_DAO::createTestObject('CRM_Contact_DAO_Contact');
55 $contactId = $contact->id;
56 $contribPage = CRM_Core_DAO::createTestObject('CRM_Contribute_DAO_ContributionPage');
57 $contribPageId = $contribPage->id;
58
59 $params = [
60 'contact_id' => $contactId,
61 'status_id' => '1',
62 'title' => 'My PCP',
63 'intro_text' => 'Hey you, contribute now!',
64 'page_text' => 'You better give more.',
65 'donate_link_text' => 'Donate Now',
66 'page_id' => $contribPageId,
67 'is_thermometer' => 1,
68 'is_honor_roll' => 1,
69 'goal_amount' => 10000.00,
70 'is_active' => 1,
71 ];
72
73 return $params;
74 }
75
76 }