Reorganize and update api examples
authorColeman Watts <coleman@civicrm.org>
Tue, 11 Feb 2014 05:15:40 +0000 (21:15 -0800)
committerEileen McNaughton <eileen@fuzion.co.nz>
Wed, 12 Feb 2014 02:06:00 +0000 (15:06 +1300)
tests/phpunit/CiviTest/CiviUnitTestCase.php
tests/phpunit/api/v3/ActivityTest.php
tests/phpunit/api/v3/ContributionTest.php
tests/phpunit/api/v3/CustomFieldTest.php
tests/phpunit/api/v3/NoteTest.php
tests/phpunit/api/v3/PaymentProcessorTest.php
tests/phpunit/api/v3/PaymentProcessorTypeTest.php
tests/phpunit/api/v3/RelationshipTypeTest.php
tests/phpunit/api/v3/UFJoinTest.php
tests/phpunit/api/v3/UFMatchTest.php
tests/templates/documentFunction.tpl

index 44eeef48abbb22d4544f0da04ea5412e58521fd4..1151b5e2c49e4a590e7cabdca4962c6560761302 100644 (file)
@@ -1916,21 +1916,15 @@ class CiviUnitTestCase extends PHPUnit_Extensions_Database_TestCase {
 
     $smarty->assign('action', $action);
     if (empty($subfile)) {
-      if (file_exists('../tests/templates/documentFunction.tpl')) {
-        $f = fopen("../api/v3/examples/$entity$entityAction.php", "w");
-        fwrite($f, $smarty->fetch('../tests/templates/documentFunction.tpl'));
-        fclose($f);
-      }
+      $subfile = $entityAction;
     }
-    else {
-      if (file_exists('../tests/templates/documentFunction.tpl')) {
-        if (!is_dir("../api/v3/examples/$entity")) {
-          mkdir("../api/v3/examples/$entity");
-        }
-        $f = fopen("../api/v3/examples/$entity/$subfile.php", "w+b");
-        fwrite($f, $smarty->fetch('../tests/templates/documentFunction.tpl'));
-        fclose($f);
+    if (file_exists('../tests/templates/documentFunction.tpl')) {
+      if (!is_dir("../api/v3/examples/$entity")) {
+        mkdir("../api/v3/examples/$entity");
       }
+      $f = fopen("../api/v3/examples/$entity/$subfile.php", "w+b");
+      fwrite($f, $smarty->fetch('../tests/templates/documentFunction.tpl'));
+      fclose($f);
     }
   }
 
index 9603e819883af02bc859651e0998eef95fff1330..5bdc9ecc7e3be72d133f22fb1920ea5b90e16d60 100644 (file)
@@ -354,7 +354,7 @@ class api_v3_ActivityTest extends CiviUnitTestCase {
     /**
      *  Test civicrm_activity_create() using example code
      */
-    require_once 'api/v3/examples/ActivityCreate.php';
+    require_once 'api/v3/examples/Activity/Create.php';
     $result = activity_create_example();
     $expectedResult = activity_create_expectedresult();
     $this->assertEquals($result, $expectedResult);
index df1ccfac77b3406f27214950b0935f62075af19f..5e194923a5b7b42ee8b7d0d47d797bcaa4205201 100644 (file)
@@ -653,7 +653,7 @@ class api_v3_ContributionTest extends CiviUnitTestCase {
     //make sure at least on page exists since there is a truncate in tear down
     $page = $this->callAPISuccess('contribution_page', 'create', $this->_pageParams);
     $this->assertAPISuccess($page);
-    require_once 'api/v3/examples/ContributionCreate.php';
+    require_once 'api/v3/examples/Contribution/Create.php';
     $result         = contribution_create_example();
     $this->assertAPISuccess($result);
     $contributionId = $result['id'];
index 34e039a76fcc39e38cde7ebcd7bf56b7adf4ba50..d5eda71266006ca5797f694204aff107a984571b 100644 (file)
@@ -203,7 +203,7 @@ class api_v3_CustomFieldTest extends CiviUnitTestCase {
 
 
         $customGroup = $this->customGroupCreate('Individual','date_test_group',3);
-        require_once 'api/v3/examples/CustomFieldCreate.php';
+        require_once 'api/v3/examples/CustomField/Create.php';
         $result = custom_field_create_example();
         $expectedResult = custom_field_create_expectedresult();
         $this->assertEquals($result,$expectedResult);
index c483bdc5a2d4f4889133d62c31673268125c0122..4879b290b80a181b0a280ba5cd30cb82f4838211 100644 (file)
@@ -279,7 +279,7 @@ class api_v3_NoteTest extends CiviUnitTestCase {
  *  Test civicrm_activity_create() using example code
  */
 function testNoteCreateExample() {
-  require_once 'api/v3/examples/NoteCreate.php';
+  require_once 'api/v3/examples/Note/Create.php';
   $result = UF_match_get_example();
   $expectedResult = UF_match_get_expectedresult();
   $this->assertEquals($result, $expectedResult);
index 19c0b1db68e797bc551c2ff014da137e345c8271..92d710e3f257a251f27c88e0a73171e336149cc0 100644 (file)
@@ -103,7 +103,7 @@ class api_v3_PaymentProcessorTest extends CiviUnitTestCase {
    * Test  using example code
    */
   function testPaymentProcessorCreateExample() {
-    require_once 'api/v3/examples/PaymentProcessorCreate.php';
+    require_once 'api/v3/examples/PaymentProcessor/Create.php';
     $result = payment_processor_create_example();
     $expectedResult = payment_processor_create_expectedresult();
     $this->assertAPISuccess($result);
index b18e82ab7a0bfe9b51711bbee0c49daac0a46ac9..6f0cf5b6bed75d9c754772efaf70411099662df6 100644 (file)
@@ -96,7 +96,7 @@ class api_v3_PaymentProcessorTypeTest extends CiviUnitTestCase {
    *  Test  using example code
    */
   function testPaymentProcessorTypeCreateExample() {
-    require_once 'api/v3/examples/PaymentProcessorTypeCreate.php';
+    require_once 'api/v3/examples/PaymentProcessorType/Create.php';
     $result = payment_processor_type_create_example();
     $expectedResult = payment_processor_type_create_expectedresult();
     $this->assertAPISuccess($result);
index 3f2912c1e08f9f42d340ad9af7a03696190f88ab..4d083e7b76834584b1abad9b3e3f82b30ac06d42 100644 (file)
@@ -140,7 +140,7 @@ class api_v3_RelationshipTypeTest extends CiviUnitTestCase {
    *  Test  using example code
    */
   function testRelationshipTypeCreateExample() {
-    require_once 'api/v3/examples/RelationshipTypeCreate.php';
+    require_once 'api/v3/examples/RelationshipType/Create.php';
     $result = relationship_type_create_example();
     $expectedResult = relationship_type_create_expectedresult();
     $this->assertAPISuccess($result);
index 7b97e43d1fee7295333a6db569a33c7eb074bcc6..4a6fb708a156aa03991895bc20c1104a0e77508f 100644 (file)
@@ -254,7 +254,7 @@ class api_v3_UFJoinTest extends CiviUnitTestCase {
    *  Test civicrm_activity_create() using example code
    */
   function testUFJoinCreateExample() {
-    require_once 'api/v3/examples/UFJoinCreate.php';
+    require_once 'api/v3/examples/UFJoin/Create.php';
     $result = UF_join_create_example();
     $expectedResult = UF_join_create_expectedresult();
     $this->assertEquals($result, $expectedResult);
index 0599f586a818c5c2bdf5f47dc50c4a5c31b24b57..c2ce8f3ecfd2449caad11984ffd04a7d6af418fb 100644 (file)
@@ -122,7 +122,7 @@ class api_v3_UFMatchTest extends CiviUnitTestCase {
    *  Test civicrm_activity_create() using example code
    */
   function testUFMatchGetExample() {
-    require_once 'api/v3/examples/UFMatchGet.php';
+    require_once 'api/v3/examples/UFMatch/Get.php';
     $result = UF_match_get_example();
     $expectedResult = UF_match_get_expectedresult();
     $this->assertEquals($result, $expectedResult);
index a13d722fa9a23d4708315f293654232fdce23d35..217bb6ff279d357311142aa4d79cdb59c9181cf5 100644 (file)
@@ -36,16 +36,16 @@ function {$function}_expectedresult(){literal}{{/literal}
 * This example has been generated from the API test suite. The test that created it is called
 *
 * {$testfunction} and can be found in
-* http://svn.civicrm.org/civicrm/trunk/tests/phpunit/CiviTest/api/v3/{$filename}
+* https://github.com/civicrm/civicrm-core/blob/master/tests/phpunit/api/v3/{$filename}
 *
 * You can see the outcome of the API tests at
-* http://tests.dev.civicrm.org/trunk/results-api_v3
+* https://test.civicrm.org/job/CiviCRM-master-git/
 *
 * To Learn about the API read
-* http://book.civicrm.org/developer/current/techniques/api/
+* http://wiki.civicrm.org/confluence/display/CRMDOC/Using+the+API
 *
-* and review the wiki at
-* http://wiki.civicrm.org/confluence/display/CRMDOC/CiviCRM+Public+APIs
+* Browse the api on your own site with the api explorer
+* http://MYSITE.ORG/path/to/civicrm/api/explorer
 *
 * Read more about testing here
 * http://wiki.civicrm.org/confluence/display/CRM/Testing