当前位置: 首页>>代码示例>>PHP>>正文


PHP User::addOrganization方法代码示例

本文整理汇总了PHP中Oro\Bundle\UserBundle\Entity\User::addOrganization方法的典型用法代码示例。如果您正苦于以下问题:PHP User::addOrganization方法的具体用法?PHP User::addOrganization怎么用?PHP User::addOrganization使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Oro\Bundle\UserBundle\Entity\User的用法示例。


在下文中一共展示了User::addOrganization方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testOnFlushCreateUser

 /**
  * Test new user creation
  */
 public function testOnFlushCreateUser()
 {
     $args = new OnFlushEventArgs($this->em);
     $user = new User();
     $org1 = new Organization();
     ReflectionUtil::setId($org1, 1);
     $org2 = new Organization();
     ReflectionUtil::setId($org2, 2);
     $user->setOrganization($org1);
     $user->addOrganization($org1);
     $user->addOrganization($org2);
     $newCalendar1 = new Calendar();
     $newCalendar1->setOwner($user)->setOrganization($org1);
     $newCalendar2 = new Calendar();
     $newCalendar2->setOwner($user)->setOrganization($org2);
     $calendarMetadata = new ClassMetadata(get_class($newCalendar1));
     $this->uow->expects($this->once())->method('getScheduledEntityInsertions')->will($this->returnValue([$user]));
     $this->uow->expects($this->once())->method('getScheduledCollectionUpdates')->will($this->returnValue([]));
     $this->em->expects($this->at(1))->method('persist')->with($this->equalTo($newCalendar1));
     $this->em->expects($this->at(2))->method('getClassMetadata')->with('Oro\\Bundle\\CalendarBundle\\Entity\\Calendar')->will($this->returnValue($calendarMetadata));
     $this->em->expects($this->at(3))->method('persist')->with($this->equalTo($newCalendar2));
     $this->uow->expects($this->at(1))->method('computeChangeSet')->with($calendarMetadata, $newCalendar1);
     $this->uow->expects($this->at(2))->method('computeChangeSet')->with($calendarMetadata, $newCalendar2);
     $this->listener->onFlush($args);
 }
开发者ID:ramunasd,项目名称:platform,代码行数:28,代码来源:EntityListenerTest.php

示例2: testOnFlushUpdateUser

 /**
  * Test existing user modification
  */
 public function testOnFlushUpdateUser()
 {
     $args = new OnFlushEventArgs($this->em);
     $user = new User();
     $org = new Organization();
     $org->setId(1);
     $org->setName('test');
     $user->addOrganization($org);
     $newCalendar = new Calendar();
     $newCalendar->setOwner($user);
     $newCalendar->setOrganization($org);
     $newConnection = new CalendarConnection($newCalendar);
     $newCalendar->addConnection($newConnection);
     $calendarMetadata = new ClassMetadata(get_class($newCalendar));
     $connectionMetadata = new ClassMetadata(get_class($newConnection));
     $this->em->expects($this->any())->method('getClassMetadata')->will($this->returnValueMap([['Oro\\Bundle\\CalendarBundle\\Entity\\Calendar', $calendarMetadata], ['Oro\\Bundle\\CalendarBundle\\Entity\\CalendarConnection', $connectionMetadata]]));
     $calendarRepo = $this->getMockBuilder('\\Doctrine\\ORM\\EntityRepository')->disableOriginalConstructor()->getMock();
     $calendarRepo->expects($this->any())->method('findDefaultCalendar')->will($this->returnValue(false));
     $this->em->expects($this->once())->method('getUnitOfWork')->will($this->returnValue($this->uow));
     $this->uow->expects($this->once())->method('getScheduledEntityInsertions')->will($this->returnValue([]));
     $this->uow->expects($this->once())->method('getScheduledEntityUpdates')->will($this->returnValue([$user]));
     $this->em->expects($this->any())->method('getRepository')->with('OroCalendarBundle:Calendar')->will($this->returnValue($calendarRepo));
     $this->em->expects($this->at(2))->method('persist')->with($this->equalTo($newCalendar));
     $this->em->expects($this->at(3))->method('persist')->with($this->equalTo($newConnection));
     $this->uow->expects($this->at(2))->method('computeChangeSet')->with($calendarMetadata, $newCalendar);
     $this->uow->expects($this->at(3))->method('computeChangeSet')->with($connectionMetadata, $newConnection);
     $this->listener->onFlush($args);
 }
开发者ID:xamin123,项目名称:platform,代码行数:31,代码来源:EntityListenerTest.php

示例3: testTokenShouldBeAuthenticated

 public function testTokenShouldBeAuthenticated()
 {
     $token = new OAuthToken('token');
     $token->setResourceOwnerName('google');
     $organization = new Organization();
     $organization->setEnabled(true);
     $token->setOrganizationContext($organization);
     $userResponse = $this->getMock('HWI\\Bundle\\OAuthBundle\\OAuth\\Response\\UserResponseInterface');
     $resourceOwner = $this->getMock('HWI\\Bundle\\OAuthBundle\\OAuth\\ResourceOwnerInterface');
     $resourceOwner->expects($this->any())->method('getName')->will($this->returnValue('google'));
     $resourceOwner->expects($this->any())->method('getUserInformation')->will($this->returnValue($userResponse));
     $this->resourceOwnerMap->expects($this->any())->method('getResourceOwnerByName')->will($this->returnValue($resourceOwner));
     $user = new User();
     $user->addOrganization($organization);
     $this->userProvider->expects($this->any())->method('loadUserByOAuthUserResponse')->with($userResponse)->will($this->returnValue($user));
     $resultToken = $this->oauthProvider->authenticate($token);
     $this->assertInstanceOf('Oro\\Bundle\\SSOBundle\\Security\\OAuthToken', $resultToken);
     $this->assertSame($user, $resultToken->getUser());
     $this->assertEquals('google', $resultToken->getResourceOwnerName());
     $this->assertTrue($resultToken->isAuthenticated());
 }
开发者ID:northdakota,项目名称:platform,代码行数:21,代码来源:OAuthProviderTest.php

示例4: testSetUsernameAndOrganizationName

 public function testSetUsernameAndOrganizationName()
 {
     $this->assertEmpty($this->securityContext->getToken());
     $username = 'test_user';
     $user = new User();
     $user->setUsername($username);
     $organizationName = 'test_organization';
     $organization = new Organization();
     $organization->setName($organizationName);
     $organization->setEnabled(true);
     $user->addOrganization($organization);
     $event = $this->getEvent();
     /** @var \PHPUnit_Framework_MockObject_MockObject  $input */
     $input = $event->getInput();
     $input->expects($this->at(0))->method('getParameterOption')->with('--' . ConsoleContextListener::OPTION_USER)->will($this->returnValue($username));
     $input->expects($this->at(1))->method('getParameterOption')->with('--' . ConsoleContextListener::OPTION_ORGANIZATION)->will($this->returnValue($organizationName));
     $this->userManager->expects($this->once())->method('findUserByUsernameOrEmail')->with($username)->will($this->returnValue($user));
     $this->organizationRepository->expects($this->once())->method('findOneBy')->with(['name' => $organizationName])->will($this->returnValue($organization));
     $this->listener->onConsoleCommand($event);
     /** @var ConsoleToken $token */
     $token = $this->securityContext->getToken();
     $this->assertNotEmpty($token);
     $this->assertInstanceOf('Oro\\Bundle\\SecurityBundle\\Authentication\\Token\\ConsoleToken', $token);
     $this->assertEquals($user, $token->getUser());
     $this->assertEquals($organization, $token->getOrganizationContext());
 }
开发者ID:xamin123,项目名称:platform,代码行数:26,代码来源:ConsoleContextListenerTest.php

示例5: testOrganizations

 public function testOrganizations()
 {
     $user = new User();
     $disabledOrganization = new Organization();
     $organization = new Organization();
     $organization->setEnabled(true);
     $user->setOrganizations(new ArrayCollection(array($organization)));
     $this->assertContains($organization, $user->getOrganizations());
     $user->removeOrganization($organization);
     $this->assertNotContains($organization, $user->getOrganizations());
     $user->addOrganization($organization);
     $this->assertContains($organization, $user->getOrganizations());
     $user->addOrganization($disabledOrganization);
     $result = $user->getOrganizations(true);
     $this->assertTrue($result->count() == 1);
     $this->assertSame($result->first(), $organization);
 }
开发者ID:xamin123,项目名称:platform,代码行数:17,代码来源:UserTest.php

示例6: setOrganizations

 /**
  * @param User $user
  * @param array $options
  * @throws InvalidArgumentException
  * @return $this
  */
 protected function setOrganizations(User $user, $options)
 {
     if (!empty($options['user-organizations'])) {
         foreach ($options['user-organizations'] as $organizationName) {
             try {
                 $organization = $this->getEntityManager()->getRepository('OroOrganizationBundle:Organization')->getOrganizationByName($organizationName);
             } catch (NoResultException $e) {
                 throw new InvalidArgumentException('Invalid organization "' . $organizationName . '" in "--user-organizations" parameter');
             }
             $user->addOrganization($organization);
         }
     }
     return $this;
 }
开发者ID:Maksold,项目名称:platform,代码行数:20,代码来源:CreateUserCommand.php


注:本文中的Oro\Bundle\UserBundle\Entity\User::addOrganization方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。