From 10427602bb652058d7283fa4e8ce53b013aee5e6 Mon Sep 17 00:00:00 2001 From: Eileen McNaughton Date: Thu, 31 Aug 2023 23:19:17 +1200 Subject: [PATCH] Add weights to event search --- tests/phpunit/CRM/Event/Form/SearchTest.php | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/tests/phpunit/CRM/Event/Form/SearchTest.php b/tests/phpunit/CRM/Event/Form/SearchTest.php index 9ad8a7d27d..5653f6e30d 100644 --- a/tests/phpunit/CRM/Event/Form/SearchTest.php +++ b/tests/phpunit/CRM/Event/Form/SearchTest.php @@ -21,11 +21,7 @@ class CRM_Event_Form_SearchTest extends CiviUnitTestCase { ]); $priceFieldValues = $priceFieldValues['values']; - $this->participantPrice = NULL; - foreach ($priceFieldValues as $priceFieldValue) { - $this->participantPrice = $priceFieldValue; - break; - } + $this->participantPrice = reset($priceFieldValues); $this->participantCreate([ 'event_id' => $event['id'], @@ -61,10 +57,13 @@ class CRM_Event_Form_SearchTest extends CiviUnitTestCase { 'radio_ts' => 'ts_all', ]); $rows = $form->controller->get('rows'); - $this->assertEquals(1, count($rows), 'Exactly one row should be returned for given price field value.'); + $this->assertCount(1, $rows, 'Exactly one row should be returned for given price field value.'); } - public function testSearchWithPricelabelChange(): void { + /** + * @throws \CRM_Core_Exception + */ + public function testSearchWithPriceLabelChange(): void { $this->callAPISuccess('PriceFieldValue', 'create', [ 'label' => 'Radio Label C', 'id' => $this->participantPrice['id'], @@ -81,7 +80,7 @@ class CRM_Event_Form_SearchTest extends CiviUnitTestCase { ]); // Confirm that even tho we have changed the label for the price field value the query still works $rows = $form->controller->get('rows'); - $this->assertEquals(1, count($rows), 'Exactly one row should be returned for given price field value.'); + $this->assertCount(1, $rows, 'Exactly one row should be returned for given price field value.'); } } -- 2.25.1