Merge pull request #2269 from eileenmcnaughton/test-fixes
authorcolemanw <coleman@civicrm.org>
Fri, 3 Jan 2014 04:51:52 +0000 (20:51 -0800)
committercolemanw <coleman@civicrm.org>
Fri, 3 Jan 2014 04:51:52 +0000 (20:51 -0800)
E-notice fix

tests/phpunit/CRM/Contact/BAO/ContactTest.php
tests/phpunit/CRM/Core/Page/AJAXTest.php
tests/phpunit/CRM/Core/Payment/AuthorizeNetTest.php

index 3398972bfff4663d396c2382d0f7daec0d499440..d4aa8b917f90ca6ef2c7186b157e3d97fdc16514 100644 (file)
@@ -1530,7 +1530,7 @@ class CRM_Contact_BAO_ContactTest extends CiviUnitTestCase {
     $test = $this;
     $this->_testTimestamps(array(
       'INSERT' => function ($contactId) use ($test, $customGroup, $customField) {
-        $result = $this->callAPISuccess('contact', 'create', array(
+        $result = civicrm_api3('contact', 'create', array(
           'contact_id' => $contactId,
           'custom_' . $customField['id'] => 'test-1',
         ));
index 28adafd279e4896dc08a2cb1786c980abe0b4bc5..0c37781258f48fbbd9d93a3f792c2efd29b09d11 100644 (file)
@@ -3,10 +3,6 @@
 require_once 'CiviTest/CiviUnitTestCase.php';
 
 class CRM_Core_Page_AJAXTest extends CiviUnitTestCase {
-  //@todo make BAO enotice compliant  & remove the line below
-  // WARNING - NEVER COPY & PASTE $_eNoticeCompliant = FALSE
-  // new test classes should be compliant.
-  public $_eNoticeCompliant = FALSE;
   public function testCheckAuthz() {
     $cases = array();
 
@@ -50,7 +46,8 @@ class CRM_Core_Page_AJAXTest extends CiviUnitTestCase {
     $cases[] = array('invalidtype', 'CRM_Foo_Page_AJAX::method', FALSE);
 
     foreach ($cases as $case) {
-      list ($type, $className, $expectedResult, $methodName) = $case;
+      list ($type, $className, $expectedResult) = $case;
+      $methodName = CRM_Utils_Array::value(3, $case);
       $actualResult = CRM_Core_Page_AJAX::checkAuthz($type, $className, $methodName);
       if ($methodName) {
         $this->assertEquals($expectedResult, $actualResult,
index 84019ed303b21dadf3f8e3b062e35cf25922b140..cab4501e302a1e84224c3fa68db9dcb16badbe87 100644 (file)
 
 require_once 'CiviTest/CiviUnitTestCase.php';
 require_once 'CiviTest/AuthorizeNet.php';
-require_once 'CiviTest/Contact.php';
+
 class CRM_Core_Payment_AuthorizeNetTest extends CiviUnitTestCase {
-  //@todo make BAO enotice compliant  & remove the line below
-  // WARNING - NEVER COPY & PASTE $_eNoticeCompliant = FALSE
-  // new test classes should be compliant.
-  public $_eNoticeCompliant = FALSE;
   function get_info() {
     return array(
       'name' => 'Authorize.net processing',
@@ -51,6 +47,7 @@ class CRM_Core_Payment_AuthorizeNetTest extends CiviUnitTestCase {
       'user_name' => $this->processorParams->user_name,
       'password' => $this->processorParams->password,
       'url_recur' => $this->processorParams->url_recur,
+      'signature' => '',
     );
 
     $this->processor = new CRM_Core_Payment_AuthorizeNet('Contribute', $paymentProcessor);
@@ -76,7 +73,7 @@ class CRM_Core_Payment_AuthorizeNetTest extends CiviUnitTestCase {
     $firstName  = 'John_' .  substr(sha1(rand()), 0, 7);
     $lastName   = 'Smith_' . substr(sha1(rand()), 0, 7);
     $nameParams = array('first_name' => $firstName, 'last_name' => $lastName);
-    $contactId  = Contact::createIndividual($nameParams);
+    $contactId  = $this->individualCreate($nameParams);
 
     $invoiceID = sha1(rand());
     $amount    = rand(100, 1000) . '.00';
@@ -95,7 +92,7 @@ class CRM_Core_Payment_AuthorizeNetTest extends CiviUnitTestCase {
       'is_test' => 1,
       'payment_processor_id' => $this->processorParams->id,
     );
-    $recur = CRM_Contribute_BAO_ContributionRecur::add($contributionRecurParams, $ids);
+    $recur = CRM_Contribute_BAO_ContributionRecur::add($contributionRecurParams);
 
     $contributionParams = array(
       'contact_id'   => $contactId,
@@ -108,7 +105,7 @@ class CRM_Core_Payment_AuthorizeNetTest extends CiviUnitTestCase {
       'is_test'      => 1,
       'contribution_status_id' => 2,
     );
-    $contribution = CRM_Contribute_BAO_Contribution::add($contributionParams, $ids);
+    $contribution = CRM_Contribute_BAO_Contribution::add($contributionParams);
 
     $params = array(
       'qfKey' => '08ed21c7ca00a1f7d32fff2488596ef7_4454',
@@ -195,10 +192,9 @@ class CRM_Core_Payment_AuthorizeNetTest extends CiviUnitTestCase {
 
     // cancel it or the transaction will be rejected by A.net if the test is re-run
     $subscriptionID = CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_ContributionRecur', $recur->id, 'processor_id');
+    $message = '';
     $result = $this->processor->cancelSubscription($message, array('subscriptionId' => $subscriptionID));
     $this->assertTrue($result, 'Failed to cancel subscription with Authorize.');
-
-    Contact::delete($contactId);
   }
 
   /**
@@ -210,7 +206,7 @@ class CRM_Core_Payment_AuthorizeNetTest extends CiviUnitTestCase {
     $firstName  = 'John_' .  substr(sha1(rand()), 0, 7);
     $lastName   = 'Smith_' . substr(sha1(rand()), 0, 7);
     $nameParams = array('first_name' => $firstName, 'last_name' => $lastName);
-    $contactId  = Contact::createIndividual($nameParams);
+    $contactId  = $this->individualCreate($nameParams);
 
     $ids = array('contribution' => NULL);
     $invoiceID = sha1(rand());
@@ -244,7 +240,7 @@ class CRM_Core_Payment_AuthorizeNetTest extends CiviUnitTestCase {
       'contribution_status_id' => 2,
     );
 
-    $this->callAPISuccess('contribution', 'create', $contributionParams);
+    $contribution = $this->callAPISuccess('contribution', 'create', $contributionParams);
 
     $params = array(
       'qfKey' => '00ed21c7ca00a1f7d555555596ef7_4454',
@@ -314,7 +310,7 @@ class CRM_Core_Payment_AuthorizeNetTest extends CiviUnitTestCase {
       'contributionPageID' => '',
       'email' => "{$firstName}.{$lastName}@example.com",
       'contactID' => $contactId,
-      'contributionID' => $contribution->id,
+      'contributionID' => $contribution['id'],
       'contributionTypeID' => $this->_financialTypeId,
       'contributionRecurID' => $recur->id,
     );
@@ -337,9 +333,8 @@ class CRM_Core_Payment_AuthorizeNetTest extends CiviUnitTestCase {
 
     // cancel it or the transaction will be rejected by A.net if the test is re-run
     $subscriptionID = CRM_Core_DAO::getFieldValue('CRM_Contribute_DAO_ContributionRecur', $recur->id, 'processor_id');
+    $message = '';
     $result = $this->processor->cancelSubscription($message, array('subscriptionId' => $subscriptionID));
     $this->assertTrue($result, 'Failed to cancel subscription with Authorize.');
-
-    Contact::delete($contactId);
   }
 }