Skip to content

Commit

Permalink
Dev: Also support the LIKE operator (list_participants)
Browse files Browse the repository at this point in the history
  • Loading branch information
olleharstedt committed Mar 19, 2020
1 parent f3f6bfa commit f6ff7d0
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
4 changes: 4 additions & 0 deletions application/helpers/remotecontrol/remotecontrol_handle.php
Expand Up @@ -2105,6 +2105,10 @@ public function list_participants($sSessionKey, $iSurveyID, $iStart = 0, $iLimit
$operator = $valueOrTuple[0];
if (!in_array($operator, $allowedOperators)) {
return array('status' => 'Illegal operator: ' . $operator);
} elseif ($operator === 'LIKE') {
/** @var mixed */
$value = $valueOrTuple[1];
$oCriteria->addSearchCondition($columnName, $value);
} else {
/** @var mixed */
$value = $valueOrTuple[1];
Expand Down
15 changes: 15 additions & 0 deletions tests/unit/helpers/RemoteControlListParticipantsTest.php
Expand Up @@ -270,5 +270,20 @@ public function testConditionHigherThan()
];

$this->assertEquals($expected, $list);

/** @var array */
$list = $handler->list_participants(
$sessionKey,
self::$surveyId,
0,
999,
false,
['validuntil', 'validfrom'],
['email' => ['LIKE', 'com']]
);

// Got exactly one participant with "com" in email.
$this->assertCount(1, $list);
$this->assertEquals('q@q.com', $list[0]['participant_info']['email']);
}
}

0 comments on commit f6ff7d0

Please sign in to comment.