6 class CRM_Event_Form_SearchTest
extends CiviUnitTestCase
{
8 public function setUp(): void
{
10 $this->individualID
= $this->individualCreate();
11 $this->event
= $this->eventCreate();
12 $this->priceFieldValues
= $this->createPriceSet('event', $this->event
, [
13 'html_type' => 'Radio',
14 'option_label' => ['1' => 'Radio Label A (inc. GST)', '2' => 'Radio Label B (inc. GST)'],
15 'option_name' => ['1' => 'Radio Label A', '2' => 'Radio Label B'],
18 $this->priceFieldValues
= $this->priceFieldValues
['values'];
19 $this->participantPrice
= NULL;
20 foreach ($this->priceFieldValues
as $priceFieldValue) {
21 $this->participantPrice
= $priceFieldValue;
25 $today = new DateTime();
26 $this->participant
= $this->participantCreate([
27 'event_id' => $this->event
['id'],
28 'contact_id' => $this->individualID
,
30 'fee_level' => $this->participantPrice
['label'],
31 'fee_amount' => $this->participantPrice
['amount'],
32 'fee_currency' => 'USD',
33 'register_date' => $today->format('YmdHis'),
37 public function tearDown(): void
{
38 $this->quickCleanUpFinancialEntities();
43 * Test that search form returns correct number of rows for complex regex filters.
45 public function testSearch() {
46 $form = new CRM_Event_Form_Search();
47 $form->controller
= new CRM_Event_Controller_Search();
50 'participant_test' => 0,
51 'participant_fee_id' => [
52 $this->participantPrice
['id'],
54 'radio_ts' => 'ts_all',
56 $rows = $form->controller
->get('rows');
57 $this->assertEquals(1, count($rows), 'Exactly one row should be returned for given price field value.');
60 public function testSearchWithPricelabelChange() {
61 $this->callAPISuccess('PriceFieldValue', 'create', [
62 'label' => 'Radio Label C',
63 'id' => $this->participantPrice
['id'],
65 $form = new CRM_Event_Form_Search();
66 $form->controller
= new CRM_Event_Controller_Search();
69 'participant_test' => 0,
70 'participant_fee_id' => [
71 $this->participantPrice
['id'],
73 'radio_ts' => 'ts_all',
75 // Confirm that even tho we have changed the label for the price field value the query still works
76 $rows = $form->controller
->get('rows');
77 $this->assertEquals(1, count($rows), 'Exactly one row should be returned for given price field value.');