Commit | Line | Data |
---|---|---|
9a42dcc8 ML |
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 | * Test ContributionPage translation features. | |
14 | * | |
15 | * @group headless | |
16 | */ | |
17 | class CRM_Contribute_Form_ContributionPageTranslationTest extends CiviUnitTestCase { | |
18 | ||
19 | public function setUp() { | |
20 | parent::setUp(); | |
21 | $this->_financialTypeID = 1; | |
22 | $this->enableMultilingual(); | |
23 | CRM_Core_I18n_Schema::addLocale('fr_FR', 'en_US'); | |
24 | } | |
25 | ||
594a9328 | 26 | public function tearDown(): void { |
9a42dcc8 ML |
27 | global $dbLocale; |
28 | if ($dbLocale) { | |
29 | CRM_Core_I18n_Schema::makeSinglelingual('en_US'); | |
30 | } | |
31 | } | |
32 | ||
33 | /** | |
34 | * Create() method (create Contribution Page with Honor block) | |
35 | */ | |
36 | public function testCreateHonor() { | |
37 | CRM_Core_I18n::singleton()->setLocale('en_US'); | |
38 | ||
39 | $params = [ | |
40 | 'title' => 'Test Contribution Page', | |
41 | 'financial_type_id' => $this->_financialTypeID, | |
42 | 'is_for_organization' => 0, | |
43 | 'for_organization' => ' I am contributing on behalf of an organization', | |
44 | 'goal_amount' => '400', | |
45 | 'is_active' => 1, | |
46 | 'honor_block_is_active' => 1, | |
47 | 'honor_block_title' => 'In Honor Title EN', | |
48 | 'honor_block_text' => 'In Honor Text EN', | |
49 | // Honoree Individual | |
50 | 'honoree_profile' => 13, | |
51 | // In Honor Of | |
52 | 'soft_credit_types' => 1, | |
53 | 'start_date' => '20091022105900', | |
54 | 'start_date_time' => '10:59AM', | |
55 | 'end_date' => '19700101000000', | |
56 | 'end_date_time' => '', | |
57 | 'is_credit_card_only' => '', | |
58 | ]; | |
59 | ||
60 | $contributionpage = CRM_Contribute_BAO_ContributionPage::create($params); | |
61 | ||
62 | // The BAO does not save these | |
63 | $params['id'] = $contributionpage->id; | |
64 | $params['honor_block_title'] = 'In Honor Title EN'; | |
65 | $params['honor_block_text'] = 'In Honor Text EN'; | |
66 | ||
67 | $form = $this->getFormObject('CRM_Contribute_Form_ContributionPage_Settings', $params, 'Settings'); | |
68 | $form->postProcess(); | |
69 | ||
70 | // Now update the page with In Honor (soft credit) text in French | |
71 | CRM_Core_I18n::singleton()->setLocale('fr_FR'); | |
72 | ||
73 | $params['honor_block_title'] = 'In Honor Title FR'; | |
74 | $params['honor_block_text'] = 'In Honor Text FR'; | |
75 | ||
76 | $form = $this->getFormObject('CRM_Contribute_Form_ContributionPage_Settings', $params, 'Settings'); | |
77 | $form->postProcess(); | |
78 | ||
79 | $uf = $this->callAPISuccess('UFJoin', 'getsingle', [ | |
80 | 'entity_id' => $contributionpage->id, | |
81 | 'module' => 'soft_credit', | |
82 | ]); | |
83 | ||
84 | $json = json_decode($uf['module_data'], TRUE); | |
85 | ||
86 | $this->assertEquals('In Honor Title EN', $json['soft_credit']['en_US']['honor_block_title']); | |
87 | $this->assertEquals('In Honor Text EN', $json['soft_credit']['en_US']['honor_block_text']); | |
88 | $this->assertEquals('In Honor Title FR', $json['soft_credit']['fr_FR']['honor_block_title']); | |
89 | $this->assertEquals('In Honor Text FR', $json['soft_credit']['fr_FR']['honor_block_text']); | |
90 | ||
91 | $this->callAPISuccess('ContributionPage', 'delete', ['id' => $contributionpage->id]); | |
92 | } | |
93 | ||
94 | } |