Merge pull request #17008 from ivan-compucorp/CPS-70-fix-radio-value
[civicrm-core.git] / Civi / Test / Api3DocTrait.php
index a4c3ceb565fbe96ab30dbaaeb88d4b9d9bf31ae5..27440f70fa799ffda93ff0363053f0b1773d546e 100644 (file)
@@ -68,7 +68,7 @@ trait Api3DocTrait {
    *   Name for this example file (CamelCase) - if omitted the action name will be substituted.
    */
   private function documentMe($entity, $action, $params, $result, $testFunction, $testFile, $description = "", $exampleName = NULL) {
-    if (defined('DONT_DOCUMENT_TEST_CONFIG') && DONT_DOCUMENT_TEST_CONFIG) {
+    if ($params['version'] != 3 || (defined('DONT_DOCUMENT_TEST_CONFIG') && DONT_DOCUMENT_TEST_CONFIG)) {
       return;
     }
     $entity = _civicrm_api_get_camel_name($entity);
@@ -123,8 +123,10 @@ trait Api3DocTrait {
       if (!is_dir($civicrm_root . "/api/v3/examples/$entity")) {
         mkdir($civicrm_root . "/api/v3/examples/$entity");
       }
-      $f = fopen($civicrm_root . "/api/v3/examples/$entity/$exampleName.php", "w+b");
-      fwrite($f, $smarty->fetch($civicrm_root . '/tests/templates/documentFunction.tpl'));
+      $f = fopen($civicrm_root . "/api/v3/examples/$entity/$exampleName.ex.php", "w+b");
+      $contents = $smarty->fetch($civicrm_root . '/tests/templates/documentFunction.tpl');
+      $contents = \CRM_Core_CodeGen_Util_ArraySyntaxConverter::convert($contents);
+      fwrite($f, $contents);
       fclose($f);
     }
   }