/**
  * @depends testMakeRecipientsForAnInferredRelation
  */
 public function testMakeRecipientsForAHasManyRelation()
 {
     $form = new DynamicTriggeredModelRelationUserWorkflowEmailMessageRecipientForm('WorkflowModelTestItem', Workflow::TYPE_ON_SAVE);
     $form->relation = 'hasMany';
     $form->dynamicUserType = DynamicTriggeredModelRelationUserWorkflowEmailMessageRecipientForm::DYNAMIC_USER_TYPE_OWNER;
     $model = new WorkflowModelTestItem();
     $model->lastName = 'lastName';
     $model->string = 'string';
     $this->assertTrue($model->save());
     //Test without any related model
     $recipients = $form->makeRecipients($model, self::$sarah);
     $this->assertEquals(0, count($recipients));
     //Test with a related model
     $model3 = new WorkflowModelTestItem3();
     $model3->name = 'model 3';
     $model3->owner = self::$bobby;
     $this->assertTrue($model3->save());
     $model->hasMany->add($model3);
     $this->assertTrue($model->save());
     $recipients = $form->makeRecipients($model, self::$bobby);
     $this->assertEquals(1, count($recipients));
     $this->assertTrue($recipients[0]->personOrAccount->isSame(self::$bobby));
 }
 /**
  * @depends testTriggerBeforeSaveHasManyNotOwnedEquals
  */
 public function testTriggerBeforeSaveManyManyNotOwnedEquals()
 {
     $workflow = self::makeOnSaveWorkflowAndTriggerWithoutValueType('hasMany3___name', 'equals', 'aValue', 'WorkflowsTestModule', 'WorkflowModelTestItem2');
     $model = new WorkflowModelTestItem2();
     $relatedModel = new WorkflowModelTestItem3();
     $this->assertTrue($relatedModel->save());
     $model->hasMany3->add($relatedModel);
     $model->hasMany3[0]->name = 'aValue';
     $this->assertTrue(WorkflowTriggersUtil::areTriggersTrueBeforeSave($workflow, $model));
     $model->hasMany3[0]->name = 'bValue';
     $this->assertFalse(WorkflowTriggersUtil::areTriggersTrueBeforeSave($workflow, $model));
     $model = self::saveAndReloadModel($model);
     $this->assertFalse(WorkflowTriggersUtil::areTriggersTrueBeforeSave($workflow, $model));
     $model->hasMany3[0]->name = 'aValue';
     $this->assertTrue(WorkflowTriggersUtil::areTriggersTrueBeforeSave($workflow, $model));
     //should be case-insensitive
     $model->hasMany3[0]->name = 'aVAlUe';
     $this->assertTrue(WorkflowTriggersUtil::areTriggersTrueBeforeSave($workflow, $model));
 }