-/**
- * Create an instance of the paypal processor
- * @todo this isn't a great place to put it - but really it belongs on a class that extends
- * this parent class & we don't have a structure for that yet
- * There is another function to this effect on the PaypalPro test but it appears to be silently failing
- * & the best protection agains that is the functions this class affords
- */
- function paymentProcessorCreate($params = array()) {
- $params = array_merge(array(
- 'name' => 'demo',
- 'domain_id' => CRM_Core_Config::domainID(),
- 'payment_processor_type_id' => 'PayPal',
- 'is_active' => 1,
- 'is_default' => 0,
- 'is_test' => 1,
- 'user_name' => 'sunil._1183377782_biz_api1.webaccess.co.in',
- 'password' => '1183377788',
- 'signature' => 'APixCoQ-Zsaj-u3IH7mD5Do-7HUqA9loGnLSzsZga9Zr-aNmaJa3WGPH',
- 'url_site' => 'https://www.sandbox.paypal.com/',
- 'url_api' => 'https://api-3t.sandbox.paypal.com/',
- 'url_button' => 'https://www.paypal.com/en_US/i/btn/btn_xpressCheckout.gif',
- 'class_name' => 'Payment_PayPalImpl',
- 'billing_mode' => 3,
- 'financial_type_id' => 1,
- ),
- $params);
- if(!is_numeric($params['payment_processor_type_id'])) {
- // really the api should handle this through getoptions but it's not exactly api call so lets just sort it
- //here
- $params['payment_processor_type_id'] = $this->callAPISuccess('payment_processor_type', 'getvalue', array(
- 'name' => $params['payment_processor_type_id'],
- 'return' => 'id',
- ), 'integer');
- }
- $result = $this->callAPISuccess('payment_processor', 'create', $params);
- return $result['id'];
- }
-
-
-function CiviUnitTestCase_fatalErrorHandler($message) {
- throw new Exception("{$message['message']}: {$message['code']}");
-}
+ /**
+ * alter default price set so that the field numbers are not all 1 (hiding errors)
+ */
+ function offsetDefaultPriceSet() {
+ $contributionPriceSet = $this->callAPISuccess('price_set', 'getsingle', array('name' => 'default_contribution_amount'));
+ $firstID = $contributionPriceSet['id'];
+ $this->callAPISuccess('price_set', 'create', array('id' => $contributionPriceSet['id'], 'is_active' => 0, 'name' => 'old'));
+ unset($contributionPriceSet['id']);
+ $newPriceSet = $this->callAPISuccess('price_set', 'create', $contributionPriceSet);
+ $priceField = $this->callAPISuccess('price_field', 'getsingle', array('price_set_id' => $firstID, 'options' => array('limit' => 1)));
+ unset($priceField['id']);
+ $priceField['price_set_id'] = $newPriceSet['id'];
+ $newPriceField = $this->callAPISuccess('price_field', 'create', $priceField);
+ $priceFieldValue = $this->callAPISuccess('price_field_value', 'getsingle', array('price_set_id' => $firstID, 'sequential' => 1, 'options' => array('limit' => 1)));
+
+ unset($priceFieldValue['id']);
+ //create some padding to use up ids
+ $this->callAPISuccess('price_field_value', 'create', $priceFieldValue);
+ $this->callAPISuccess('price_field_value', 'create', $priceFieldValue);
+ $this->callAPISuccess('price_field_value', 'create', array_merge($priceFieldValue, array('price_field_id' => $newPriceField['id'])));
+
+ }
+
+ /**
+ * Create an instance of the paypal processor
+ * @todo this isn't a great place to put it - but really it belongs on a class that extends
+ * this parent class & we don't have a structure for that yet
+ * There is another function to this effect on the PaypalPro test but it appears to be silently failing
+ * & the best protection agains that is the functions this class affords
+ */
+ function paymentProcessorCreate($params = array()) {
+ $params = array_merge(array(
+ 'name' => 'demo',
+ 'domain_id' => CRM_Core_Config::domainID(),
+ 'payment_processor_type_id' => 'PayPal',
+ 'is_active' => 1,
+ 'is_default' => 0,
+ 'is_test' => 1,
+ 'user_name' => 'sunil._1183377782_biz_api1.webaccess.co.in',
+ 'password' => '1183377788',
+ 'signature' => 'APixCoQ-Zsaj-u3IH7mD5Do-7HUqA9loGnLSzsZga9Zr-aNmaJa3WGPH',
+ 'url_site' => 'https://www.sandbox.paypal.com/',
+ 'url_api' => 'https://api-3t.sandbox.paypal.com/',
+ 'url_button' => 'https://www.paypal.com/en_US/i/btn/btn_xpressCheckout.gif',
+ 'class_name' => 'Payment_PayPalImpl',
+ 'billing_mode' => 3,
+ 'financial_type_id' => 1,
+ ),
+ $params);
+ if (!is_numeric($params['payment_processor_type_id'])) {
+ // really the api should handle this through getoptions but it's not exactly api call so lets just sort it
+ //here
+ $params['payment_processor_type_id'] = $this->callAPISuccess('payment_processor_type', 'getvalue', array(
+ 'name' => $params['payment_processor_type_id'],
+ 'return' => 'id',
+ ), 'integer');
+ }
+ $result = $this->callAPISuccess('payment_processor', 'create', $params);
+ return $result['id'];
+ }
+
+ /**
+ * @param $message
+ *
+ * @throws Exception
+ */
+ function CiviUnitTestCase_fatalErrorHandler($message) {
+ throw new Exception("{$message['message']}: {$message['code']}");
+ }
+
+ /**
+ * Helper function to create new mailing
+ * @return mixed
+ */
+ function createMailing() {
+ $params = array(
+ 'subject' => 'maild' . rand(),
+ 'body_text' => 'bdkfhdskfhduew',
+ 'name' => 'mailing name' . rand(),
+ 'created_id' => 1,
+ );
+
+ $result = $this->callAPISuccess('Mailing', 'create', $params);
+ return $result['id'];
+ }
+
+ /**
+ * Helper function to delete mailing
+ * @param $id
+ */
+ function deleteMailing($id) {
+ $params = array(
+ 'id' => $id,
+ );
+
+ $this->callAPISuccess('Mailing', 'delete', $params);
+ }