本文整理汇总了PHP中Oro\Bundle\UserBundle\Entity\User::setFirstName方法的典型用法代码示例。如果您正苦于以下问题:PHP User::setFirstName方法的具体用法?PHP User::setFirstName怎么用?PHP User::setFirstName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Oro\Bundle\UserBundle\Entity\User
的用法示例。
在下文中一共展示了User::setFirstName方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: userFullNameRetrieves
/**
* @test
*/
public function userFullNameRetrieves()
{
$firstname = 'First';
$lastname = 'Last';
$user = new User();
$user->setFirstName($firstname);
$user->setLastName($lastname);
$worklog = new Worklog(new TimeSpent(50), new \DateTime('now'), new Task(), $user, 'DUMMY_DESCRIPTION');
$this->assertEquals(sprintf('%s %s', $firstname, $lastname), $worklog->getUserFullName());
}
示例3: denormalizeShort
/**
* Short mode denormalization
*
* @param mixed $data
* @param string $class
* @param mixed $format
* @param array $context
* @return User
*/
protected function denormalizeShort($data, $class, $format = null, array $context = array())
{
$result = new User();
if (!empty($data['username'])) {
$result->setUsername($data['username']);
}
if (!empty($data['fullName'])) {
list($firstName, $lastName) = explode(' ', $data['fullName'], 2);
$result->setFirstName($firstName);
$result->setLastName($lastName);
}
return $result;
}
示例4: createUser
/**
* @param string $firstName
* @param string $lastName
*
* @return User
*/
protected function createUser($firstName, $lastName)
{
$user = new User();
$user->setOrganization($this->organization);
$user->setFirstName($firstName);
$user->setLastName($lastName);
$user->setUsername(strtolower($firstName . '.' . $lastName));
$user->setPassword(strtolower($firstName . '.' . $lastName));
$user->setEmail(strtolower($firstName . '_' . $lastName . '@example.com'));
$user->addEmail($this->email);
$this->em->persist($user);
return $user;
}
示例5: testGetVariableValues
public function testGetVariableValues()
{
$organization = new Organization();
$organization->setName('TestOrg');
$user = new User();
$user->setUsername('test');
$user->setFirstName('FirstName');
$user->setLastName('LastName');
$this->securityFacade->expects($this->once())->method('getOrganization')->will($this->returnValue($organization));
$this->securityFacade->expects($this->once())->method('getLoggedUser')->will($this->returnValue($user));
$this->nameFormatter->expects($this->once())->method('format')->with($this->identicalTo($user))->will($this->returnValue('FullName'));
$result = $this->provider->getVariableValues();
$this->assertEquals(['userName' => 'test', 'userFirstName' => 'FirstName', 'userLastName' => 'LastName', 'userFullName' => 'FullName', 'organizationName' => 'TestOrg'], $result);
}
示例6: testPreUpdate
/**
* @param object $entity
* @param bool $mockUser
* @param bool $detachedUser
* @param bool $reloadUser
*
* @dataProvider prePersistAndPreUpdateDataProvider
*/
public function testPreUpdate($entity, $mockUser = false, $detachedUser = null, $reloadUser = null)
{
$oldDate = new \DateTime('2012-12-12 12:12:12');
$oldUser = new User();
$oldUser->setFirstName('oldUser');
if ($entity instanceof ActivityList) {
$entity->setUpdatedAt($oldDate);
$entity->setEditor($oldUser);
}
$initialEntity = clone $entity;
$newUser = null;
if ($mockUser) {
$newUser = new User();
$newUser->setFirstName('newUser');
}
$this->mockSecurityContext($newUser);
$unitOfWork = $this->getMockBuilder('Doctrine\\ORM\\UnitOfWork')->setMethods(['propertyChanged', 'getEntityState'])->disableOriginalConstructor()->getMock();
$entityManager = $this->getEntityManagerMock($reloadUser, $newUser);
$entityManager->expects($this->any())->method('getUnitOfWork')->will($this->returnValue($unitOfWork));
if ($entity instanceof ActivityList) {
$callIndex = 0;
if (null !== $detachedUser) {
$unitOfWork->expects($this->at($callIndex++))->method('getEntityState')->with($newUser)->will($this->returnValue($detachedUser ? UnitOfWork::STATE_DETACHED : UnitOfWork::STATE_MANAGED));
}
$unitOfWork->expects($this->at($callIndex++))->method('propertyChanged')->with($entity, 'updatedAt', $oldDate, $this->isInstanceOf('\\DateTime'));
$unitOfWork->expects($this->at($callIndex++))->method('propertyChanged')->with($entity, 'editor', $oldUser, $newUser);
} else {
$unitOfWork->expects($this->never())->method($this->anything());
}
$changeSet = [];
$args = new PreUpdateEventArgs($entity, $entityManager, $changeSet);
$this->listener->preUpdate($args);
if (!$entity instanceof ActivityList) {
$this->assertEquals($initialEntity, $entity);
return;
}
$this->assertInstanceOf('\\DateTime', $entity->getUpdatedAt());
if ($mockUser) {
$this->assertEquals($newUser, $entity->getEditor());
} else {
$this->assertNull($entity->getEditor());
}
}
示例7: testPreUpdate
/**
* @param object $entity
* @param bool $mockUser
* @param bool $detachedUser
* @param bool $reloadUser
*
* @dataProvider prePersistAndPreUpdateDataProvider
*/
public function testPreUpdate($entity, $mockUser = false, $detachedUser = null, $reloadUser = null)
{
$oldUser = new User();
$oldUser->setFirstName('oldUser');
if ($entity instanceof Comment) {
$entity->setUpdatedBy($oldUser);
}
$initialEntity = clone $entity;
$newUser = null;
if ($mockUser) {
$newUser = new User();
$newUser->setFirstName('newUser');
}
$this->mockSecurityContext($newUser);
$unitOfWork = $this->getMockBuilder('Doctrine\\ORM\\UnitOfWork')->setMethods(['propertyChanged', 'getEntityState'])->disableOriginalConstructor()->getMock();
$entityManager = $this->getEntityManagerMock($reloadUser, $newUser);
$entityManager->expects($this->any())->method('getUnitOfWork')->will($this->returnValue($unitOfWork));
if ($entity instanceof Comment) {
$callIndex = 0;
if (null !== $detachedUser) {
$unitOfWork->expects($this->once(++$callIndex))->method('getEntityState')->with($newUser)->will($this->returnValue($detachedUser ? UnitOfWork::STATE_DETACHED : UnitOfWork::STATE_MANAGED));
}
$unitOfWork->expects($this->once(++$callIndex))->method('propertyChanged')->with($entity, 'updatedBy', $oldUser, $newUser);
} else {
$unitOfWork->expects($this->never())->method($this->anything());
}
$changeSet = array();
$args = new PreUpdateEventArgs($entity, $entityManager, $changeSet);
$this->subscriber->preUpdate($args);
if (!$entity instanceof Comment) {
$this->assertEquals($initialEntity, $entity);
return;
}
if ($mockUser) {
$this->assertEquals($newUser, $entity->getUpdatedBy());
} else {
$this->assertNull($entity->getUpdatedBy());
}
}
示例8: createMainEntity
/**
* @param string $accountName
* @param string $userFirstName
* @param string $userLastName
* @param bool $isOrder
* @return Order|Quote
*/
protected function createMainEntity($accountName, $userFirstName, $userLastName, $isOrder = false)
{
$accountUser = $this->createAccountUser($accountName);
$owner = new User();
$owner->setFirstName($userFirstName . ' owner')->setLastName($userLastName . ' owner')->setSalt(null);
$organization = new Organization();
$organization->setName($userFirstName . ' ' . $userLastName . ' org');
$entity = $isOrder ? new Order() : new Quote();
$entity->setAccount($accountUser->getAccount())->setAccountUser($accountUser)->setOwner($owner)->setOrganization($organization);
return $entity;
}
示例9: testNames
public function testNames()
{
$user = new User();
$first = 'James';
$last = 'Bond';
$user->setFirstName($first);
$user->setLastName($last);
}
示例10: testActivityOwner
public function testActivityOwner()
{
$user = new User();
$user->setFirstName('First Name');
$organization = new Organization();
$organization->setName('Organization One');
$activityOwner = new ActivityOwner();
$activityOwner->setUser($user);
$activityOwner->setOrganization($organization);
$activityList = new ActivityList();
$activityList->addActivityOwner($activityOwner);
$this->assertCount(1, $activityList->getActivityOwners());
$firstOwner = $activityList->getActivityOwners()->first();
$this->assertEquals('First Name', $firstOwner->getUser()->getFirstName());
$this->assertEquals('Organization One', $firstOwner->getOrganization()->getName());
}
示例11: getOroUsersCollection
/**
* @param int $size
* @param string $specificData
* @return array
*/
protected function getOroUsersCollection($size = 2, $specificData = '')
{
$result = array();
for ($i = 0; $i < $size; $i++) {
$user = new OroUser();
$user->setUsername("username_{$i}");
$user->setFirstName("First {$specificData}");
$user->setLastName("Last {$specificData}");
$user->setEmail("some@host{$i}.com");
$result[] = $user;
}
return $result;
}