From 8d5b38f109ceb0994b8d3f64f1013b7e98ea6d97 Mon Sep 17 00:00:00 2001 From: colemanw Date: Wed, 18 Oct 2023 09:06:34 -0400 Subject: [PATCH] ParticipantStatusType - Switch to writeRecord --- CRM/Admin/Form/ParticipantStatusType.php | 2 +- CRM/Event/BAO/ParticipantStatusType.php | 20 +++++-------------- .../CRM/Event/BAO/ParticipantStatusTest.php | 8 ++++---- 3 files changed, 10 insertions(+), 20 deletions(-) diff --git a/CRM/Admin/Form/ParticipantStatusType.php b/CRM/Admin/Form/ParticipantStatusType.php index a3097c7de7..7eb9523568 100644 --- a/CRM/Admin/Form/ParticipantStatusType.php +++ b/CRM/Admin/Form/ParticipantStatusType.php @@ -119,7 +119,7 @@ class CRM_Admin_Form_ParticipantStatusType extends CRM_Admin_Form { } $params['weight'] = CRM_Utils_Weight::updateOtherWeights('CRM_Event_DAO_ParticipantStatusType', $oldWeight, $params['weight']); - $participantStatus = CRM_Event_BAO_ParticipantStatusType::create($params); + $participantStatus = CRM_Event_BAO_ParticipantStatusType::writeRecord($params); if ($participantStatus->id) { if ($this->_action & CRM_Core_Action::UPDATE) { diff --git a/CRM/Event/BAO/ParticipantStatusType.php b/CRM/Event/BAO/ParticipantStatusType.php index 7176dcc48b..7632f634e7 100644 --- a/CRM/Event/BAO/ParticipantStatusType.php +++ b/CRM/Event/BAO/ParticipantStatusType.php @@ -17,33 +17,23 @@ class CRM_Event_BAO_ParticipantStatusType extends CRM_Event_DAO_ParticipantStatusType { /** + * @deprecated * @param array $params * * @return self|null */ public static function add(&$params) { - if (empty($params)) { - return NULL; - } - $dao = new CRM_Event_DAO_ParticipantStatusType(); - $dao->copyValues($params); - return $dao->save(); + return self::writeRecord($params); } /** + * @deprecated * @param array $params * * @return self|null */ - public static function &create(&$params) { - $transaction = new CRM_Core_Transaction(); - $statusType = self::add($params); - if (is_a($statusType, 'CRM_Core_Error')) { - $transaction->rollback(); - return $statusType; - } - $transaction->commit(); - return $statusType; + public static function create(&$params) { + return self::writeRecord($params); } /** diff --git a/tests/phpunit/CRM/Event/BAO/ParticipantStatusTest.php b/tests/phpunit/CRM/Event/BAO/ParticipantStatusTest.php index 190232af43..01dedbfc57 100644 --- a/tests/phpunit/CRM/Event/BAO/ParticipantStatusTest.php +++ b/tests/phpunit/CRM/Event/BAO/ParticipantStatusTest.php @@ -31,7 +31,7 @@ class CRM_Event_BAO_ParticipantStatusTest extends CiviUnitTestCase { 'visibility_id' => 1, ]; - $statusType = CRM_Event_BAO_ParticipantStatusType::create($params); + $statusType = CRM_Event_BAO_ParticipantStatusType::writeRecord($params); // Checking for participant status type id in db. $statusTypeId = $this->assertDBNotNull('CRM_Event_DAO_ParticipantStatusType', $statusType->id, 'id', 'id', 'Check DB for status type id' @@ -60,7 +60,7 @@ class CRM_Event_BAO_ParticipantStatusTest extends CiviUnitTestCase { ]; // check for add participant status type - $statusType = CRM_Event_BAO_ParticipantStatusType::add($params); + $statusType = CRM_Event_BAO_ParticipantStatusType::writeRecord($params); foreach ($params as $param => $value) { $this->assertEquals($value, $statusType->$param); } @@ -77,7 +77,7 @@ class CRM_Event_BAO_ParticipantStatusTest extends CiviUnitTestCase { ]; // check for add participant status type - $statusType = CRM_Event_BAO_ParticipantStatusType::add($params); + $statusType = CRM_Event_BAO_ParticipantStatusType::writeRecord($params); foreach ($params as $param => $value) { $this->assertEquals($value, $statusType->$param); } @@ -98,7 +98,7 @@ class CRM_Event_BAO_ParticipantStatusTest extends CiviUnitTestCase { 'visibility_id' => 1, ]; - $statusType = CRM_Event_BAO_ParticipantStatusType::create($params); + $statusType = CRM_Event_BAO_ParticipantStatusType::writeRecord($params); // retrieve status type $retrieveParams = ['id' => $statusType->id]; -- 2.25.1