Skip to content

Commit

Permalink
[REF][PHP8.2] Get rid of dynamic properties in CRM_Core_Payment_Proce…
Browse files Browse the repository at this point in the history
…ssorFormTest
  • Loading branch information
braders committed Mar 17, 2023
1 parent 3ab6b8f commit 76f7cb9
Showing 1 changed file with 45 additions and 15 deletions.
60 changes: 45 additions & 15 deletions tests/phpunit/CRM/Core/Payment/ProcessorFormTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,52 +15,82 @@
*/
class CRM_Core_Payment_ProcessorFormTest extends CiviUnitTestCase {

/**
* @var array
*/
protected $standardProfile;

/**
* @var array
*/
protected $billingProfile;

/**
* @var int
*/
protected $standardProcessorTypeID;

/**
* @var int
*/
protected $customProcessorTypeID;

/**
* @var int
*/
protected $standardProcessorID;

/**
* @var int
*/
protected $customProcessorID;

public function setUp(): void {
parent::setUp();

$this->standardProfile = $this->createStandardBillingProfile();
$this->customProfile = $this->createCustomBillingProfile();
$this->billingProfile = $this->createCustomBillingProfile();

$this->standardProcessorType = $this->paymentProcessorTypeCreate([
$this->standardProcessorTypeID = $this->paymentProcessorTypeCreate([
'class_name' => 'PaymentProcessorWithStandardBillingRequirements',
'name' => 'StandardBillingType',
]);

$this->customProcessorType = $this->paymentProcessorTypeCreate([
$this->customProcessorTypeID = $this->paymentProcessorTypeCreate([
'class_name' => 'PaymentProcessorWithCustomBillingRequirements',
'name' => 'CustomBillingType',
]);

$this->standardProcessor = $this->paymentProcessorCreate([
$this->standardProcessorID = $this->paymentProcessorCreate([
'name' => 'StandardBilling',
'class_name' => 'PaymentProcessorWithStandardBillingRequirements',
'payment_processor_type_id' => $this->standardProcessorType,
'payment_processor_type_id' => $this->standardProcessorTypeID,
'is_test' => 0,
]);

$this->customProcessor = $this->paymentProcessorCreate([
$this->customProcessorID = $this->paymentProcessorCreate([
'name' => 'CustomBilling',
'class_name' => 'PaymentProcessorWithCustomBillingRequirements',
'payment_processor_type_id' => $this->customProcessorType,
'payment_processor_type_id' => $this->customProcessorTypeID,
'is_test' => 0,
]);
}

public function tearDown(): void {
$this->callAPISuccess('PaymentProcessor', 'delete', [
'id' => $this->standardProcessor,
'id' => $this->standardProcessorID,
]);

$this->callAPISuccess('PaymentProcessor', 'delete', [
'id' => $this->customProcessor,
'id' => $this->customProcessorID,
]);

$this->callAPISuccess('PaymentProcessorType', 'delete', [
'id' => $this->standardProcessorType,
'id' => $this->standardProcessorTypeID,
]);

$this->callAPISuccess('PaymentProcessorType', 'delete', [
'id' => $this->customProcessorType,
'id' => $this->customProcessorTypeID,
]);

$this->quickCleanUpFinancialEntities();
Expand All @@ -69,15 +99,15 @@ public function tearDown(): void {
parent::tearDown();
}

public function createStandardBillingProfile() {
public function createStandardBillingProfile(): array {
return $this->createTestableBillingProfile('standard', TRUE);
}

public function createCustomBillingProfile() {
public function createCustomBillingProfile(): array {
return $this->createTestableBillingProfile('custom', FALSE);
}

public function createTestableBillingProfile($name, $withState) {
public function createTestableBillingProfile($name, $withState): array {
$billingId = CRM_Core_BAO_LocationType::getBilling();

$profile = $this->callAPISuccess('UFGroup', 'create', [
Expand Down Expand Up @@ -143,7 +173,7 @@ public function createTestableBillingProfile($name, $withState) {
* indicates whether the billing block can be hidden, or not.
*/
public function checkPaymentProcessorWithProfile($processorClass, $case) {
$whichProcessor = $case . "Processor";
$whichProcessor = $case . "ProcessorId";
$whichProfile = $case . "Profile";

$processor = new $processorClass();
Expand Down

0 comments on commit 76f7cb9

Please sign in to comment.