Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EventFlagsTest: Fix testFlagFilters #94

Open
wants to merge 1 commit into
base: run-tests-in-github-action
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 22 additions & 27 deletions tests/phpunit/CRM/Remoteevent/EventFlagsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -163,51 +163,46 @@ public function testFlagsPersonalised()
/**
* Test as filters
*/
public function testFlagFilters()
public function testFlagFilters(): void
{
// create an event
// create events
$event1 = $this->createRemoteEvent();
$event2 = $this->createRemoteEvent();
$this->createRemoteEvent();
$event3 = $this->createRemoteEvent();
$my_events = ['id' => ['IN' => [$event1['id'], $event2['id'], $event3['id']]]];
$my_event = ['id' => $event1['id']];

// create a remote contact
$contact = $this->createContact();
$remote_key = $this->getRemoteContactKey($contact['id']);
$my_contact = ['remote_contact_id' => $remote_key];
$my_event_contact = $my_events + $my_contact;
$my_event_contact = $my_event + $my_contact;

$this->callAPISuccessGetCount('RemoteEvent', $my_event, 1);
$this->callAPISuccessGetCount('RemoteEvent', $my_contact, 3);
$this->callAPISuccessGetCount('RemoteEvent', ['id' => $event3['id'] + 1], 0);

// there should now be 3 events
$this->callAPISuccessGetCount('RemoteEvent', $my_events, 3);
// let's see what happens when we add limits
$this->callAPISuccessGetCount('RemoteEvent',$my_contact + ['option.limit' => 3], 3);
$this->callAPISuccessGetCount('RemoteEvent',$my_contact + ['option.limit' => 2], 2);
$this->callAPISuccessGetCount('RemoteEvent',$my_contact + ['option.limit' => 1], 1);

// there should not be any registered contact yet
$this->callAPISuccessGetCount('RemoteEvent',$my_event_contact, 3);
$this->callAPISuccessGetCount('RemoteEvent',$my_event_contact + ['is_registered' => 0], 3);
$this->callAPISuccessGetCount('RemoteEvent',$my_event_contact + ['is_registered' => 0], 1);
$this->callAPISuccessGetCount('RemoteEvent',$my_event_contact + ['is_registered' => 1], 0);

// let's see what happens when we add limits
$this->callAPISuccessGetCount('RemoteEvent',$my_event_contact + ['option.limit' => 3], 3);
$this->callAPISuccessGetCount('RemoteEvent',$my_event_contact + ['option.limit' => 2], 2);
$this->callAPISuccessGetCount('RemoteEvent',$my_event_contact + ['option.limit' => 1], 1);
$this->callAPISuccessGetCount('RemoteEvent',$my_contact + ['is_registered' => 0], 3);
$this->callAPISuccessGetCount('RemoteEvent',$my_contact + ['is_registered' => 1], 0);

// now, let's register, and see if something changes
$this->registerRemote($event1['id'], ['email' => $contact['email']]);
$this->callAPISuccessGetCount('RemoteEvent',$my_event_contact, 3);
$this->callAPISuccessGetCount('RemoteEvent',$my_event_contact + ['is_registered' => 0], 2);
$this->callAPISuccessGetCount('RemoteEvent', $my_event_contact, 1);
$this->callAPISuccessGetCount('RemoteEvent',$my_event_contact + ['is_registered' => 0], 0);
$this->callAPISuccessGetCount('RemoteEvent',$my_event_contact + ['is_registered' => 1], 1);

// let's see what happens when we add limits
$this->callAPISuccessGetCount('RemoteEvent',$my_event_contact + ['option.limit' => 3], 3);
$this->callAPISuccessGetCount('RemoteEvent',$my_event_contact + ['option.limit' => 2], 2);
$this->callAPISuccessGetCount('RemoteEvent',$my_event_contact + ['option.limit' => 1], 1);
$this->callAPISuccessGetCount('RemoteEvent',$my_contact + ['is_registered' => 0], 2);
$this->callAPISuccessGetCount('RemoteEvent',$my_contact + ['is_registered' => 1], 1);

// let's see what happens when we add limits + flags
$this->callAPISuccessGetCount('RemoteEvent',$my_event_contact + ['is_registered' => 0, 'option.limit' => 1], 1);
$this->callAPISuccessGetCount('RemoteEvent',$my_event_contact + ['is_registered' => 1, 'option.limit' => 3], 1);

// same without limits
$this->callAPISuccessGetCount('RemoteEvent',$my_event_contact + ['is_registered' => 0], 2);
$this->callAPISuccessGetCount('RemoteEvent',$my_event_contact + ['is_registered' => 1], 1);
$this->callAPISuccessGetCount('RemoteEvent',$my_contact + ['is_registered' => 0, 'option.limit' => 1], 1);
$this->callAPISuccessGetCount('RemoteEvent',$my_contact + ['is_registered' => 1, 'option.limit' => 3], 1);
}

/**
Expand Down
Loading