Skip to content

Commit

Permalink
Remove ids from BAO_Product::create (renamed from add) signature alto…
Browse files Browse the repository at this point in the history
…gether

This is actually a new function so we don't need to respect the signature of the deprecated one
  • Loading branch information
eileenmcnaughton committed Jul 20, 2018
1 parent ff93a82 commit 207d537
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 10 deletions.
8 changes: 6 additions & 2 deletions CRM/Contribute/BAO/ManagePremiums.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,12 @@ public static function setIsActive($id, $is_active) {
* @return CRM_Contribute_DAO_Product
*/
public static function add(&$params, $ids) {
CRM_Core_Error::deprecatedFunctionWarning('CRM_Contribute_BAO_Product::add');
return parent::add($params, $ids);
CRM_Core_Error::deprecatedFunctionWarning('CRM_Contribute_BAO_Product::create');
$id = CRM_Utils_Array::value('id', $params, CRM_Utils_Array::value('premium', $ids));
if ($id) {
$params['id'] = $id;
}
return parent::create($params);
}

/**
Expand Down
4 changes: 2 additions & 2 deletions CRM/Contribute/BAO/Product.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,8 @@ public static function setIsActive($id, $is_active) {
*
* @return CRM_Contribute_DAO_Product
*/
public static function add(&$params, $ids = []) {
$id = CRM_Utils_Array::value('id', $params, CRM_Utils_Array::value('premium', $ids));
public static function create($params) {
$id = CRM_Utils_Array::value('id', $params);
if (empty($id)) {
$defaultParams = [
'id' => $id,
Expand Down
2 changes: 1 addition & 1 deletion CRM/Contribute/Form/ManagePremiums.php
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ public function postProcess() {
$this->_processImages($params);

// Save to database
$premium = CRM_Contribute_BAO_Product::add($params);
$premium = CRM_Contribute_BAO_Product::create($params);

CRM_Core_Session::setStatus(
ts("The Premium '%1' has been saved.", array(1 => $premium->name)),
Expand Down
2 changes: 1 addition & 1 deletion tests/phpunit/CRM/Contribute/BAO/ContributionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ public function testAddPremium() {
'min_contribution' => 100,
'is_active' => 1,
);
$premium = CRM_Contribute_BAO_Product::add($params);
$premium = CRM_Contribute_BAO_Product::create($params);

$this->assertEquals('TEST Premium', $premium->name, 'Check for premium name.');

Expand Down
8 changes: 4 additions & 4 deletions tests/phpunit/CRM/Contribute/BAO/ProductTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public function testAdd() {
'is_active' => 1,
);

$product = CRM_Contribute_BAO_Product::add($params);
$product = CRM_Contribute_BAO_Product::create($params);

$result = $this->assertDBNotNull('CRM_Contribute_BAO_Product', $product->id,
'sku', 'id',
Expand All @@ -73,7 +73,7 @@ public function testRetrieve() {
'is_active' => 1,
);

$product = CRM_Contribute_BAO_Product::add($params);
$product = CRM_Contribute_BAO_Product::create($params);
$params = array('id' => $product->id);
$default = array();
$result = CRM_Contribute_BAO_Product::retrieve($params, $default);
Expand All @@ -94,7 +94,7 @@ public function testSetIsActive() {
'is_active' => 1,
);

$product = CRM_Contribute_BAO_Product::add($params);
$product = CRM_Contribute_BAO_Product::create($params);
CRM_Contribute_BAO_Product::setIsActive($product->id, 0);

$isActive = $this->assertDBNotNull('CRM_Contribute_BAO_Product', $product->id,
Expand All @@ -119,7 +119,7 @@ public function testDel() {
'is_active' => 1,
);

$product = CRM_Contribute_BAO_Product::add($params);
$product = CRM_Contribute_BAO_Product::create($params);

CRM_Contribute_BAO_Product::del($product->id);

Expand Down

0 comments on commit 207d537

Please sign in to comment.