Skip to content

Commit

Permalink
[NFC] Add in unit test to ensure that APIv4 Doesn't accept an invalid…
Browse files Browse the repository at this point in the history
… sort
  • Loading branch information
seamuslee001 committed Mar 25, 2020
1 parent f9a004f commit 1dc4ad9
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions tests/phpunit/api/v4/Query/Api4SelectQueryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,4 +105,26 @@ public function testOneToManyMultipleJoin() {
$this->assertCount(2, $result['phones']);
}


public function testInvaidSort() {
$query = new Api4SelectQuery('Contact', FALSE, civicrm_api4('Contact', 'getFields', ['includeCustom' => FALSE, 'checkPermissions' => FALSE, 'action' => 'get'], 'name'));
$query->select[] = 'id';
$query->select[] = 'first_name';
$query->select[] = 'phones.phone';
$query->where[] = ['first_name', '=', 'Phoney'];
$query->orderBy = ['first_name' => 'sleep(1)'];
try {
$results = $query->run();
$this->fail('An Exception Should have been raised');
}
catch (\API_Exception $e) {
}
$query->orderBy = ['sleep(1)', 'ASC'];
try {
$results = $query->run();
$this->fail('An Exception Should have been raised');
}
catch (\API_Exception $e) {
}
}
}

0 comments on commit 1dc4ad9

Please sign in to comment.