CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion »
  • APIs and Hooks (Moderator: Donald Lobo) »
  • Contribution: unit test for 2.1 api/Membership.php
Pages: [1]

Author Topic: Contribution: unit test for 2.1 api/Membership.php  (Read 1836 times)

dharmatech

  • I post frequently
  • ***
  • Posts: 280
  • Karma: 53
    • dharmatech.org
Contribution: unit test for 2.1 api/Membership.php
January 07, 2009, 11:02:43 am
This test uses Simpletest to exercise (all but one of) the functions implemented in CiviCRM 2.1 api/Membership.php.  It runs well under Drupal 6 simpletest module 6.x-1.2 so presumably will work with the test code in the packages/ directory.

Notice that the way this test works is a little less constrained than most of the tests in the tests/ directory in the repository.  Specifically, it has no requirements for the existing contents of the database.  All the data used in the test is generated during test execution and deleted at the end of the test.  This test also follows the Drupal simpletest convention of creating only data names that begin simpletest_  with a randomly-generated part that reduces the chance of a name collision in the generated test data.  At completion of the test all generated data is cleaned up, it says here theoretically  ;)  If any test data remains in the database, it's easy to identify by its unusual name.  Personally I believe this is the best way to write tests, since it makes the test easier to use and therefore more like to be used.

To use this test, rename the attached file to Membership.test, drop it into the tests/api/ directory, then run it using either the Drupal 6 simpletest integration module that I posted to the main developer forum, or the usual CiviCRM regression test procedure.

-- Walt
 
« Last Edit: January 07, 2009, 11:04:51 am by dharmatech »
http://dharmatech.org
oss@dharmatech.org
801.541.8671

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion »
  • APIs and Hooks (Moderator: Donald Lobo) »
  • Contribution: unit test for 2.1 api/Membership.php

This forum was archived on 2017-11-26.