/** * Tests the multidev:list command when there are no multidev environments */ public function testOrgListNotEmpty() { $data = ['id' => 'org_id', 'name' => 'Organization Name']; $this->user->expects($this->once())->method('getOrganizations')->with()->willReturn([$this->organization, $this->organization]); $this->logger->expects($this->never())->method('log'); $this->organization->expects($this->exactly(2))->method('serialize')->with()->willReturn($data); $out = $this->command->listOrgs(); $this->assertInstanceOf('Consolidation\\OutputFormatters\\StructuredData\\RowsOfFields', $out); $this->assertEquals([$data, $data], $out->getArrayCopy()); }
public function testGetUsers() { $organization = new Organization((object) ['id' => '123']); $user_data = ['a' => ['id' => 'abc', 'email' => '*****@*****.**', 'profile' => (object) ['full_name' => 'User A']], 'b' => ['id' => 'bcd', 'email' => '*****@*****.**', 'profile' => (object) ['full_name' => 'User B']], 'c' => ['id' => 'cde', 'email' => '*****@*****.**', 'profile' => (object) ['full_name' => 'User C']]]; $model_data = $users = []; foreach ($user_data as $i => $user) { $model_data[$i] = $this->getMockBuilder(OrganizationUserMembership::class)->disableOriginalConstructor()->getMock(); $users[$user['id']] = new User((object) $user); $model_data[$i]->method('getUser')->willReturn($users[$user['id']]); } $org_user_membership = $this->getMockBuilder(OrganizationUserMemberships::class)->setMethods(['getMembers'])->disableOriginalConstructor()->getMock(); $org_user_membership->expects($this->any())->method('getMembers')->willReturn($model_data); $container = $this->getMockBuilder(Container::class)->disableOriginalConstructor()->getMock(); $container->expects($this->once())->method('get')->with(OrganizationUserMemberships::class, [['organization' => $organization]])->willReturn($org_user_membership); $organization->setContainer($container); $this->assertEquals($org_user_membership, $organization->getUserMemberships()); $this->assertEquals($users, $organization->getUsers()); }
/** * @inheritdoc */ protected function setUp() { parent::setUp(); $this->session = $this->getMockBuilder(Session::class)->disableOriginalConstructor()->getMock(); $this->user = $this->getMockBuilder(User::class)->disableOriginalConstructor()->getMock(); $this->user_org_memberships = $this->getMockBuilder(UserOrganizationMemberships::class)->disableOriginalConstructor()->getMock(); $this->user_org_membership = $this->getMockBuilder(UserOrganizationMembership::class)->disableOriginalConstructor()->getMock(); $this->organization = $this->getMockBuilder(Organization::class)->disableOriginalConstructor()->getMock(); $this->organization->id = 'org_id'; $this->org_user_membership = $this->getMockBuilder(OrganizationUserMembership::class)->disableOriginalConstructor()->getMock(); $this->org_user_memberships = $this->getMockBuilder(OrganizationUserMemberships::class)->disableOriginalConstructor()->getMock(); $this->session->method('getUser')->with()->willReturn($this->user); $this->user->method('getOrgMemberships')->with()->willReturn($this->user_org_memberships); $this->user_org_memberships->method('get')->with($this->equalTo($this->organization->id))->willReturn($this->user_org_membership); $this->user_org_membership->method('getOrganization')->with()->willReturn($this->organization); $this->organization->method('getUserMemberships')->with()->willReturn($this->org_user_memberships); $this->org_user_memberships->method('fetch')->with()->willReturn($this->org_user_memberships); }
/** * Removes a site from this organization * * @return Workflow */ public function delete() { $workflow = $this->organization->getWorkflows()->create('remove_organization_site_membership', ['params' => ['site_id' => $this->getSite()->get('id')]]); return $workflow; }
/** * Sets the user's role within this organization * * @param string $role Role for this user to take in the organization * @return Workflow */ public function setRole($role) { $workflow = $this->organization->getWorkflows()->create('update_organization_user_membership', ['params' => ['user_id' => $this->getUser()->id, 'role' => $role]]); return $workflow; }