Pantheon\Terminus\Collections\OrganizationUserMemberships::create PHP Method

create() public method

Adds a user to this organization
public create ( string $uuid, string $role ) : Workflow
$uuid string UUID of user user to add to this organization
$role string Role to assign to the new member
return Workflow $workflow
    public function create($uuid, $role)
    {
        $workflow = $this->organization->getWorkflows()->create('add_organization_user_membership', ['params' => ['user_email' => $uuid, 'role' => $role]]);
        return $workflow;
    }

Usage Example

 public function testCreate()
 {
     $workflows = $this->getMockBuilder(Workflows::class)->disableOriginalConstructor()->getMock();
     $organization = $this->getMockBuilder(Organization::class)->disableOriginalConstructor()->getMock();
     $organization->expects($this->once())->method('getWorkflows')->willReturn($workflows);
     $organization->id = '123';
     $workflows->expects($this->once())->method('create')->with('add_organization_user_membership', ['params' => ['user_email' => '*****@*****.**', 'role' => 'team_member']]);
     $org_site_membership = new OrganizationUserMemberships(['organization' => $organization]);
     $org_site_membership->create('*****@*****.**', 'team_member');
 }