39 public static function setUpBeforeClass()
41 parent::setUpBeforeClass();
43 UserTestHelper::createBasicUser(
'bobby');
47 public function testResolveOnSaveWorkflowByWizardPostData()
50 $workflow->setType(Workflow::TYPE_ON_SAVE);
52 $data[
'OnSaveWorkflowWizardForm'] = array(
'description' =>
'someDescription',
55 'triggerOn' => Workflow::TRIGGER_ON_NEW,
56 'triggersStructure' =>
'1 AND 2',
57 'moduleClassName' =>
'WorkflowsTestModule');
59 $this->assertEquals(
'someDescription', $workflow->getDescription());
60 $this->assertTrue($workflow->getIsActive());
61 $this->assertEquals(
'someName', $workflow->getName());
62 $this->assertEquals(Workflow::TRIGGER_ON_NEW, $workflow->getTriggerOn());
63 $this->assertEquals(
'1 AND 2', $workflow->getTriggersStructure());
64 $this->assertEquals(
'WorkflowsTestModule', $workflow->getModuleClassName());
68 $workflow->setType(Workflow::TYPE_ON_SAVE);
70 $data[
'OnSaveWorkflowWizardForm'] = array(
'description' =>
'someDescription',
73 'triggerOn' => Workflow::TRIGGER_ON_NEW,
74 'triggersStructure' =>
'1 AND 2',
75 'moduleClassName' =>
'WorkflowsTestModule');
77 $this->assertFalse($workflow->getIsActive());
86 $workflow->setType(Workflow::TYPE_ON_SAVE);
87 $workflow->setModuleClassName(
'WorkflowsTestModule');
91 'valueType' =>
'Between',
92 'value' =>
'2/24/2012',
93 'secondValue' =>
'2/28/2012');
95 'operator' => OperatorRules::TYPE_EQUALS,
96 'value' =>
'something');
98 $triggers = $workflow->getTriggers();
99 $this->assertCount(2, $triggers);
100 $this->assertEquals(
'2012-02-24', $triggers[0]->value);
101 $this->assertEquals(
'Between', $triggers[0]->valueType);
102 $this->assertEquals(
'2012-02-28', $triggers[0]->secondValue);
103 $this->assertEquals(
'something', $triggers[1]->value);
104 $this->assertEquals(OperatorRules::TYPE_EQUALS, $triggers[1]->
operator);
108 $workflow->setType(Workflow::TYPE_ON_SAVE);
109 $workflow->setModuleClassName(
'WorkflowsTestModule');
110 $trigger =
new TriggerForWorkflowForm(
'WorkflowsTestModule',
'WorkflowModelTestItem', Workflow::TYPE_ON_SAVE);
111 $workflow->addTrigger($trigger);
112 $triggers = $workflow->getTriggers();
113 $this->assertCount(1, $triggers);
117 $triggers = $workflow->getTriggers();
118 $this->assertCount(0, $triggers);
127 $workflow->setType(Workflow::TYPE_BY_TIME);
128 $workflow->setModuleClassName(
'WorkflowsTestModule');
131 'operator' => OperatorRules::TYPE_EQUALS,
133 'durationInterval' =>
'10',
134 'durationSign' => TimeDurationUtil::DURATION_SIGN_NEGATIVE,
135 'durationType' => TimeDurationUtil::DURATION_TYPE_WEEK);
137 $trigger = $workflow->getTimeTrigger();
138 $this->assertEquals(
'514', $trigger->value);
139 $this->assertEquals(
'10', $trigger->durationInterval);
140 $this->assertEquals(TimeDurationUtil::DURATION_SIGN_NEGATIVE, $trigger->durationSign);
141 $this->assertEquals(TimeDurationUtil::DURATION_TYPE_WEEK, $trigger->durationType);
142 $this->assertEquals(OperatorRules::TYPE_EQUALS, $trigger->operator);
151 $workflow->setType(Workflow::TYPE_ON_SAVE);
152 $workflow->setModuleClassName(
'WorkflowsTestModule');
156 'valueType' =>
'Between',
157 'value' =>
'2/24/2012',
158 'secondValue' =>
'2/28/2012');
160 $triggers = $workflow->getTriggers();
161 $this->assertCount(1, $triggers);
162 $this->assertEquals(
'2012-02-24', $triggers[0]->value);
163 $this->assertEquals(
'Between', $triggers[0]->valueType);
164 $this->assertEquals(
'2012-02-28', $triggers[0]->secondValue);
173 $triggersData = array();
174 $triggersData[0] = array(
'attributeIndexOrDerivedType' =>
'date',
'value' =>
'2/24/2012');
175 $triggersData[1] = array(
'attributeIndexOrDerivedType' =>
'dateTime',
'value' =>
'2/25/2012');
176 $triggersData[2] = array(
'attributeIndexOrDerivedType' =>
'date',
'value' =>
'2/24/2012',
177 'secondValue' =>
'2/28/2012');
179 Workflow::TYPE_ON_SAVE, $triggersData);
180 $this->assertEquals(
'2012-02-24', $sanitizedTriggerData[0][
'value']);
181 $this->assertEquals(
'2012-02-25', $sanitizedTriggerData[1][
'value']);
182 $this->assertEquals(
'2012-02-24', $sanitizedTriggerData[2][
'value']);
183 $this->assertEquals(
'2012-02-28', $sanitizedTriggerData[2][
'secondValue']);
192 $this->assertTrue($contactStates[0]->
id > 0);
193 $contactState = $contactStates[0];
197 $workflow->setType(Workflow::TYPE_ON_SAVE);
198 $workflow->setModuleClassName(
'WorkflowsTestModule');
203 'boolean' => array(
'shouldSetValue' =>
'1',
204 'type' => WorkflowActionAttributeForm::TYPE_STATIC,
206 'boolean2' => array(
'shouldSetValue' =>
'1',
207 'type' => WorkflowActionAttributeForm::TYPE_STATIC,
209 'currencyValue' => array(
'shouldSetValue' =>
'1',
210 'type' => WorkflowActionAttributeForm::TYPE_STATIC,
212 'currencyId' => $currency->id),
213 'date' => array(
'shouldSetValue' =>
'1',
214 'type' => WorkflowActionAttributeForm::TYPE_STATIC,
215 'value' =>
'2/24/2012'),
216 'dateTime' => array(
'shouldSetValue' =>
'1',
217 'type' => WorkflowActionAttributeForm::TYPE_STATIC,
218 'value' =>
'2/24/2012 03:00 AM'),
219 'dropDown' => array(
'shouldSetValue' =>
'1',
220 'type' => WorkflowActionAttributeForm::TYPE_STATIC,
221 'value' =>
'Value 1'),
222 'float' => array(
'shouldSetValue' =>
'1',
223 'type' => WorkflowActionAttributeForm::TYPE_STATIC,
225 'integer' => array(
'shouldSetValue' =>
'1',
226 'type' => WorkflowActionAttributeForm::TYPE_STATIC,
228 'likeContactState' => array(
'shouldSetValue' =>
'1',
229 'type' => WorkflowActionAttributeForm::TYPE_STATIC,
230 'value' => $contactState->id),
231 'multiDropDown' => array(
'shouldSetValue' =>
'1',
232 'type' => WorkflowActionAttributeForm::TYPE_STATIC,
233 'value' => array(
'Multi Value 1',
'Multi Value 2')),
234 'owner' => array(
'shouldSetValue' =>
'1',
235 'type' => WorkflowActionAttributeForm::TYPE_STATIC,
236 'value' => $bobby->id),
237 'phone' => array(
'shouldSetValue' =>
'1',
238 'type' => WorkflowActionAttributeForm::TYPE_STATIC,
239 'value' =>
'8471112222'),
240 'primaryAddress___street1' => array(
'shouldSetValue' =>
'1',
241 'type' => WorkflowActionAttributeForm::TYPE_STATIC,
242 'value' =>
'123 Main Street'),
243 'primaryEmail___emailAddress' => array(
'shouldSetValue' =>
'1',
244 'type' => WorkflowActionAttributeForm::TYPE_STATIC,
245 'value' =>
'info@zurmo.com'),
246 'radioDropDown' => array(
'shouldSetValue' =>
'1',
247 'type' => WorkflowActionAttributeForm::TYPE_STATIC,
248 'value' =>
'Radio Value 1'),
249 'string' => array(
'shouldSetValue' =>
'1',
250 'type' => WorkflowActionAttributeForm::TYPE_STATIC,
252 'tagCloud' => array(
'shouldSetValue' =>
'1',
253 'type' => WorkflowActionAttributeForm::TYPE_STATIC,
254 'value' => array(
'Tag Value 1',
'Tag Value 2')),
255 'textArea' => array(
'shouldSetValue' =>
'1',
256 'type' => WorkflowActionAttributeForm::TYPE_STATIC,
257 'value' =>
'some description'),
258 'url' => array(
'shouldSetValue' =>
'1',
259 'type' => WorkflowActionAttributeForm::TYPE_STATIC,
260 'value' =>
'http://www.zurmo.com'),
264 $actions = $workflow->getActions();
265 $this->assertCount(1, $actions);
267 $this->assertEquals(19, $actions[0]->getActionAttributeFormsCount());
270 $this->assertEquals(
'Static', $actions[0]->getActionAttributeFormByName(
'boolean')->type);
271 $this->assertEquals(
'1', $actions[0]->getActionAttributeFormByName(
'boolean')->value);
273 $this->assertTrue($actions[0]->getActionAttributeFormByName(
'boolean2') instanceof CheckBoxWorkflowActionAttributeForm);
274 $this->assertEquals(
'Static', $actions[0]->getActionAttributeFormByName(
'boolean2')->type);
275 $this->assertEquals(
'0', $actions[0]->getActionAttributeFormByName(
'boolean2')->value);
278 $this->assertEquals(
'Static', $actions[0]->getActionAttributeFormByName(
'currencyValue')->type);
279 $this->assertEquals(362.24, $actions[0]->getActionAttributeFormByName(
'currencyValue')->value);
280 $this->assertEquals($currency->id, $actions[0]->getActionAttributeFormByName(
'currencyValue')->currencyId);
281 $this->assertEquals(
'Static', $actions[0]->getActionAttributeFormByName(
'currencyValue')->currencyIdType);
284 $this->assertEquals(
'Static', $actions[0]->getActionAttributeFormByName(
'date')->type);
285 $this->assertEquals(
'2012-02-24', $actions[0]->getActionAttributeFormByName(
'date')->value);
288 $this->assertEquals(
'Static', $actions[0]->getActionAttributeFormByName(
'dateTime')->type);
290 $this->assertEquals($compareDateTime, $actions[0]->getActionAttributeFormByName(
'dateTime')->value);
293 $this->assertEquals(
'Static', $actions[0]->getActionAttributeFormByName(
'dropDown')->type);
294 $this->assertEquals(
'Value 1', $actions[0]->getActionAttributeFormByName(
'dropDown')->value);
297 $this->assertEquals(
'Static', $actions[0]->getActionAttributeFormByName(
'float')->type);
298 $this->assertEquals(
'54.25', $actions[0]->getActionAttributeFormByName(
'float')->value);
301 $this->assertEquals(
'Static', $actions[0]->getActionAttributeFormByName(
'integer')->type);
302 $this->assertEquals(
'32', $actions[0]->getActionAttributeFormByName(
'integer')->value);
305 $this->assertEquals(
'Static', $actions[0]->getActionAttributeFormByName(
'likeContactState')->type);
306 $this->assertEquals($contactState->id, $actions[0]->getActionAttributeFormByName(
'likeContactState')->value);
309 $this->assertEquals(
'Static', $actions[0]->getActionAttributeFormByName(
'multiDropDown')->type);
310 $this->assertEquals(array(
'Multi Value 1',
'Multi Value 2'), $actions[0]->getActionAttributeFormByName(
'multiDropDown')->value);
313 $this->assertEquals(
'Static', $actions[0]->getActionAttributeFormByName(
'owner')->type);
314 $this->assertEquals($bobby->id, $actions[0]->getActionAttributeFormByName(
'owner')->value);
317 $this->assertEquals(
'Static', $actions[0]->getActionAttributeFormByName(
'phone')->type);
318 $this->assertEquals(
'8471112222', $actions[0]->getActionAttributeFormByName(
'phone')->value);
321 $this->assertEquals(
'Static', $actions[0]->getActionAttributeFormByName(
'primaryAddress___street1')->type);
322 $this->assertEquals(
'123 Main Street', $actions[0]->getActionAttributeFormByName(
'primaryAddress___street1')->value);
325 $this->assertEquals(
'Static', $actions[0]->getActionAttributeFormByName(
'primaryEmail___emailAddress')->type);
326 $this->assertEquals(
'info@zurmo.com', $actions[0]->getActionAttributeFormByName(
'primaryEmail___emailAddress')->value);
329 $this->assertEquals(
'Static', $actions[0]->getActionAttributeFormByName(
'radioDropDown')->type);
330 $this->assertEquals(
'Radio Value 1', $actions[0]->getActionAttributeFormByName(
'radioDropDown')->value);
332 $this->assertTrue($actions[0]->getActionAttributeFormByName(
'string') instanceof TextWorkflowActionAttributeForm);
333 $this->assertEquals(
'Static', $actions[0]->getActionAttributeFormByName(
'string')->type);
334 $this->assertEquals(
'jason', $actions[0]->getActionAttributeFormByName(
'string')->value);
337 $this->assertEquals(
'Static', $actions[0]->getActionAttributeFormByName(
'tagCloud')->type);
338 $this->assertEquals(array(
'Tag Value 1',
'Tag Value 2'), $actions[0]->getActionAttributeFormByName(
'tagCloud')->value);
341 $this->assertEquals(
'Static', $actions[0]->getActionAttributeFormByName(
'textArea')->type);
342 $this->assertEquals(
'some description', $actions[0]->getActionAttributeFormByName(
'textArea')->value);
345 $this->assertEquals(
'Static', $actions[0]->getActionAttributeFormByName(
'url')->type);
346 $this->assertEquals(
'http://www.zurmo.com', $actions[0]->getActionAttributeFormByName(
'url')->value);
356 $workflow->setType(Workflow::TYPE_ON_SAVE);
357 $workflow->setModuleClassName(
'WorkflowsTestModule');
362 'date' => array(
'shouldSetValue' =>
'1',
363 'type' => DateWorkflowActionAttributeForm::TYPE_DYNAMIC_FROM_TRIGGERED_DATE,
364 'value' =>
'-86400'),
365 'date2' => array(
'shouldSetValue' =>
'1',
366 'type' => DateWorkflowActionAttributeForm::TYPE_DYNAMIC_FROM_TRIGGERED_DATE,
368 'date3' => array(
'shouldSetValue' =>
'1',
369 'type' => DateWorkflowActionAttributeForm::TYPE_DYNAMIC_FROM_EXISTING_DATE,
370 'value' =>
'-86400'),
371 'date4' => array(
'shouldSetValue' =>
'1',
372 'type' => DateWorkflowActionAttributeForm::TYPE_DYNAMIC_FROM_EXISTING_DATE,
374 'dateTime' => array(
'shouldSetValue' =>
'1',
375 'type' => DateTimeWorkflowActionAttributeForm::TYPE_DYNAMIC_FROM_TRIGGERED_DATETIME,
377 'dateTime2' => array(
'shouldSetValue' =>
'1',
378 'type' => DateTimeWorkflowActionAttributeForm::TYPE_DYNAMIC_FROM_TRIGGERED_DATETIME,
380 'dateTime3' => array(
'shouldSetValue' =>
'1',
381 'type' => DateTimeWorkflowActionAttributeForm::TYPE_DYNAMIC_FROM_EXISTING_DATETIME,
383 'dateTime4' => array(
'shouldSetValue' =>
'1',
384 'type' => DateTimeWorkflowActionAttributeForm::TYPE_DYNAMIC_FROM_EXISTING_DATETIME,
386 'dropDown' => array(
'shouldSetValue' =>
'1',
389 'owner' => array(
'shouldSetValue' =>
'1',
390 'type' => UserWorkflowActionAttributeForm::TYPE_DYNAMIC_CREATED_BY_USER),
391 'radioDropDown' => array(
'shouldSetValue' =>
'1',
394 'user' => array(
'shouldSetValue' =>
'1',
395 'type' => UserWorkflowActionAttributeForm::TYPE_DYNAMIC_MODIFIED_BY_USER),
396 'user2' => array(
'shouldSetValue' =>
'1',
397 'type' => UserWorkflowActionAttributeForm::TYPE_DYNAMIC_TRIGGERED_BY_USER),
400 $actions = $workflow->getActions();
401 $this->assertCount(1, $actions);
403 $this->assertEquals(13, $actions[0]->getActionAttributeFormsCount());
406 $this->assertEquals(
'DynamicFromTriggeredDate', $actions[0]->getActionAttributeFormByName(
'date')->type);
407 $this->assertEquals(-86400, $actions[0]->getActionAttributeFormByName(
'date')->value);
408 $this->assertTrue($actions[0]->getActionAttributeFormByName(
'date2') instanceof DateWorkflowActionAttributeForm);
409 $this->assertEquals(
'DynamicFromTriggeredDate', $actions[0]->getActionAttributeFormByName(
'date2')->type);
410 $this->assertEquals(86400, $actions[0]->getActionAttributeFormByName(
'date2')->value);
411 $this->assertTrue($actions[0]->getActionAttributeFormByName(
'date3') instanceof DateWorkflowActionAttributeForm);
412 $this->assertEquals(
'DynamicFromExistingDate', $actions[0]->getActionAttributeFormByName(
'date3')->type);
413 $this->assertEquals(-86400, $actions[0]->getActionAttributeFormByName(
'date3')->value);
414 $this->assertTrue($actions[0]->getActionAttributeFormByName(
'date4') instanceof DateWorkflowActionAttributeForm);
415 $this->assertEquals(
'DynamicFromExistingDate', $actions[0]->getActionAttributeFormByName(
'date4')->type);
416 $this->assertEquals(86400, $actions[0]->getActionAttributeFormByName(
'date4')->value);
419 $this->assertEquals(
'DynamicFromTriggeredDateTime', $actions[0]->getActionAttributeFormByName(
'dateTime')->type);
420 $this->assertEquals(-3600, $actions[0]->getActionAttributeFormByName(
'dateTime')->value);
421 $this->assertTrue($actions[0]->getActionAttributeFormByName(
'dateTime2') instanceof DateTimeWorkflowActionAttributeForm);
422 $this->assertEquals(
'DynamicFromTriggeredDateTime', $actions[0]->getActionAttributeFormByName(
'dateTime2')->type);
423 $this->assertEquals(3600, $actions[0]->getActionAttributeFormByName(
'dateTime2')->value);
424 $this->assertTrue($actions[0]->getActionAttributeFormByName(
'dateTime3') instanceof DateTimeWorkflowActionAttributeForm);
425 $this->assertEquals(
'DynamicFromExistingDateTime', $actions[0]->getActionAttributeFormByName(
'dateTime3')->type);
426 $this->assertEquals(-7200, $actions[0]->getActionAttributeFormByName(
'dateTime3')->value);
427 $this->assertTrue($actions[0]->getActionAttributeFormByName(
'dateTime4') instanceof DateTimeWorkflowActionAttributeForm);
428 $this->assertEquals(
'DynamicFromExistingDateTime', $actions[0]->getActionAttributeFormByName(
'dateTime4')->type);
429 $this->assertEquals(7200, $actions[0]->getActionAttributeFormByName(
'dateTime4')->value);
432 $this->assertEquals(
'DynamicStepForwardOrBackwards', $actions[0]->getActionAttributeFormByName(
'dropDown')->type);
433 $this->assertEquals(2, $actions[0]->getActionAttributeFormByName(
'dropDown')->value);
436 $this->assertEquals(
'DynamicCreatedByUser', $actions[0]->getActionAttributeFormByName(
'owner')->type);
437 $this->assertNull($actions[0]->getActionAttributeFormByName(
'owner')->value);
440 $this->assertEquals(
'DynamicStepForwardOrBackwards', $actions[0]->getActionAttributeFormByName(
'radioDropDown')->type);
441 $this->assertEquals(-2, $actions[0]->getActionAttributeFormByName(
'radioDropDown')->value);
443 $this->assertTrue($actions[0]->getActionAttributeFormByName(
'user') instanceof UserWorkflowActionAttributeForm);
444 $this->assertEquals(
'DynamicModifiedByUser', $actions[0]->getActionAttributeFormByName(
'user')->type);
445 $this->assertNull($actions[0]->getActionAttributeFormByName(
'user')->value);
446 $this->assertTrue($actions[0]->getActionAttributeFormByName(
'user2') instanceof UserWorkflowActionAttributeForm);
447 $this->assertEquals(
'DynamicTriggeredByUser', $actions[0]->getActionAttributeFormByName(
'user2')->type);
448 $this->assertNull($actions[0]->getActionAttributeFormByName(
'user2')->value);
457 $this->assertTrue($contactStates[0]->
id > 0);
458 $contactState = $contactStates[0];
462 $workflow->setType(Workflow::TYPE_ON_SAVE);
463 $workflow->setModuleClassName(
'WorkflowsTest2Module');
469 'boolean' => array(
'shouldSetValue' =>
'1',
470 'type' => WorkflowActionAttributeForm::TYPE_STATIC,
472 'boolean2' => array(
'shouldSetValue' =>
'1',
473 'type' => WorkflowActionAttributeForm::TYPE_STATIC,
475 'currencyValue' => array(
'shouldSetValue' =>
'1',
476 'type' => WorkflowActionAttributeForm::TYPE_STATIC,
478 'currencyId' => $currency->id),
479 'date' => array(
'shouldSetValue' =>
'1',
480 'type' => WorkflowActionAttributeForm::TYPE_STATIC,
481 'value' =>
'2/24/2012'),
482 'dateTime' => array(
'shouldSetValue' =>
'1',
483 'type' => WorkflowActionAttributeForm::TYPE_STATIC,
484 'value' =>
'2/24/2012 03:00 AM'),
485 'dropDown' => array(
'shouldSetValue' =>
'1',
486 'type' => WorkflowActionAttributeForm::TYPE_STATIC,
487 'value' =>
'Value 1'),
488 'float' => array(
'shouldSetValue' =>
'1',
489 'type' => WorkflowActionAttributeForm::TYPE_STATIC,
491 'integer' => array(
'shouldSetValue' =>
'1',
492 'type' => WorkflowActionAttributeForm::TYPE_STATIC,
494 'likeContactState' => array(
'shouldSetValue' =>
'1',
495 'type' => WorkflowActionAttributeForm::TYPE_STATIC,
496 'value' => $contactState->id),
497 'multiDropDown' => array(
'shouldSetValue' =>
'1',
498 'type' => WorkflowActionAttributeForm::TYPE_STATIC,
499 'value' => array(
'Multi Value 1',
'Multi Value 2')),
500 'owner' => array(
'shouldSetValue' =>
'1',
501 'type' => WorkflowActionAttributeForm::TYPE_STATIC,
502 'value' => $bobby->id),
503 'phone' => array(
'shouldSetValue' =>
'1',
504 'type' => WorkflowActionAttributeForm::TYPE_STATIC,
505 'value' =>
'8471112222'),
506 'primaryAddress___street1' => array(
'shouldSetValue' =>
'1',
507 'type' => WorkflowActionAttributeForm::TYPE_STATIC,
508 'value' =>
'123 Main Street'),
509 'primaryEmail___emailAddress' => array(
'shouldSetValue' =>
'1',
510 'type' => WorkflowActionAttributeForm::TYPE_STATIC,
511 'value' =>
'info@zurmo.com'),
512 'radioDropDown' => array(
'shouldSetValue' =>
'1',
513 'type' => WorkflowActionAttributeForm::TYPE_STATIC,
514 'value' =>
'Radio Value 1'),
515 'string' => array(
'shouldSetValue' =>
'1',
516 'type' => WorkflowActionAttributeForm::TYPE_STATIC,
518 'tagCloud' => array(
'shouldSetValue' =>
'1',
519 'type' => WorkflowActionAttributeForm::TYPE_STATIC,
520 'value' => array(
'Tag Value 1',
'Tag Value 2')),
521 'textArea' => array(
'shouldSetValue' =>
'1',
522 'type' => WorkflowActionAttributeForm::TYPE_STATIC,
523 'value' =>
'some description'),
524 'url' => array(
'shouldSetValue' =>
'1',
525 'type' => WorkflowActionAttributeForm::TYPE_STATIC,
526 'value' =>
'http://www.zurmo.com'),
530 $actions = $workflow->getActions();
531 $this->assertCount(1, $actions);
533 $this->assertEquals(
'hasMany2', $actions[0]->relation);
536 $this->assertEquals(19, $actions[0]->getActionAttributeFormsCount());
539 $this->assertEquals(
'Static', $actions[0]->getActionAttributeFormByName(
'boolean')->type);
540 $this->assertEquals(
'1', $actions[0]->getActionAttributeFormByName(
'boolean')->value);
542 $this->assertTrue($actions[0]->getActionAttributeFormByName(
'boolean2') instanceof CheckBoxWorkflowActionAttributeForm);
543 $this->assertEquals(
'Static', $actions[0]->getActionAttributeFormByName(
'boolean2')->type);
544 $this->assertEquals(
'0', $actions[0]->getActionAttributeFormByName(
'boolean2')->value);
547 $this->assertEquals(
'Static', $actions[0]->getActionAttributeFormByName(
'currencyValue')->type);
548 $this->assertEquals(362.24, $actions[0]->getActionAttributeFormByName(
'currencyValue')->value);
549 $this->assertEquals($currency->id, $actions[0]->getActionAttributeFormByName(
'currencyValue')->currencyId);
550 $this->assertEquals(
'Static', $actions[0]->getActionAttributeFormByName(
'currencyValue')->currencyIdType);
553 $this->assertEquals(
'Static', $actions[0]->getActionAttributeFormByName(
'date')->type);
554 $this->assertEquals(
'2012-02-24', $actions[0]->getActionAttributeFormByName(
'date')->value);
557 $this->assertEquals(
'Static', $actions[0]->getActionAttributeFormByName(
'dateTime')->type);
559 $this->assertEquals($compareDateTime, $actions[0]->getActionAttributeFormByName(
'dateTime')->value);
562 $this->assertEquals(
'Static', $actions[0]->getActionAttributeFormByName(
'dropDown')->type);
563 $this->assertEquals(
'Value 1', $actions[0]->getActionAttributeFormByName(
'dropDown')->value);
566 $this->assertEquals(
'Static', $actions[0]->getActionAttributeFormByName(
'float')->type);
567 $this->assertEquals(
'54.25', $actions[0]->getActionAttributeFormByName(
'float')->value);
570 $this->assertEquals(
'Static', $actions[0]->getActionAttributeFormByName(
'integer')->type);
571 $this->assertEquals(
'32', $actions[0]->getActionAttributeFormByName(
'integer')->value);
574 $this->assertEquals(
'Static', $actions[0]->getActionAttributeFormByName(
'likeContactState')->type);
575 $this->assertEquals($contactState->id, $actions[0]->getActionAttributeFormByName(
'likeContactState')->value);
578 $this->assertEquals(
'Static', $actions[0]->getActionAttributeFormByName(
'multiDropDown')->type);
579 $this->assertEquals(array(
'Multi Value 1',
'Multi Value 2'), $actions[0]->getActionAttributeFormByName(
'multiDropDown')->value);
582 $this->assertEquals(
'Static', $actions[0]->getActionAttributeFormByName(
'owner')->type);
583 $this->assertEquals($bobby->id, $actions[0]->getActionAttributeFormByName(
'owner')->value);
586 $this->assertEquals(
'Static', $actions[0]->getActionAttributeFormByName(
'phone')->type);
587 $this->assertEquals(
'8471112222', $actions[0]->getActionAttributeFormByName(
'phone')->value);
590 $this->assertEquals(
'Static', $actions[0]->getActionAttributeFormByName(
'primaryAddress___street1')->type);
591 $this->assertEquals(
'123 Main Street', $actions[0]->getActionAttributeFormByName(
'primaryAddress___street1')->value);
594 $this->assertEquals(
'Static', $actions[0]->getActionAttributeFormByName(
'primaryEmail___emailAddress')->type);
595 $this->assertEquals(
'info@zurmo.com', $actions[0]->getActionAttributeFormByName(
'primaryEmail___emailAddress')->value);
598 $this->assertEquals(
'Static', $actions[0]->getActionAttributeFormByName(
'radioDropDown')->type);
599 $this->assertEquals(
'Radio Value 1', $actions[0]->getActionAttributeFormByName(
'radioDropDown')->value);
601 $this->assertTrue($actions[0]->getActionAttributeFormByName(
'string') instanceof TextWorkflowActionAttributeForm);
602 $this->assertEquals(
'Static', $actions[0]->getActionAttributeFormByName(
'string')->type);
603 $this->assertEquals(
'jason', $actions[0]->getActionAttributeFormByName(
'string')->value);
606 $this->assertEquals(
'Static', $actions[0]->getActionAttributeFormByName(
'tagCloud')->type);
607 $this->assertEquals(array(
'Tag Value 1',
'Tag Value 2'), $actions[0]->getActionAttributeFormByName(
'tagCloud')->value);
610 $this->assertEquals(
'Static', $actions[0]->getActionAttributeFormByName(
'textArea')->type);
611 $this->assertEquals(
'some description', $actions[0]->getActionAttributeFormByName(
'textArea')->value);
614 $this->assertEquals(
'Static', $actions[0]->getActionAttributeFormByName(
'url')->type);
615 $this->assertEquals(
'http://www.zurmo.com', $actions[0]->getActionAttributeFormByName(
'url')->value);
625 $workflow->setType(Workflow::TYPE_ON_SAVE);
626 $workflow->setModuleClassName(
'WorkflowsTest2Module');
632 'date' => array(
'shouldSetValue' =>
'1',
633 'type' => DateWorkflowActionAttributeForm::TYPE_DYNAMIC_FROM_TRIGGERED_DATE,
634 'value' =>
'-86400'),
635 'date2' => array(
'shouldSetValue' =>
'1',
636 'type' => DateWorkflowActionAttributeForm::TYPE_DYNAMIC_FROM_TRIGGERED_DATE,
638 'date3' => array(
'shouldSetValue' =>
'1',
639 'type' => DateWorkflowActionAttributeForm::TYPE_DYNAMIC_FROM_EXISTING_DATE,
640 'value' =>
'-86400'),
641 'date4' => array(
'shouldSetValue' =>
'1',
642 'type' => DateWorkflowActionAttributeForm::TYPE_DYNAMIC_FROM_EXISTING_DATE,
644 'dateTime' => array(
'shouldSetValue' =>
'1',
645 'type' => DateTimeWorkflowActionAttributeForm::TYPE_DYNAMIC_FROM_TRIGGERED_DATETIME,
647 'dateTime2' => array(
'shouldSetValue' =>
'1',
648 'type' => DateTimeWorkflowActionAttributeForm::TYPE_DYNAMIC_FROM_TRIGGERED_DATETIME,
650 'dateTime3' => array(
'shouldSetValue' =>
'1',
651 'type' => DateTimeWorkflowActionAttributeForm::TYPE_DYNAMIC_FROM_EXISTING_DATETIME,
653 'dateTime4' => array(
'shouldSetValue' =>
'1',
654 'type' => DateTimeWorkflowActionAttributeForm::TYPE_DYNAMIC_FROM_EXISTING_DATETIME,
656 'dropDown' => array(
'shouldSetValue' =>
'1',
659 'owner' => array(
'shouldSetValue' =>
'1',
660 'type' => UserWorkflowActionAttributeForm::TYPE_DYNAMIC_CREATED_BY_USER),
661 'radioDropDown' => array(
'shouldSetValue' =>
'1',
664 'user' => array(
'shouldSetValue' =>
'1',
665 'type' => UserWorkflowActionAttributeForm::TYPE_DYNAMIC_MODIFIED_BY_USER),
666 'user2' => array(
'shouldSetValue' =>
'1',
667 'type' => UserWorkflowActionAttributeForm::TYPE_DYNAMIC_TRIGGERED_BY_USER),
671 $actions = $workflow->getActions();
672 $this->assertCount(1, $actions);
674 $this->assertEquals(
'hasMany2', $actions[0]->relation);
676 $this->assertEquals(13, $actions[0]->getActionAttributeFormsCount());
679 $this->assertEquals(
'DynamicFromTriggeredDate', $actions[0]->getActionAttributeFormByName(
'date')->type);
680 $this->assertEquals(-86400, $actions[0]->getActionAttributeFormByName(
'date')->value);
681 $this->assertTrue($actions[0]->getActionAttributeFormByName(
'date2') instanceof DateWorkflowActionAttributeForm);
682 $this->assertEquals(
'DynamicFromTriggeredDate', $actions[0]->getActionAttributeFormByName(
'date2')->type);
683 $this->assertEquals(86400, $actions[0]->getActionAttributeFormByName(
'date2')->value);
684 $this->assertTrue($actions[0]->getActionAttributeFormByName(
'date3') instanceof DateWorkflowActionAttributeForm);
685 $this->assertEquals(
'DynamicFromExistingDate', $actions[0]->getActionAttributeFormByName(
'date3')->type);
686 $this->assertEquals(-86400, $actions[0]->getActionAttributeFormByName(
'date3')->value);
687 $this->assertTrue($actions[0]->getActionAttributeFormByName(
'date4') instanceof DateWorkflowActionAttributeForm);
688 $this->assertEquals(
'DynamicFromExistingDate', $actions[0]->getActionAttributeFormByName(
'date4')->type);
689 $this->assertEquals(86400, $actions[0]->getActionAttributeFormByName(
'date4')->value);
692 $this->assertEquals(
'DynamicFromTriggeredDateTime', $actions[0]->getActionAttributeFormByName(
'dateTime')->type);
693 $this->assertEquals(-3600, $actions[0]->getActionAttributeFormByName(
'dateTime')->value);
694 $this->assertTrue($actions[0]->getActionAttributeFormByName(
'dateTime2') instanceof DateTimeWorkflowActionAttributeForm);
695 $this->assertEquals(
'DynamicFromTriggeredDateTime', $actions[0]->getActionAttributeFormByName(
'dateTime2')->type);
696 $this->assertEquals(3600, $actions[0]->getActionAttributeFormByName(
'dateTime2')->value);
697 $this->assertTrue($actions[0]->getActionAttributeFormByName(
'dateTime3') instanceof DateTimeWorkflowActionAttributeForm);
698 $this->assertEquals(
'DynamicFromExistingDateTime', $actions[0]->getActionAttributeFormByName(
'dateTime3')->type);
699 $this->assertEquals(-7200, $actions[0]->getActionAttributeFormByName(
'dateTime3')->value);
700 $this->assertTrue($actions[0]->getActionAttributeFormByName(
'dateTime4') instanceof DateTimeWorkflowActionAttributeForm);
701 $this->assertEquals(
'DynamicFromExistingDateTime', $actions[0]->getActionAttributeFormByName(
'dateTime4')->type);
702 $this->assertEquals(7200, $actions[0]->getActionAttributeFormByName(
'dateTime4')->value);
705 $this->assertEquals(
'DynamicStepForwardOrBackwards', $actions[0]->getActionAttributeFormByName(
'dropDown')->type);
706 $this->assertEquals(2, $actions[0]->getActionAttributeFormByName(
'dropDown')->value);
709 $this->assertEquals(
'DynamicCreatedByUser', $actions[0]->getActionAttributeFormByName(
'owner')->type);
710 $this->assertNull($actions[0]->getActionAttributeFormByName(
'owner')->value);
713 $this->assertEquals(
'DynamicStepForwardOrBackwards', $actions[0]->getActionAttributeFormByName(
'radioDropDown')->type);
714 $this->assertEquals(-2, $actions[0]->getActionAttributeFormByName(
'radioDropDown')->value);
716 $this->assertTrue($actions[0]->getActionAttributeFormByName(
'user') instanceof UserWorkflowActionAttributeForm);
717 $this->assertEquals(
'DynamicModifiedByUser', $actions[0]->getActionAttributeFormByName(
'user')->type);
718 $this->assertNull($actions[0]->getActionAttributeFormByName(
'user')->value);
719 $this->assertTrue($actions[0]->getActionAttributeFormByName(
'user2') instanceof UserWorkflowActionAttributeForm);
720 $this->assertEquals(
'DynamicTriggeredByUser', $actions[0]->getActionAttributeFormByName(
'user2')->type);
721 $this->assertNull($actions[0]->getActionAttributeFormByName(
'user2')->value);
731 $workflow->setType(Workflow::TYPE_ON_SAVE);
732 $workflow->setModuleClassName(
'WorkflowsTest2Module');
738 'user' => array(
'shouldSetValue' =>
'1',
739 'type' => UserWorkflowActionAttributeForm::TYPE_DYNAMIC_OWNER_OF_TRIGGERED_MODEL),
743 $actions = $workflow->getActions();
744 $this->assertCount(1, $actions);
746 $this->assertEquals(
'hasMany2', $actions[0]->relation);
748 $this->assertEquals(1, $actions[0]->getActionAttributeFormsCount());
751 $this->assertEquals(
'OwnerOfTriggeredModel', $actions[0]->getActionAttributeFormByName(
'user')->type);
752 $this->assertNull($actions[0]->getActionAttributeFormByName(
'user')->value);
762 $workflow->setType(Workflow::TYPE_ON_SAVE);
763 $workflow->setModuleClassName(
'WorkflowsTest2Module');
769 'string' => array(
'shouldSetValue' =>
'1',
770 'type' => WorkflowActionAttributeForm::TYPE_STATIC,
772 'phone' => array(
'shouldSetValue' =>
'1',
773 'type' => WorkflowActionAttributeForm::TYPE_STATIC_NULL,
778 $actions = $workflow->getActions();
779 $this->assertCount(1, $actions);
781 $this->assertEquals(
'hasMany2', $actions[0]->relation);
783 $this->assertEquals(2, $actions[0]->getActionAttributeFormsCount());
786 $this->assertEquals(
'Static', $actions[0]->getActionAttributeFormByName(
'string')->type);
787 $this->assertEquals(
'jason', $actions[0]->getActionAttributeFormByName(
'string')->value);
789 $this->assertEquals(
'StaticNull', $actions[0]->getActionAttributeFormByName(
'phone')->type);
790 $this->assertEquals(null, $actions[0]->getActionAttributeFormByName(
'phone')->value);
800 $workflow->setType(Workflow::TYPE_ON_SAVE);
801 $workflow->setModuleClassName(
'WorkflowsTest2Module');
808 'name' => array(
'shouldSetValue' =>
'1',
809 'type' => WorkflowActionAttributeForm::TYPE_STATIC,
814 $actions = $workflow->getActions();
815 $this->assertCount(1, $actions);
817 $this->assertEquals(
'hasMany2', $actions[0]->relation);
819 $this->assertEquals(
'hasMany', $actions[0]->relatedModelRelation);
821 $this->assertEquals(1, $actions[0]->getActionAttributeFormsCount());
824 $this->assertEquals(
'Static', $actions[0]->getActionAttributeFormByName(
'name')->type);
825 $this->assertEquals(
'jason', $actions[0]->getActionAttributeFormByName(
'name')->value);
876 $workflow->setType(Workflow::TYPE_ON_SAVE);
877 $workflow->setModuleClassName(
'WorkflowsTestModule');
881 EmailMessageForWorkflowForm::SEND_FROM_TYPE_DEFAULT;
886 array(
'type' => WorkflowEmailMessageRecipientForm::TYPE_DYNAMIC_TRIGGERED_MODEL_USER,
887 'audienceType' => EmailMessageRecipient::TYPE_TO,
888 'dynamicUserType' => DynamicTriggeredModelUserWorkflowEmailMessageRecipientForm::DYNAMIC_USER_TYPE_CREATED_BY_USER),
889 array(
'type' => WorkflowEmailMessageRecipientForm::TYPE_DYNAMIC_TRIGGERED_MODEL_USER,
890 'audienceType' => EmailMessageRecipient::TYPE_CC,
891 'dynamicUserType' => DynamicTriggeredModelUserWorkflowEmailMessageRecipientForm::DYNAMIC_USER_TYPE_MANAGER_OF_CREATED_BY_USER),
892 array(
'type' => WorkflowEmailMessageRecipientForm::TYPE_DYNAMIC_TRIGGERED_MODEL_USER,
893 'audienceType' => EmailMessageRecipient::TYPE_BCC,
894 'dynamicUserType' => DynamicTriggeredModelUserWorkflowEmailMessageRecipientForm::DYNAMIC_USER_TYPE_MODIFIED_BY_USER),
895 array(
'type' => WorkflowEmailMessageRecipientForm::TYPE_DYNAMIC_TRIGGERED_MODEL_USER,
896 'audienceType' => EmailMessageRecipient::TYPE_TO,
897 'dynamicUserType' => DynamicTriggeredModelUserWorkflowEmailMessageRecipientForm::DYNAMIC_USER_TYPE_MANAGER_OF_MODIFIED_BY_USER),
898 array(
'type' => WorkflowEmailMessageRecipientForm::TYPE_DYNAMIC_TRIGGERED_MODEL_USER,
899 'audienceType' => EmailMessageRecipient::TYPE_CC,
900 'dynamicUserType' => DynamicTriggeredModelUserWorkflowEmailMessageRecipientForm::DYNAMIC_USER_TYPE_OWNER),
901 array(
'type' => WorkflowEmailMessageRecipientForm::TYPE_DYNAMIC_TRIGGERED_MODEL_USER,
902 'audienceType' => EmailMessageRecipient::TYPE_BCC,
903 'dynamicUserType' => DynamicTriggeredModelUserWorkflowEmailMessageRecipientForm::DYNAMIC_USER_TYPE_MANAGER_OF_OWNER),
904 array(
'type' => WorkflowEmailMessageRecipientForm::TYPE_DYNAMIC_TRIGGERED_MODEL_RELATION_USER,
905 'audienceType' => EmailMessageRecipient::TYPE_TO,
906 'dynamicUserType' => DynamicTriggeredModelUserWorkflowEmailMessageRecipientForm::DYNAMIC_USER_TYPE_CREATED_BY_USER,
907 'relation' =>
'hasOne'),
908 array(
'type' => WorkflowEmailMessageRecipientForm::TYPE_STATIC_ROLE,
909 'audienceType' => EmailMessageRecipient::TYPE_CC,
911 array(
'type' => WorkflowEmailMessageRecipientForm::TYPE_DYNAMIC_TRIGGERED_BY_USER,
912 'audienceType' => EmailMessageRecipient::TYPE_BCC),
913 array(
'type' => WorkflowEmailMessageRecipientForm::TYPE_STATIC_USER,
914 'audienceType' => EmailMessageRecipient::TYPE_TO,
916 array(
'type' => WorkflowEmailMessageRecipientForm::TYPE_STATIC_ADDRESS,
917 'audienceType' => EmailMessageRecipient::TYPE_CC,
918 'toName' =>
'somebody',
919 'toAddress' =>
'someone@zurmo.com'),
920 array(
'type' => WorkflowEmailMessageRecipientForm::TYPE_STATIC_GROUP,
921 'audienceType' => EmailMessageRecipient::TYPE_BCC,
925 $emailMessages = $workflow->getEmailMessages();
926 $this->assertCount(1, $emailMessages);
927 $this->assertEquals(
'5', $emailMessages[0]->emailTemplateId);
928 $this->assertEquals(EmailMessageForWorkflowForm::SEND_FROM_TYPE_DEFAULT, $emailMessages[0]->sendFromType);
929 $this->assertEquals(0, $emailMessages[0]->sendAfterDurationInterval);
930 $this->assertEquals(TimeDurationUtil::DURATION_TYPE_WEEK, $emailMessages[0]->sendAfterDurationType);
931 $this->assertEquals(12, $emailMessages[0]->getEmailMessageRecipientFormsCount());
933 $emailMessageRecipients = $emailMessages[0]->getEmailMessageRecipients();
935 $this->assertEquals(
'DynamicTriggeredModelUser', $emailMessageRecipients[0]->type);
936 $this->assertEquals(1, $emailMessageRecipients[0]->audienceType);
937 $this->assertEquals(
'CreatedByUser', $emailMessageRecipients[0]->dynamicUserType);
938 $this->assertTrue($emailMessageRecipients[1] instanceof DynamicTriggeredModelUserWorkflowEmailMessageRecipientForm);
939 $this->assertEquals(
'DynamicTriggeredModelUser', $emailMessageRecipients[1]->type);
940 $this->assertEquals(2, $emailMessageRecipients[1]->audienceType);
941 $this->assertEquals(
'ManagerOfCreatedByUser', $emailMessageRecipients[1]->dynamicUserType);
942 $this->assertTrue($emailMessageRecipients[2] instanceof DynamicTriggeredModelUserWorkflowEmailMessageRecipientForm);
943 $this->assertEquals(
'DynamicTriggeredModelUser', $emailMessageRecipients[2]->type);
944 $this->assertEquals(3, $emailMessageRecipients[2]->audienceType);
945 $this->assertEquals(
'ModifiedByUser', $emailMessageRecipients[2]->dynamicUserType);
946 $this->assertTrue($emailMessageRecipients[3] instanceof DynamicTriggeredModelUserWorkflowEmailMessageRecipientForm);
947 $this->assertEquals(
'DynamicTriggeredModelUser', $emailMessageRecipients[3]->type);
948 $this->assertEquals(1, $emailMessageRecipients[3]->audienceType);
949 $this->assertEquals(
'ManagerOfModifiedByUser', $emailMessageRecipients[3]->dynamicUserType);
950 $this->assertTrue($emailMessageRecipients[4] instanceof DynamicTriggeredModelUserWorkflowEmailMessageRecipientForm);
951 $this->assertEquals(
'DynamicTriggeredModelUser', $emailMessageRecipients[4]->type);
952 $this->assertEquals(2, $emailMessageRecipients[4]->audienceType);
953 $this->assertEquals(
'Owner', $emailMessageRecipients[4]->dynamicUserType);
954 $this->assertTrue($emailMessageRecipients[5] instanceof DynamicTriggeredModelUserWorkflowEmailMessageRecipientForm);
955 $this->assertEquals(
'DynamicTriggeredModelUser', $emailMessageRecipients[5]->type);
956 $this->assertEquals(3, $emailMessageRecipients[5]->audienceType);
957 $this->assertEquals(
'ManagerOfOwner', $emailMessageRecipients[5]->dynamicUserType);
959 $this->assertEquals(
'DynamicTriggeredModelRelationUser', $emailMessageRecipients[6]->type);
960 $this->assertEquals(1, $emailMessageRecipients[6]->audienceType);
961 $this->assertEquals(
'CreatedByUser', $emailMessageRecipients[6]->dynamicUserType);
962 $this->assertEquals(
'hasOne', $emailMessageRecipients[6]->relation);
963 $this->assertEquals(
'RelationFilterAll', $emailMessageRecipients[6]->relationFilter);
965 $this->assertEquals(
'StaticRole', $emailMessageRecipients[7]->type);
966 $this->assertEquals(2, $emailMessageRecipients[7]->audienceType);
967 $this->assertEquals(5, $emailMessageRecipients[7]->roleId);
969 $this->assertEquals(
'DynamicTriggeredByUser', $emailMessageRecipients[8]->type);
970 $this->assertEquals(3, $emailMessageRecipients[8]->audienceType);
972 $this->assertEquals(
'StaticUser', $emailMessageRecipients[9]->type);
973 $this->assertEquals(1, $emailMessageRecipients[9]->audienceType);
974 $this->assertEquals(6, $emailMessageRecipients[9]->userId);
976 $this->assertEquals(
'StaticAddress', $emailMessageRecipients[10]->type);
977 $this->assertEquals(2, $emailMessageRecipients[10]->audienceType);
978 $this->assertEquals(
'somebody', $emailMessageRecipients[10]->toName);
979 $this->assertEquals(
'someone@zurmo.com', $emailMessageRecipients[10]->toAddress);
981 $this->assertEquals(
'StaticGroup', $emailMessageRecipients[11]->type);
982 $this->assertEquals(3, $emailMessageRecipients[11]->audienceType);
983 $this->assertEquals(7, $emailMessageRecipients[11]->groupId);
testResolveTriggersAndDateConvertsProperlyToDbFormat()
static resolveEmailMessages($data, Workflow $workflow)
static getByUsername($username)
static resolveTimeTrigger($data, Workflow $workflow)
static convertDateTimeLocaleFormattedDisplayToDbFormattedDateTimeWithSecondsAsZero($localeFormattedDateTime)
static resolveTriggers($data, Workflow $workflow)
testResolveCreateRelatedActionWithValues()
static resolveWorkflowByWizardPostData(Workflow $workflow, $postData, $wizardFormClassName)
testResolveUpdateRelatedActionWithStaticValues()
static getAll($orderBy=null, $sortDescending=false, $modelClassName=null, $buildFirstCurrency=true)
testResolveCreateActionWithValues()
testResolveUpdateActionWithStaticValues()
static sanitizeTriggersData($moduleClassName, $workflowType, array $triggersData)
testSanitizeTriggersData()
testResolveUpdateRelatedActionWithDynamicValuesSpecificallyDynamicOwnerOfTriggeredModel()
testResolveUpdateRelatedActionWithDynamicValues()
static getAll($orderBy=null, $sortDescending=false, $modelClassName=null)
testResolveUpdateActionWithDynamicValues()
static resolveActions($data, Workflow $workflow)