CRM-16367 (Backoffice contribution page) get premium code email under unit test
authorEileen McNaughton <eileen@fuzion.co.nz>
Sun, 3 May 2015 10:05:03 +0000 (22:05 +1200)
committerEileen McNaughton <eileen@fuzion.co.nz>
Sun, 3 May 2015 10:05:03 +0000 (22:05 +1200)
CRM/Contribute/Form/AbstractEditPayment.php
CRM/Contribute/Form/AdditionalInfo.php
CRM/Contribute/Form/Contribution.php
tests/phpunit/CRM/Contribute/Form/ContributionTest.php

index c3b971d3d3b179abb676480c90d7894f1e1a9ad2..70678d1b8b4e44d2dc019491ae444130aa40e271 100644 (file)
@@ -29,8 +29,6 @@
  *
  * @package CRM
  * @copyright CiviCRM LLC (c) 2004-2015
- * $Id$
- *
  */
 
 /**
index 8da21e9c8e3218dfb1d2a58d37907f7310616f11..448f05bc4deace7554924cb1a4154231f51fb668 100644 (file)
@@ -375,12 +375,13 @@ class CRM_Contribute_Form_AdditionalInfo {
       ) {
         $productDAO = new CRM_Contribute_DAO_Product();
         $productDAO->id = $params['product_name'][0];
+        $productOptionID = $params['product_name'][1];
         $productDAO->find(TRUE);
         $params['product_name'] = $productDAO->name;
         $params['product_sku'] = $productDAO->sku;
 
-        if (empty($params['product_option']) && !empty($form->_options[$params['product_name'][0]])) {
-          $params['product_option'] = $form->_options[$params['product_name'][0]][$params['product_name'][1]];
+        if (empty($params['product_option']) && !empty($form->_options[$productDAO->id])) {
+          $params['product_option'] = $form->_options[$productDAO->id][$productOptionID];
         }
       }
 
index 2d4688c2cf07ab7e1a096830e286fab1c5041512..a8baae0ab6262158b7c57730392aab81a2aa0816 100644 (file)
@@ -1411,6 +1411,7 @@ class CRM_Contribute_Form_Contribution extends CRM_Contribute_Form_AbstractEditP
       'receipt_date_time' => '',
       'cancel_date' => '',
       'cancel_date_time' => '',
+      'hidden_Premium' => 1,
     );
     if (!empty($params['id'])) {
       $existingContribution = civicrm_api3('contribution', 'getsingle', array(
@@ -1432,6 +1433,7 @@ class CRM_Contribute_Form_Contribution extends CRM_Contribute_Form_AbstractEditP
     CRM_Contribute_Form_AdditionalInfo::buildPremium($this);
 
     $this->submit(array_merge($defaults, $params), $action, CRM_Utils_Array::value('pledge_payment_id', $params));
+
   }
 
   /**
index 984d21c4f9904865444ff1af6443c2ae222edfc3..df93819b764420659df36fa2a10ecc1a0c6297a4 100644 (file)
@@ -241,6 +241,7 @@ class CRM_Contribute_Form_ContributionTest extends CiviUnitTestCase {
    */
   public function testPremiumUpdate() {
     $form = new CRM_Contribute_Form_Contribution();
+    $mut = new CiviMailUtils($this, TRUE);
     $form->testSubmit(array(
       'total_amount' => 50,
       'financial_type_id' => 1,
@@ -251,9 +252,17 @@ class CRM_Contribute_Form_ContributionTest extends CiviUnitTestCase {
       'contribution_status_id' => 1,
       'product_name' => array($this->products[0]['id'], 1),
       'fulfilled_date' => '',
+      'is_email_receipt' => TRUE,
+      'from_email_address' => 'test@test.com',
     ), CRM_Core_Action::ADD);
     $contributionProduct = $this->callAPISuccess('contribution_product', 'getsingle', array());
     $this->assertEquals('clumsy smurf', $contributionProduct['product_option']);
+    $mut->checkMailLog(array(
+      'Premium Information',
+      'Smurf',
+      'clumsy smurf',
+    ));
+    $mut->stop();
   }
 
 }