本文整理汇总了PHP中Oro\Bundle\UserBundle\Entity\User::setId方法的典型用法代码示例。如果您正苦于以下问题:PHP User::setId方法的具体用法?PHP User::setId怎么用?PHP User::setId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Oro\Bundle\UserBundle\Entity\User
的用法示例。
在下文中一共展示了User::setId方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testAddRemoveActivityOwner
/**
* Test add and remove activity owner from ActivityList
*/
public function testAddRemoveActivityOwner()
{
$activity = new ActivityList();
$activity->setId(1);
$organization = new Organization();
$user1 = new User();
$user1->setId(1);
$user1->setFirstName('TestUserName1');
$entity1 = new ActivityOwner();
$entity1->setActivity($activity);
$entity1->setUser($user1);
$entity1->setOrganization($organization);
$activity->addActivityOwner($entity1);
$user2 = new User();
$user1->setId(2);
$user2->setFirstName('TestUserName2');
$entity2 = new ActivityOwner();
$entity2->setActivity($activity);
$entity2->setUser($user2);
$entity2->setOrganization($organization);
$activity->addActivityOwner($entity2);
$this->assertTrue($activity->getActivityOwners()->contains($entity1));
$this->assertTrue($activity->getActivityOwners()->contains($entity2));
$activity->removeActivityOwner($entity1);
$activity->removeActivityOwner($entity2);
$this->assertFalse($activity->getActivityOwners()->contains($entity1));
$this->assertFalse($activity->getActivityOwners()->contains($entity2));
}
示例2: testProcessValidData
public function testProcessValidData()
{
$appendedUser = new User();
$appendedUser->setId(1);
$removedUser = new User();
$removedUser->setId(2);
$removedUser->addBusinessUnit($this->entity);
$this->form->expects($this->once())->method('setData')->with($this->entity);
$this->form->expects($this->once())->method('submit')->with($this->request);
$this->request->setMethod('POST');
$this->form->expects($this->once())->method('isValid')->will($this->returnValue(true));
$appendForm = $this->getMockBuilder('Symfony\\Component\\Form\\Form')->disableOriginalConstructor()->getMock();
$appendForm->expects($this->once())->method('getData')->will($this->returnValue(array($appendedUser)));
$this->form->expects($this->at(3))->method('get')->with('appendUsers')->will($this->returnValue($appendForm));
$removeForm = $this->getMockBuilder('Symfony\\Component\\Form\\Form')->disableOriginalConstructor()->getMock();
$removeForm->expects($this->once())->method('getData')->will($this->returnValue(array($removedUser)));
$this->form->expects($this->at(4))->method('get')->with('removeUsers')->will($this->returnValue($removeForm));
$this->manager->expects($this->at(0))->method('persist')->with($appendedUser);
$this->manager->expects($this->at(1))->method('persist')->with($removedUser);
$this->manager->expects($this->at(2))->method('persist')->with($this->entity);
$this->manager->expects($this->once())->method('flush');
$this->assertTrue($this->handler->process($this->entity));
$businessUnits = $appendedUser->getBusinessUnits()->toArray();
$this->assertCount(1, $businessUnits);
$this->assertEquals($this->entity, current($businessUnits));
$this->assertCount(0, $removedUser->getBusinessUnits()->toArray());
}
示例3: testSetUserIdAndOrganizationIds
public function testSetUserIdAndOrganizationIds()
{
$this->assertEmpty($this->securityContext->getToken());
$userId = 1;
$user = new User();
$user->setId($userId);
$organizationId = 2;
$organization = new Organization();
$organization->setId($organizationId);
$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($userId));
$input->expects($this->at(1))->method('getParameterOption')->with('--' . ConsoleContextListener::OPTION_ORGANIZATION)->will($this->returnValue($organizationId));
$this->userRepository->expects($this->once())->method('find')->with($userId)->will($this->returnValue($user));
$this->organizationRepository->expects($this->once())->method('find')->with($organizationId)->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());
}
示例4: testInitializeScopeId
public function testInitializeScopeId()
{
$user = new User();
$user->setId(123);
$token = $this->getMock('Symfony\\Component\\Security\\Core\\Authentication\\Token\\TokenInterface');
$this->securityContext->expects($this->once())->method('getToken')->willReturn($token);
$token->expects($this->once())->method('getUser')->willReturn($user);
$this->assertEquals(123, $this->manager->getScopeId());
}
示例5: testProcessEvent
public function testProcessEvent()
{
$user = new User();
$user->setId(1);
$this->configManager->expects($this->once())->method('get')->with('diamante_desk.email_notification')->will($this->returnValue(true));
$this->securityFacade->expects($this->once())->method('getLoggedUser')->will($this->returnValue($user));
$event = $this->event();
$this->notificationDeliveryManager->expects($this->once())->method('add')->with($this->logicalAnd($this->isInstanceOf('\\Diamante\\DeskBundle\\Model\\Ticket\\Notifications\\TicketNotification'), $this->attributeEqualTo('ticketUniqueId', $event->getAggregateId()), $this->attributeEqualTo('author', $user), $this->attributeEqualTo('headerText', $event->getHeaderText()), $this->attributeEqualTo('subject', $event->getSubject()), $this->attributeEqualTo('attachments', $event->attachments()), $this->attribute($this->logicalAnd($this->isInstanceOf('\\ArrayIterator'), $this->arrayHasKey('Description'), $this->contains('New Description')), 'changeList')));
$this->subscriber->processEvent($event);
}
示例6: testHasAccessEditField
/**
* @dataProvider hasAccessEditFiledDataProvider
*
* @param int $currentUserId
* @param int $userId
* @param string $fieldName
* @param bool $result
*/
public function testHasAccessEditField($currentUserId, $userId, $fieldName, $result)
{
$currentUser = $this->getMockBuilder('Oro\\Bundle\\UserBundle\\Entity\\User')->setMethods(['getId'])->disableOriginalConstructor()->getMock();
if ('enabled' === $fieldName) {
$currentUser->expects(self::once())->method('getId')->willReturn($currentUserId);
}
$this->securityFacade->expects(self::once())->method('getLoggedUser')->willReturn($currentUser);
$entity = new User();
$entity->setId($userId);
self::assertEquals($this->validator->hasAccessEditField($entity, $fieldName), $result);
}
示例7: testSendNotNewEntity
public function testSendNotNewEntity()
{
$organization = new Organization();
$organization->setId(1);
$user = new User();
$user->setId(1);
$this->emailUser->expects($this->exactly(1))->method('getOwner')->willReturn($user);
$this->emailUser->expects($this->exactly(2))->method('getOrganization')->willReturn($organization);
$this->topicPublisher->expects($this->once())->method('send')->with(WebSocketSendProcessor::getUserTopic($this->emailUser->getOwner(), $this->emailUser->getOrganization()), json_encode(['hasNewEmail' => false]));
$this->processor->send([1 => ['entity' => $this->emailUser, 'new' => 0]]);
}
示例8: getUser
/**
* @return User
*/
protected function getUser()
{
$user = new User();
/** @var \PHPUnit_Framework_MockObject_MockObject|Group $group1 */
$group1 = $this->getMock('Oro\\Bundle\\UserBundle\\Entity\\Group');
/** @var \PHPUnit_Framework_MockObject_MockObject|Group $group2 */
$group2 = $this->getMock('Oro\\Bundle\\UserBundle\\Entity\\Group');
$group1->expects($this->any())->method('getId')->will($this->returnValue(2));
$group2->expects($this->any())->method('getId')->will($this->returnValue(3));
$user->setId(1)->addGroup($group1)->addGroup($group2);
return $user;
}
示例9: testGetInvitationPermissions
/**
* @param array $params
* @param array $expected
*
* @dataProvider permissionsDataProvider
*/
public function testGetInvitationPermissions(array $params, array $expected)
{
$record = $this->getMock('Oro\\Bundle\\DataGridBundle\\Datasource\\ResultRecordInterface');
$user = new User();
$user->setId(self::ADMIN);
$this->securityFacade->expects($this->any())->method('getLoggedUser')->will($this->returnValue($user));
$record->expects($this->at(0))->method('getValue')->with('invitationStatus')->will($this->returnValue($params['invitationStatus']));
$record->expects($this->at(1))->method('getValue')->with('parentId')->will($this->returnValue($params['parentId']));
$record->expects($this->at(2))->method('getValue')->with('ownerId')->will($this->returnValue($params['ownerId']));
$record->expects($this->at(3))->method('getValue')->with('childrenCount')->will($this->returnValue($params['childrenCount']));
$result = $this->provider->getInvitationPermissions($record);
$this->assertEquals($expected, $result);
}
示例10: testAddRemoveUser
public function testAddRemoveUser()
{
$org = new Organization();
$user = new User();
$user->setId(uniqid());
$this->assertFalse($org->hasUser($user));
$org->addUser($user);
$users = $org->getUsers()->toArray();
$this->assertCount(1, $users);
$this->assertTrue($org->hasUser($user));
$this->assertEquals($user, reset($users));
$org->removeUser($user);
$this->assertFalse($org->hasUser($user));
}
示例11: testReverseTransform
public function testReverseTransform()
{
$this->assertSame([], $this->transformer->reverseTransform(null));
$this->assertSame([], $this->transformer->reverseTransform([]));
$organizationId = 42;
$firstUser = new User();
$firstUser->setId(1)->setUsername('1');
$secondUser = new User();
$secondUser->setId(2)->setUsername('2');
$firstCalendar = new Calendar();
$this->securityFacade->expects($this->any())->method('getOrganizationId')->will($this->returnValue($organizationId));
$calendarRepository = $this->getMockBuilder('Oro\\Bundle\\CalendarBundle\\Entity\\Repository\\CalendarRepository')->disableOriginalConstructor()->getMock();
$calendarRepository->expects($this->once())->method('findDefaultCalendars')->with([1, 2], $organizationId)->will($this->returnValue([$firstCalendar]));
$this->registry->expects($this->any())->method('getRepository')->with('OroCalendarBundle:Calendar')->will($this->returnValue($calendarRepository));
$events = $this->transformer->reverseTransform([$firstUser, $secondUser]);
$this->assertCount(1, $events);
/** @var CalendarEvent $event */
$event = $events->first();
$this->assertInstanceOf('Oro\\Bundle\\CalendarBundle\\Entity\\CalendarEvent', $event);
$this->assertEquals($firstCalendar, $event->getCalendar());
}
示例12: testAddEntityFields
/**
* @dataProvider addEntityFieldsDataProvider
* @param $permissions
* @param $isMyProfile
*/
public function testAddEntityFields($permissions, $isMyProfile)
{
$user = new User();
$user->setId(1);
$order = 0;
foreach ($permissions as $rule => $isGranted) {
$this->securityFacade->expects($this->at($order))->method('isGranted')->with($rule)->will($this->returnValue($isGranted));
$order++;
}
$request = new Request();
$request->attributes->add(array('_route' => $isMyProfile ? self::MY_PROFILE_ROUTE : self::OTHER_PROFILE_ROUTE));
$formFactory = $this->getMockBuilder('Symfony\\Component\\Form\\FormFactory')->disableOriginalConstructor()->getMock();
$userSubscriber = new UserSubscriber($formFactory, $this->securityInterface);
$order = 0;
$builder = $this->getMockBuilder('Symfony\\Component\\Form\\FormBuilder')->disableOriginalConstructor()->setMethods(array('addEventSubscriber', 'add', 'getFormFactory'))->getMock();
$builder->expects($this->at($order))->method('getFormFactory')->will($this->returnValue($formFactory));
$builder->expects($this->at(++$order))->method('addEventSubscriber')->with($userSubscriber)->will($this->returnSelf());
$this->mockSetDefaultUserFields($builder, $order);
if ($permissions[self::RULE_ROLE]) {
$builder->expects($this->at(++$order))->method('add')->with('roles', 'entity')->will($this->returnValue($builder));
}
if ($permissions[self::RULE_GROUP]) {
$arr = array('label' => 'oro.user.groups.label', 'class' => 'OroUserBundle:Group', 'property' => 'name', 'multiple' => true, 'expanded' => true, 'required' => false, 'read_only' => $isMyProfile, 'disabled' => $isMyProfile);
$builder->expects($this->at(++$order))->method('add')->with('groups', 'entity', $arr)->will($this->returnValue($builder));
}
if ($permissions[self::RULE_BUSINESS_UNIT] && $permissions[self::RULE_ORGANIZATION]) {
$builder->expects($this->at(++$order))->method('add')->with('organizations', 'oro_organizations_select')->will($this->returnValue($builder));
}
$builder->expects($this->at(++$order))->method('add')->with('plainPassword', 'repeated')->will($this->returnValue($builder));
$builder->expects($this->at(++$order))->method('add')->with('emails', 'collection')->will($this->returnValue($builder));
$builder->expects($this->at(++$order))->method('add')->with('tags', 'oro_tag_select')->will($this->returnValue($builder));
$builder->expects($this->at(++$order))->method('add')->with('imapConfiguration', 'oro_imap_configuration')->will($this->returnValue($builder));
$builder->expects($this->at(++$order))->method('add')->with('change_password', 'oro_change_password')->will($this->returnValue($builder));
$builder->expects($this->at(++$order))->method('add')->with('avatar', 'oro_image')->will($this->returnValue($builder));
$builder->expects($this->at(++$order))->method('add')->with('inviteUser', 'checkbox')->will($this->returnValue($builder));
$type = new UserType($this->securityInterface, $this->securityFacade, $request);
$type->buildForm($builder, []);
}
示例13: testFlush
public function testFlush()
{
$changesetAnswer = ['seen' => true];
$user1 = new User();
$user1->setId(1);
$user2 = new User();
$user2->setId(2);
$emailUser1 = new EmailUser();
$emailUser1->setOwner($user1);
$emailUser2 = new EmailUser();
$emailUser2->setOwner($user2);
$emailUserArray = [$emailUser1, $emailUser2, $emailUser1];
$onFlushEventArgs = $this->getMockBuilder('Doctrine\\ORM\\Event\\OnFlushEventArgs')->setMethods(['getEntityManager', 'getUnitOfWork', 'getScheduledEntityInsertions', 'getScheduledEntityUpdates', 'getEntityChangeSet'])->disableOriginalConstructor()->getMock();
$onFlushEventArgs->expects($this->once())->method('getEntityManager')->will($this->returnValue($onFlushEventArgs));
$onFlushEventArgs->expects($this->once())->method('getUnitOfWork')->will($this->returnValue($onFlushEventArgs));
$onFlushEventArgs->expects($this->exactly(3))->method('getEntityChangeSet')->will($this->returnValue($changesetAnswer));
$onFlushEventArgs->expects($this->once())->method('getScheduledEntityInsertions')->will($this->returnValue($emailUserArray));
$onFlushEventArgs->expects($this->once())->method('getScheduledEntityUpdates')->will($this->returnValue($emailUserArray));
$this->processor->expects($this->exactly(1))->method('send')->with([$user1->getId() => ['entity' => $emailUser1, 'new' => 2], $user2->getId() => ['entity' => $emailUser2, 'new' => 1]]);
$postFlushEventArgs = $this->getMockBuilder('Doctrine\\ORM\\Event\\PostFlushEventArgs')->disableOriginalConstructor()->getMock();
$this->listener->onFlush($onFlushEventArgs);
$this->listener->postFlush($postFlushEventArgs);
}
示例14: getTestUser
protected function getTestUser()
{
$user = new User();
$user->setId(1);
$user->setEmail('test_user@test.com');
$user->setSalt('1fqvkjskgry8s8cs400840c0ok8ggck');
return $user;
}
示例15: testForecastOfOpportunitiesValuesWithBusinessUnits
public function testForecastOfOpportunitiesValuesWithBusinessUnits()
{
$user = new User();
$user->setId(1);
$businessUnit = new BusinessUnit();
$businessUnit->addUser($user);
$options = ['owners' => [], 'businessUnits' => [$businessUnit]];
$widgetOptions = new WidgetOptionBag($options);
$this->opportunityRepository->expects($this->any())->method('getForecastOfOpporunitiesData')->with([$user->getId()], null, $this->aclHelper)->will($this->returnValue(['inProgressCount' => 5, 'budgetAmount' => 1000, 'weightedForecast' => 500]));
$this->businessUnitRepository->expects($this->any())->method('findById')->will($this->returnValue([$businessUnit]));
$result = $this->provider->getForecastOfOpportunitiesValues($widgetOptions, 'getInProgressValues', 'integer', false);
$this->assertEquals(['value' => 5], $result);
$result = $this->provider->getForecastOfOpportunitiesValues($widgetOptions, 'getTotalForecastValues', 'currency', false);
$this->assertEquals(['value' => 1000], $result);
$result = $this->provider->getForecastOfOpportunitiesValues($widgetOptions, 'getWeightedForecastValues', 'currency', false);
$this->assertEquals(['value' => 500], $result);
}