Skip to content

Commit

Permalink
Merge pull request #16893 from seamuslee001/nfc_sort_api4_test
Browse files Browse the repository at this point in the history
[NFC] Add in unit test to ensure that APIv4 Doesn't accept an invalid…
  • Loading branch information
colemanw authored Mar 28, 2020
2 parents 0597447 + 1d37400 commit 28f8e24
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions tests/phpunit/api/v4/Query/Api4SelectQueryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,4 +109,27 @@ public function testOneToManyMultipleJoin() {
$this->assertCount(2, $result['phones']);
}

public function testInvaidSort() {
$api = \Civi\API\Request::create('Contact', 'get', ['version' => 4, 'checkPermissions' => FALSE]);
$query = new Api4SelectQuery($api);
$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 28f8e24

Please sign in to comment.