<?php
+use Civi\Test\Api3TestTrait;
+use Civi\Test\CiviEnvBuilder;
use Civi\Test\HeadlessInterface;
use Civi\Test\HookInterface;
use Civi\Test\TransactionalInterface;
use Civi\Api4\Event;
use Civi\Api4\PriceField;
use Civi\Api4\Participant;
+use PHPUnit\Framework\TestCase;
/**
* FIXME - Add test description.
*
* @group headless
*/
-class CancelTest extends \PHPUnit\Framework\TestCase implements HeadlessInterface, HookInterface, TransactionalInterface {
+class CancelTest extends TestCase implements HeadlessInterface, HookInterface, TransactionalInterface {
- use \Civi\Test\Api3TestTrait;
+ use Api3TestTrait;
/**
* Created ids.
protected $ids = [];
/**
- * The setupHeadless function runs at the start of each test case, right before
- * the headless environment reboots.
+ * The setupHeadless function runs at the start of each test case, right
+ * before the headless environment reboots.
*
* It should perform any necessary steps required for putting the database
* in a consistent baseline -- such as loading schema and extensions.
* for managing this setup, and it includes optimizations to avoid redundant
* setup work.
*
+ * @throws \CRM_Extension_Exception_ParseException
* @see \Civi\Test
*/
- public function setUpHeadless() {
+ public function setUpHeadless(): CiviEnvBuilder {
// Civi\Test has many helpers, like install(), uninstall(), sql(), and sqlFile().
// See: https://docs.civicrm.org/dev/en/latest/testing/phpunit/#civitest
return \Civi\Test::headless()
* @throws \CRM_Core_Exception
* @throws \Civi\API\Exception\UnauthorizedException
*/
- public function testPaypalProCancel() {
+ public function testPaypalProCancel(): void {
$this->createContact();
$this->createMembershipType();
Relationship::create()->setValues([
/**
* Create an order with more than one membership.
*
- * @throws \API_Exception
* @throws \CRM_Core_Exception
- * @throws \Civi\API\Exception\UnauthorizedException
*/
- protected function createMembershipOrder() {
+ protected function createMembershipOrder(): void {
$priceFieldID = $this->callAPISuccessGetValue('price_field', [
'return' => 'id',
'label' => 'Membership Amount',
* @return int
* @throws \CRM_Core_Exception
*/
- public function createPaymentProcessor($params = []) {
+ public function createPaymentProcessor($params = []): int {
$params = array_merge([
'name' => 'demo',
'domain_id' => CRM_Core_Config::domainID(),
* Test that a cancel from paypal pro results in an order being cancelled.
*
* @throws \API_Exception
- * @throws \CRM_Core_Exception
+ * @throws \CRM_Core_Exception|\CiviCRM_API3_Exception
*/
- public function testPaypalStandardCancel() {
+ public function testPaypalStandardCancel(): void {
$this->createContact();
$orderID = $this->createEventOrder();
$ipn = new CRM_Core_Payment_PayPalIPN([
* @throws API_Exception
* @throws CRM_Core_Exception
*/
- public function testCancelOrderWithParticipant() {
+ public function testCancelOrderWithParticipant(): void {
$this->createContact();
$orderID = $this->createEventOrder();
$this->callAPISuccess('Order', 'cancel', ['contribution_id' => $orderID]);
* @throws CRM_Core_Exception
* @throws API_Exception
*/
- public function testCancelOrderWithPledge() {
+ public function testCancelOrderWithPledge(): void {
$this->createContact();
$pledgeID = (int) $this->callAPISuccess('Pledge', 'create', ['contact_id' => $this->ids['contact'][0], 'amount' => 4, 'installments' => 2, 'frequency_unit' => 'month', 'original_installment_amount' => 2, 'create_date' => 'now', 'financial_type_id' => 'Donation', 'start_date' => '+5 days'])['id'];
$orderID = (int) $this->callAPISuccess('Order', 'create', ['contact_id' => $this->ids['contact'][0], 'total_amount' => 2, 'financial_type_id' => 'Donation', 'api.Payment.create' => ['total_amount' => 2]])['id'];
* @throws API_Exception
* @throws CRM_Core_Exception
*/
- protected function createEventOrder() {
+ protected function createEventOrder(): int {
$this->ids['event'][0] = (int) Event::create()->setValues(['title' => 'Event', 'start_date' => 'tomorrow', 'event_type_id:name' => 'Workshop'])->execute()->first()['id'];
$order = $this->callAPISuccess('Order', 'create', [
'contact_id' => $this->ids['contact'][0],