/** * Test various relations to get full coverage on resolveModelClassName() * @depends testMakeRecipientsForAHasOneRelation */ public function testGetDynamicUserTypesAndLabels() { $form = new DynamicTriggeredModelRelationUserWorkflowEmailMessageRecipientForm('WorkflowModelTestItem', Workflow::TYPE_ON_SAVE); $form->relation = 'hasOne'; $this->assertEquals(6, count($form->getDynamicUserTypesAndLabels())); $form = new DynamicTriggeredModelRelationUserWorkflowEmailMessageRecipientForm('WorkflowModelTestItem5', Workflow::TYPE_ON_SAVE); $form->relation = 'WorkflowModelTestItem__workflowItems__Inferred'; $this->assertEquals(6, count($form->getDynamicUserTypesAndLabels())); $form = new DynamicTriggeredModelRelationUserWorkflowEmailMessageRecipientForm('WorkflowModelTestItem', Workflow::TYPE_ON_SAVE); $form->relation = 'model5ViaItem'; $this->assertEquals(6, count($form->getDynamicUserTypesAndLabels())); }
/** * @param string $modelClassName * @param string $workflowType * @return array */ public static function getTypeValuesAndLabels($modelClassName, $workflowType) { assert('is_string($modelClassName)'); assert('is_string($workflowType)'); $data = array(); $data[static::TYPE_DYNAMIC_TRIGGERED_MODEL_USER] = DynamicTriggeredModelUserWorkflowEmailMessageRecipientForm::getTypeLabel(); $data[static::TYPE_DYNAMIC_TRIGGERED_MODEL_RELATION_USER] = DynamicTriggeredModelRelationUserWorkflowEmailMessageRecipientForm::getTypeLabel(); $data[static::TYPE_STATIC_ROLE] = StaticRoleWorkflowEmailMessageRecipientForm::getTypeLabel(); $data[static::TYPE_DYNAMIC_TRIGGERED_BY_USER] = DynamicTriggeredByUserWorkflowEmailMessageRecipientForm::getTypeLabel(); $data[static::TYPE_STATIC_USER] = StaticUserWorkflowEmailMessageRecipientForm::getTypeLabel(); $data[static::TYPE_STATIC_ADDRESS] = StaticAddressWorkflowEmailMessageRecipientForm::getTypeLabel(); $data[static::TYPE_STATIC_GROUP] = StaticGroupWorkflowEmailMessageRecipientForm::getTypeLabel(); if (is_subclass_of($modelClassName, 'Contact') || $modelClassName == 'Contact') { $data[static::TYPE_DYNAMIC_TRIGGERED_MODEL] = DynamicTriggeredModelWorkflowEmailMessageRecipientForm::getTypeLabel(); } $form = new DynamicTriggeredModelRelationWorkflowEmailMessageRecipientForm($modelClassName, $workflowType); $relationValuesAndLabels = $form->getRelationValuesAndLabels(); if (!empty($relationValuesAndLabels)) { $data[static::TYPE_DYNAMIC_TRIGGERED_MODEL_RELATION] = DynamicTriggeredModelRelationWorkflowEmailMessageRecipientForm::getTypeLabel(); } return $data; }