/** * @depends testMakeRecipientsForAHasManyRelation */ public function testMakeRecipientsForAHasOneRelation() { $form = new DynamicTriggeredModelRelationUserWorkflowEmailMessageRecipientForm('WorkflowModelTestItem', Workflow::TYPE_ON_SAVE); $form->relation = 'hasOne'; $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 $model2 = new WorkflowModelTestItem2(); $model2->name = 'model 2'; $this->assertTrue($model2->save()); $this->assertTrue($model2->id > 0); $model->hasOne = $model2; $this->assertTrue($model->save()); $this->assertTrue($model->hasOne->id > 0); $recipients = $form->makeRecipients($model, self::$sarah); $this->assertEquals(1, count($recipients)); $this->assertTrue($recipients[0]->personOrAccount->isSame(self::$super)); }