Test fix - adapt tests to not use hard-coded payment_processor_type_id
authoreileenmcnaugton <eileen@fuzion.co.nz>
Thu, 22 Oct 2015 03:17:20 +0000 (16:17 +1300)
committereileenmcnaugton <eileen@fuzion.co.nz>
Thu, 22 Oct 2015 10:29:58 +0000 (23:29 +1300)
This type id has been changed in core & the tests are now failing - but since the
affected tests were excluded from CI it wasn't picked up at the time

tests/phpunit/CRM/Member/Form/MembershipRenewalTest.php
tests/phpunit/CRM/Member/Form/MembershipTest.php
tests/phpunit/CiviTest/CiviUnitTestCase.php
tests/phpunit/api/v3/ContributionRecurTest.php
tests/phpunit/api/v3/ContributionSoftTest.php
tests/phpunit/api/v3/ContributionTest.php
tests/phpunit/api/v3/ParticipantPaymentTest.php
tests/phpunit/api/v3/PaymentTokenTest.php

index ca7b17a571cfaa3166eaf395c6bbb43ee6086b62..9536c1052d621e0f470d1cb86e04280b3eb3fb6d 100644 (file)
@@ -98,8 +98,7 @@ class CRM_Member_Form_MembershipRenewalTest extends CiviUnitTestCase {
     parent::setUp();
 
     $this->_individualId = $this->individualCreate();
-    $processor = $this->processorCreate();
-    $this->_paymentProcessorID = $processor->id;
+    $this->_paymentProcessorID = $this->processorCreate();
     // Insert test data.
     $op = new PHPUnit_Extensions_Database_Operation_Insert();
     $op->execute($this->_dbconn,
index ae19247929756799f14688ebf5aa490a718489c7..a70157bc600ad5c5e112349b53fb413ff3a2674d 100644 (file)
@@ -98,8 +98,7 @@ class CRM_Member_Form_MembershipTest extends CiviUnitTestCase {
     parent::setUp();
 
     $this->_individualId = $this->individualCreate();
-    $processor = $this->processorCreate();
-    $this->_paymentProcessorID = $processor->id;
+    $this->_paymentProcessorID = $this->processorCreate();
     // Insert test data.
     $op = new PHPUnit_Extensions_Database_Operation_Insert();
     $op->execute($this->_dbconn,
index 9a3d907e2554ecafbe88873851d26fba45b2d785..352d6d68fe6fa269cb4d33ceeeff304af0d8e17e 100755 (executable)
@@ -1488,14 +1488,14 @@ class CiviUnitTestCase extends PHPUnit_Extensions_Database_TestCase {
   /**
    * Create Payment Processor.
    *
-   * @return CRM_Financial_DAO_PaymentProcessor
-   *   instance of Payment Processor
+   * @return int
+   *   Id Payment Processor
    */
   public function processorCreate() {
     $processorParams = array(
       'domain_id' => 1,
       'name' => 'Dummy',
-      'payment_processor_type_id' => 10,
+      'payment_processor_type_id' => 'Dummy',
       'financial_account_id' => 12,
       'is_test' => TRUE,
       'is_active' => 1,
@@ -1503,8 +1503,10 @@ class CiviUnitTestCase extends PHPUnit_Extensions_Database_TestCase {
       'url_site' => 'http://dummy.com',
       'url_recur' => 'http://dummy.com',
       'billing_mode' => 1,
+      'sequential' => 1,
     );
-    return CRM_Financial_BAO_PaymentProcessor::create($processorParams);
+    $processor = $this->callAPISuccess('PaymentProcessor', 'create', $processorParams);
+    return $processor['id'];
   }
 
   /**
@@ -1516,8 +1518,8 @@ class CiviUnitTestCase extends PHPUnit_Extensions_Database_TestCase {
    *    Instance of Dummy Payment Processor
    */
   public function dummyProcessorCreate($processorParams = array()) {
-    $paymentProcessor = $this->processorCreate($processorParams);
-    return Civi\Payment\System::singleton()->getById($paymentProcessor->id);
+    $paymentProcessorID = $this->processorCreate($processorParams);
+    return Civi\Payment\System::singleton()->getById($paymentProcessorID);
   }
 
   /**
index 49ef6c27475e91a9417159f2d537a8cc739e1c47..63ad157006c02072e8f78aa477c90170c476421e 100644 (file)
@@ -77,9 +77,8 @@ class api_v3_ContributionRecurTest extends CiviUnitTestCase {
   public function testCreateContributionRecurWithToken() {
     // create token
     $this->createLoggedInUser();
-    $paymentProcessor = $this->processorCreate();
     $token = $this->callAPISuccess('PaymentToken', 'create', array(
-      'payment_processor_id' => $paymentProcessor->id,
+      'payment_processor_id' => $this->processorCreate(),
       'token' => 'hhh',
       'contact_id' => $this->individualCreate(),
     ));
index d9431dd0ac471001a78358e447cd27cf8fc3ff20..91e84f90cd100124c88dbcd1bd51c999e3f92e42 100644 (file)
@@ -72,7 +72,7 @@ class api_v3_ContributionSoftTest extends CiviUnitTestCase {
     $this->_softIndividual2Id = $this->individualCreate();
     $this->_contributionId = $this->contributionCreate(array('contact_id' => $this->_individualId));
 
-    $paymentProcessor = $this->processorCreate();
+    $this->processorCreate();
     $this->_params = array(
       'contact_id' => $this->_individualId,
       'receive_date' => '20120511',
index 7f27b9e07c3bc9dea9bfd49f8e3151c2dc584c0a..77ee69fe85dcf4abdb450174cad2eb7bbabd576f 100644 (file)
@@ -72,7 +72,6 @@ class api_v3_ContributionTest extends CiviUnitTestCase {
 
     $this->_apiversion = 3;
     $this->_individualId = $this->individualCreate();
-    $paymentProcessor = $this->processorCreate();
     $this->_params = array(
       'contact_id' => $this->_individualId,
       'receive_date' => '20120511',
@@ -100,7 +99,7 @@ class api_v3_ContributionTest extends CiviUnitTestCase {
       'financial_type_id' => 1,
       'currency' => 'USD',
       'financial_account_id' => 1,
-      'payment_processor' => $paymentProcessor->id,
+      'payment_processor' => $this->processorCreate(),
       'is_active' => 1,
       'is_allow_other_amount' => 1,
       'min_amount' => 10,
index a07f8b474df7539771a4870a226eef78f46a1708..b11a3ff3ff9fe71ba4e3c5dd5af24b4fd456c768 100644 (file)
@@ -202,13 +202,12 @@ class api_v3_ParticipantPaymentTest extends CiviUnitTestCase {
    */
   public function testPaymentOnline() {
 
-    $paymentProcessor = $this->processorCreate();
-    $pageParams['processor_id'] = $paymentProcessor->id;
+    $pageParams['processor_id'] = $this->processorCreate();
     $contributionPage = $this->contributionPageCreate($pageParams);
     $contributionParams = array(
       'contact_id' => $this->_contactID,
       'contribution_page_id' => $contributionPage['id'],
-      'payment_processor' => $paymentProcessor->id,
+      'payment_processor' => $pageParams['processor_id'],
       'financial_type_id' => 1,
     );
     $contributionID = $this->contributionCreate($contributionParams);
@@ -236,9 +235,7 @@ class api_v3_ParticipantPaymentTest extends CiviUnitTestCase {
    * Check financial records for online Participant pay later scenario.
    */
   public function testPaymentPayLaterOnline() {
-
-    $paymentProcessor = $this->processorCreate();
-    $pageParams['processor_id'] = $paymentProcessor->id;
+    $pageParams['processor_id'] = $this->processorCreate();
     $pageParams['is_pay_later'] = 1;
     $contributionPage = $this->contributionPageCreate($pageParams);
     $contributionParams = array(
index a36edab30e6a86242811399f8c781e1699e4f286..d2b0fbfde850f89c28529a61aa040b9cdc1f7651 100644 (file)
@@ -43,12 +43,11 @@ class api_v3_PaymentTokenTest extends CiviUnitTestCase {
     $this->useTransaction(TRUE);
     parent::setUp();
     $contactID = $this->individualCreate();
-    $paymentProcessor = $this->processorCreate();
     $this->params = array(
       'token' => "fancy-token-xxxx",
       'contact_id' => $contactID,
       'created_id' => $contactID,
-      'payment_processor_id' => $paymentProcessor->id,
+      'payment_processor_id' => $this->processorCreate(),
     );
   }