Expand test coverage to include specified ordering
authorSeamus Lee <seamuslee001@gmail.com>
Mon, 12 Dec 2016 05:16:28 +0000 (16:16 +1100)
committerSeamus Lee <seamuslee001@gmail.com>
Mon, 12 Dec 2016 05:17:10 +0000 (16:17 +1100)
tests/phpunit/api/v3/SyntaxConformanceTest.php

index eadc674212e30e09105c96889f7eb9b861461b04..80a4a0b194a89fb33ca66cfbdb75f5d99be07ed2 100644 (file)
@@ -1061,13 +1061,21 @@ class api_v3_SyntaxConformanceTest extends CiviUnitTestCase {
    */
   public function testValidSortSingleArrayById_get($Entity) {
     $invalidEntitys = array('ActivityType', 'Setting', 'System');
-    if (in_array($Entity, $invalidEntitys)) {
-      $this->markTestSkipped('It seems OK for ' . $Entity . ' to skip here as it silently sips invalid params');
+    $tests = array(
+      'id' => '_id',
+      'id desc' => '_id desc',
+      'id DESC' => '_id DESC',
+      'id ASC' => '_id ASC',
+      'id asc' => '_id asc');
+    foreach ($tests as $test => $expected) {
+      if (in_array($Entity, $invalidEntitys)) {
+        $this->markTestSkipped('It seems OK for ' . $Entity . ' to skip here as it silently ignores passed in params');
+      }
+      $params = array('sort' => array($test));
+      $result = _civicrm_api3_get_options_from_params($params, FALSE, $Entity, 'get');
+      $lowercase_entity = _civicrm_api_get_entity_name_from_camel($Entity);
+      $this->assertEquals($lowercase_entity . $expected, $result['sort']);
     }
-    $params = array('sort' => array('id'));
-    $result = _civicrm_api3_get_options_from_params($params, FALSE, $Entity, 'get');
-    $lowercase_entity = _civicrm_api_get_entity_name_from_camel($Entity);
-    $this->assertEquals($result['sort'], $lowercase_entity . '_id');
   }
 
   /**