[NFC] Minor margin tidy up
authoreileen <emcnaughton@wikimedia.org>
Sat, 21 Nov 2020 17:31:26 +0000 (06:31 +1300)
committereileen <emcnaughton@wikimedia.org>
Sat, 21 Nov 2020 17:36:39 +0000 (06:36 +1300)
Just fixes all the things that get marked as 'not best practice' in the IDE

ext/contributioncancelactions/tests/phpunit/CancelTest.php

index 3e850a5428af9ce83fa7118b05265a6087d890c8..946b3484d4511b90477c8d5d0da3b01aada95ae7 100644 (file)
@@ -1,5 +1,7 @@
 <?php
 
+use Civi\Test\Api3TestTrait;
+use Civi\Test\CiviEnvBuilder;
 use Civi\Test\HeadlessInterface;
 use Civi\Test\HookInterface;
 use Civi\Test\TransactionalInterface;
@@ -10,6 +12,7 @@ use Civi\Api4\Relationship;
 use Civi\Api4\Event;
 use Civi\Api4\PriceField;
 use Civi\Api4\Participant;
+use PHPUnit\Framework\TestCase;
 
 /**
  * FIXME - Add test description.
@@ -25,9 +28,9 @@ use Civi\Api4\Participant;
  *
  * @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.
@@ -37,8 +40,8 @@ class CancelTest extends \PHPUnit\Framework\TestCase implements HeadlessInterfac
   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.
@@ -47,9 +50,10 @@ class CancelTest extends \PHPUnit\Framework\TestCase implements HeadlessInterfac
    * 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()
@@ -64,7 +68,7 @@ class CancelTest extends \PHPUnit\Framework\TestCase implements HeadlessInterfac
    * @throws \CRM_Core_Exception
    * @throws \Civi\API\Exception\UnauthorizedException
    */
-  public function testPaypalProCancel() {
+  public function testPaypalProCancel(): void {
     $this->createContact();
     $this->createMembershipType();
     Relationship::create()->setValues([
@@ -97,11 +101,9 @@ class CancelTest extends \PHPUnit\Framework\TestCase implements HeadlessInterfac
   /**
    * 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',
@@ -178,7 +180,7 @@ class CancelTest extends \PHPUnit\Framework\TestCase implements HeadlessInterfac
    * @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(),
@@ -215,9 +217,9 @@ class CancelTest extends \PHPUnit\Framework\TestCase implements HeadlessInterfac
    * 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([
@@ -241,7 +243,7 @@ class CancelTest extends \PHPUnit\Framework\TestCase implements HeadlessInterfac
    * @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]);
@@ -259,7 +261,7 @@ class CancelTest extends \PHPUnit\Framework\TestCase implements HeadlessInterfac
    * @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'];
@@ -281,7 +283,7 @@ class CancelTest extends \PHPUnit\Framework\TestCase implements HeadlessInterfac
    * @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],