Skip to content

Instantly share code, notes, and snippets.

@ErichBSchulz
ErichBSchulz / TestSubjectFactory.php
Created February 3, 2017 13:23
refactor of CiviUnitTestCase
class TestSubjectFactory {
public static function testArray($params) {
$params = array_merge(array(
'overrides' => array(),
), $params);
switch ($params['entity']) {
case 'group':
$defaults = array(
'name' => 'Test Group 1',
@ErichBSchulz
ErichBSchulz / backbone_crm.js
Created May 27, 2013 11:57
Bridge between backbonejs models (and collections) and the CiviCRM CRM.api
var CRMModel = Backbone.Model.extend({
// redirect sync to custom method
sync: this.crmSync,
// Custom bridge to V3 civicrm API
crmSync: function(method, model, options) {
// make a shallow copy of options ? uneccesary but seems safest??
var params = _.clone(options);
// look up this models enity (as either method or property)
var entity = _.result(this, 'entity');
var action = ''; // is there a good value to pass the api to throw error?
@ErichBSchulz
ErichBSchulz / test.txt
Created August 3, 2011 09:31
test cases
Plan for testing:
- insert contact A
- insert contact B
- read contact B -> get contact B
- automerge (A, B) -> get expected SUCCESS result
- read contact B -> get nothing back
- read contact A -> get back merged A and B, store as $A
- insert contact C (different in some important way from A)