--- /dev/null
+<?php
+
+/*
+ +--------------------------------------------------------------------+
+ | Copyright CiviCRM LLC. All rights reserved. |
+ | |
+ | This work is published under the GNU AGPLv3 license with some |
+ | permitted exceptions and without any warranty. For full license |
+ | and copyright information, see https://civicrm.org/licensing |
+ +--------------------------------------------------------------------+
+ */
+
+/**
+ *
+ * @package CRM
+ * @copyright CiviCRM LLC https://civicrm.org/licensing
+ */
+
+namespace Civi\Api4;
+
+/**
+ * PCP Block entity.
+ *
+ * @package Civi\Api4
+ */
+class PcpBlock extends Generic\DAOEntity {
+
+}
* @throws \CiviCRM_API3_Exception
* @throws \Civi\Payment\Exception\PaymentProcessorException
*/
- public function testSubmitWithPCP() {
+ public function testSubmitWithPCP(): void {
+ $mut = new CiviMailUtils($this, TRUE);
+ $mut->clearMessages();
$params = $this->pcpParams();
$pcpID = $this->createPCPBlock($params);
$form = new CRM_Contribute_Form_Contribution();
], CRM_Core_Action::ADD);
$softCredit = $this->callAPISuccessGetSingle('ContributionSoft', []);
$this->assertEquals('Dobby', $softCredit['pcp_roll_nickname']);
+ $mut->checkMailLog(['Personal Campaign Page Owner Notification']);
}
/**
+--------------------------------------------------------------------+
*/
+use Civi\Api4\Email;
+
/**
* Trait CRMTraits_PCP_PCPTestTrait
*
$supporterProfile = CRM_Core_DAO::createTestObject('CRM_Core_DAO_UFGroup');
$supporterProfileId = $supporterProfile->id;
- $params = [
+ return [
'entity_table' => 'civicrm_contribution_page',
'entity_id' => $contribPageId,
'supporter_profile_id' => $supporterProfileId,
'tellfriend_limit' => 1,
'link_text' => 'Create your own PCP',
'is_active' => 1,
+ 'owner_notify_id:name' => 'owner_chooses',
];
-
- return $params;
}
/**
*
* Create the necessary initial objects for a pcp page, then return the
* params needed to create the pcp page.
+ *
+ * @throw API_Exception
*/
public function pcpParams() {
$contact = CRM_Core_DAO::createTestObject('CRM_Contact_DAO_Contact');
$contactId = $contact->id;
+ Email::create()->setValues(['email' => 'dobby@example.org', 'contact_id' => $contactId])->execute();
$contribPage = CRM_Core_DAO::createTestObject('CRM_Contribute_DAO_ContributionPage');
$contribPageId = $contribPage->id;
- $params = [
+ return [
'contact_id' => $contactId,
'status_id' => '1',
'title' => 'My PCP',
'page_text' => 'You better give more.',
'donate_link_text' => 'Donate Now',
'page_id' => $contribPageId,
+ 'is_notify' => TRUE,
'is_thermometer' => 1,
'is_honor_roll' => 1,
'goal_amount' => 10000.00,
'is_active' => 1,
];
-
- return $params;
}
/**
*/
protected function createPCPBlock(array $params):int {
$blockParams = $this->pcpBlockParams();
- $pcpBlock = CRM_PCP_BAO_PCPBlock::create($blockParams);
-
$params = array_merge($this->pcpParams(), $params);
- $params['pcp_block_id'] = $pcpBlock->id;
+ $params['pcp_block_id'] = \Civi\Api4\PcpBlock::create()->setValues($blockParams)->execute()->first()['id'];
$pcp = CRM_PCP_BAO_PCP::create($params);
return (int) $pcp->id;
}
/**
- * @param $strings
+ * @param array $strings
* @param $absentStrings
* @param $prefix
* @param $mail
* @return mixed
*/
- public function checkMailForStrings($strings, $absentStrings, $prefix, $mail) {
+ public function checkMailForStrings(array $strings, $absentStrings = [], $prefix = '', $mail) {
foreach ($strings as $string) {
$this->_ut->assertContains($string, $mail, "$string . not found in $mail $prefix");
}