Skip to content

Instantly share code, notes, and snippets.

@ErichBSchulz
Created February 3, 2017 13:23
Show Gist options
  • Save ErichBSchulz/ed1a9d9d4a24cb412e2e1d9431a9a112 to your computer and use it in GitHub Desktop.
Save ErichBSchulz/ed1a9d9d4a24cb412e2e1d9431a9a112 to your computer and use it in GitHub Desktop.
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',
'domain_id' => 1,
'title' => 'New Test Group Created',
'description' => 'New Test Group Created',
'is_active' => 1,
'visibility' => 'Public Pages',
'group_type' => array(
'1' => 1,
'2' => 1,
)
);
break;
case ....
etc
default:
throw new Exception('bad test entity');
}
return array_merge($defaults, $params['overrides']);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment