|
| 1 | +<?php |
| 2 | + |
| 3 | +use Civi\Api4\Contact; |
| 4 | +use Civi\Test\HeadlessInterface; |
| 5 | +use Civi\Test\HookInterface; |
| 6 | +use Civi\Test\TransactionalInterface; |
| 7 | +use GuzzleHttp\Psr7\Response; |
| 8 | +use PHPUnit\Framework\TestCase; |
| 9 | +use Civi\Test\Api3TestTrait; |
| 10 | +use Civi\Api4\ContributionRecur; |
| 11 | +use Civi\Api4\Contribution; |
| 12 | + |
| 13 | +/** |
| 14 | + * Sage pay tests for one-off payment. |
| 15 | + * |
| 16 | + * @group headless |
| 17 | + */ |
| 18 | +class BillingFieldsTest extends TestCase implements HeadlessInterface, HookInterface, TransactionalInterface { |
| 19 | + use Api3TestTrait; |
| 20 | + use HttpClientTestTrait; |
| 21 | + |
| 22 | + /** |
| 23 | + * ID of payment processor created for test. |
| 24 | + * |
| 25 | + * @var int |
| 26 | + */ |
| 27 | + protected $paymentProcessorID; |
| 28 | + |
| 29 | + /** |
| 30 | + * @return \Civi\Test\CiviEnvBuilder |
| 31 | + * @throws \CRM_Extension_Exception_ParseException |
| 32 | + */ |
| 33 | + public function setUpHeadless(): \Civi\Test\CiviEnvBuilder { |
| 34 | + // Civi\Test has many helpers, like install(), uninstall(), sql(), and sqlFile(). |
| 35 | + // See: https://github.com/civicrm/org.civicrm.testapalooza/blob/master/civi-test.md |
| 36 | + return \Civi\Test::headless() |
| 37 | + ->installMe(__DIR__) |
| 38 | + ->apply(); |
| 39 | + } |
| 40 | + |
| 41 | + /** |
| 42 | + * Setup for test. |
| 43 | + * |
| 44 | + * @throws \API_Exception |
| 45 | + * @throws \CRM_Csore_Exception |
| 46 | + */ |
| 47 | + public function setUp():void { |
| 48 | + parent::setUp(); |
| 49 | + |
| 50 | + $paymentProcessorID = (int) $this->callAPISuccess('PaymentProcessor', 'create', [ |
| 51 | + 'payment_processor_type_id' => 'omnipay_SagePay_Server', |
| 52 | + 'user_name' => 'sagepay_user', |
| 53 | + 'is_test' => 1, |
| 54 | + 'sequential' => 1, |
| 55 | + ])['values'][0]['id']; |
| 56 | + |
| 57 | + $this->processor = $this->callAPISuccess('PaymentProcessor', 'getsingle', [ |
| 58 | + 'id' => $paymentProcessorID, |
| 59 | + ]); |
| 60 | + } |
| 61 | + |
| 62 | + public function testStateProvinceNotMandatoryInSagePay() { |
| 63 | + $processor = new CRM_Core_Payment_OmnipayMultiProcessor('live', $this->processor); |
| 64 | + $fields = $processor->getBillingAddressFields(5); |
| 65 | + $this->assertArrayNotHasKey('state_province', $fields); |
| 66 | + } |
| 67 | + |
| 68 | +} |
0 commit comments