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 »
  • Unit Testing (Moderator: Michał Mach) »
  • Custom templates directory for unit testing
Pages: [1]

Author Topic: Custom templates directory for unit testing  (Read 4467 times)

demeritcowboy

  • Ask me questions
  • ****
  • Posts: 570
  • Karma: 42
  • CiviCRM version: Always the latest!
  • CMS version: Drupal 6 mostly, still evaluating 7.
  • MySQL version: Mix of 5.0 / 5.1 / 5.5
  • PHP version: 5.3, usually on Windows
Custom templates directory for unit testing
September 09, 2011, 11:31:10 am
CiviCase requires (for now anyway) a custom templates folder to put the case type xml files in, so unit tests fail since there is no such thing in that environment.

I'm planning to just stick one in the tests/phpunit folder and put the civicase sample files in there, and then add a function to the base clase that turns this custom directory on and off (it justs sets config->customTemplateDir to this folder, like visiting the admin settings page).

Let me know if you think this is a bad idea.

totten

  • Administrator
  • Ask me questions
  • *****
  • Posts: 695
  • Karma: 64
Re: Custom templates directory for unit testing
September 10, 2011, 10:20:37 pm
Fwiw, I had a similar issue while unit testing CRM-8797 and did something similar. (Dumped some mock files in tests/phpunit/apiv3/dataset/resolver and then referenced them in https://fisheye2.atlassian.com/viewrep/CiviCRM/branches/v3.4/tests/phpunit/api/v3/APITest.php?r1=35050&r2=36015 ).

The technique of putting some helpers in the base class sounds good - eg that makes it easier to write a teardown function that cleans up properly. (r36015's testAPIResolver feels a little lazy/ugly on that front, but I may be hypersensitive.)

It feels right to anticipate using different fixtures for different test cases - that's why the fixtures in r36015 are buried down in dataset/resolver.

There's a design consideration with modifying the config variable -- is the modified variable written to db? If you're writing a WebTest, then you need to save to db; otoh, if you save to db, then it's not safe to execute multiple tests concurrently. I don't know if either of those actually matters in this case, but it's worth noting.

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion »
  • Unit Testing (Moderator: Michał Mach) »
  • Custom templates directory for unit testing

This forum was archived on 2017-11-26.