From 3ec6e38dc05990db0f98aa17b3a8d5271c5e30ab Mon Sep 17 00:00:00 2001 From: Coleman Watts Date: Mon, 10 Feb 2014 21:15:40 -0800 Subject: [PATCH] Reorganize and update api examples --- tests/phpunit/CiviTest/CiviUnitTestCase.php | 20 +++++++------------ tests/phpunit/api/v3/ActivityTest.php | 2 +- tests/phpunit/api/v3/ContributionTest.php | 2 +- tests/phpunit/api/v3/CustomFieldTest.php | 2 +- tests/phpunit/api/v3/NoteTest.php | 2 +- tests/phpunit/api/v3/PaymentProcessorTest.php | 2 +- .../api/v3/PaymentProcessorTypeTest.php | 2 +- tests/phpunit/api/v3/RelationshipTypeTest.php | 2 +- tests/phpunit/api/v3/UFJoinTest.php | 2 +- tests/phpunit/api/v3/UFMatchTest.php | 2 +- tests/templates/documentFunction.tpl | 10 +++++----- 11 files changed, 21 insertions(+), 27 deletions(-) diff --git a/tests/phpunit/CiviTest/CiviUnitTestCase.php b/tests/phpunit/CiviTest/CiviUnitTestCase.php index 44eeef48ab..1151b5e2c4 100644 --- a/tests/phpunit/CiviTest/CiviUnitTestCase.php +++ b/tests/phpunit/CiviTest/CiviUnitTestCase.php @@ -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); } } diff --git a/tests/phpunit/api/v3/ActivityTest.php b/tests/phpunit/api/v3/ActivityTest.php index 9603e81988..5bdc9ecc7e 100644 --- a/tests/phpunit/api/v3/ActivityTest.php +++ b/tests/phpunit/api/v3/ActivityTest.php @@ -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); diff --git a/tests/phpunit/api/v3/ContributionTest.php b/tests/phpunit/api/v3/ContributionTest.php index df1ccfac77..5e194923a5 100644 --- a/tests/phpunit/api/v3/ContributionTest.php +++ b/tests/phpunit/api/v3/ContributionTest.php @@ -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']; diff --git a/tests/phpunit/api/v3/CustomFieldTest.php b/tests/phpunit/api/v3/CustomFieldTest.php index 34e039a76f..d5eda71266 100644 --- a/tests/phpunit/api/v3/CustomFieldTest.php +++ b/tests/phpunit/api/v3/CustomFieldTest.php @@ -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); diff --git a/tests/phpunit/api/v3/NoteTest.php b/tests/phpunit/api/v3/NoteTest.php index c483bdc5a2..4879b290b8 100644 --- a/tests/phpunit/api/v3/NoteTest.php +++ b/tests/phpunit/api/v3/NoteTest.php @@ -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); diff --git a/tests/phpunit/api/v3/PaymentProcessorTest.php b/tests/phpunit/api/v3/PaymentProcessorTest.php index 19c0b1db68..92d710e3f2 100644 --- a/tests/phpunit/api/v3/PaymentProcessorTest.php +++ b/tests/phpunit/api/v3/PaymentProcessorTest.php @@ -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); diff --git a/tests/phpunit/api/v3/PaymentProcessorTypeTest.php b/tests/phpunit/api/v3/PaymentProcessorTypeTest.php index b18e82ab7a..6f0cf5b6be 100644 --- a/tests/phpunit/api/v3/PaymentProcessorTypeTest.php +++ b/tests/phpunit/api/v3/PaymentProcessorTypeTest.php @@ -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); diff --git a/tests/phpunit/api/v3/RelationshipTypeTest.php b/tests/phpunit/api/v3/RelationshipTypeTest.php index 3f2912c1e0..4d083e7b76 100644 --- a/tests/phpunit/api/v3/RelationshipTypeTest.php +++ b/tests/phpunit/api/v3/RelationshipTypeTest.php @@ -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); diff --git a/tests/phpunit/api/v3/UFJoinTest.php b/tests/phpunit/api/v3/UFJoinTest.php index 7b97e43d1f..4a6fb708a1 100644 --- a/tests/phpunit/api/v3/UFJoinTest.php +++ b/tests/phpunit/api/v3/UFJoinTest.php @@ -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); diff --git a/tests/phpunit/api/v3/UFMatchTest.php b/tests/phpunit/api/v3/UFMatchTest.php index 0599f586a8..c2ce8f3ecf 100644 --- a/tests/phpunit/api/v3/UFMatchTest.php +++ b/tests/phpunit/api/v3/UFMatchTest.php @@ -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); diff --git a/tests/templates/documentFunction.tpl b/tests/templates/documentFunction.tpl index a13d722fa9..217bb6ff27 100644 --- a/tests/templates/documentFunction.tpl +++ b/tests/templates/documentFunction.tpl @@ -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 -- 2.25.1