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) »
  • CRM_Core_DAO::createTestObject refactored
Pages: [1]

Author Topic: CRM_Core_DAO::createTestObject refactored  (Read 701 times)

totten

  • Administrator
  • Ask me questions
  • *****
  • Posts: 695
  • Karma: 64
CRM_Core_DAO::createTestObject refactored
August 26, 2014, 07:09:21 pm
The CaseType API added in 4.5 has been failing in the SyntaxConformanceTest for a while. The root of the problem: SyntaxConformanceTest calls createTestObject() to generate sample data, but createTestObject() was unable to produce valid sample data for CaseType. (Specifically, civicrm_case_type.definition must be an XML string -- and createTestObject would put in an arbitrary string.)

createTestObject() grew... a bit difficult to read. It had several hacks to handle specific fields/entities. I've refactored it so that we can use OOP techniques (polymorphism) to customize the test-data. Now, createTestObject() calls $bao->assignTestValue($fieldName, $fieldDef). The default implementation in CRM_Core_DAO->assignTestValue() uses the old logic, but you can override it for specific BAOs. For an example, see CRM_Case_BAO_CaseType->assignTestValue().

PR: https://github.com/civicrm/civicrm-core/pull/3963

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion »
  • Unit Testing (Moderator: Michał Mach) »
  • CRM_Core_DAO::createTestObject refactored

This forum was archived on 2017-11-26.