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


PHP User::setUsername方法代码示例

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


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

示例1: setUp

 public function setUp()
 {
     parent::setUp();
     $this->ids = array();
     $groupA = new Group('groupA');
     $groupB = new Group('groupB');
     $profile = new Profile();
     $profile->setFirstname('Timothy');
     $tim = new User();
     $tim->setUsername('Tim');
     $tim->setHits(10);
     $tim->addGroup($groupA);
     $tim->addGroup($groupB);
     $tim->setProfile($profile);
     $this->dm->persist($tim);
     $john = new User();
     $john->setUsername('John');
     $john->setHits(10);
     $this->dm->persist($john);
     $this->dm->flush();
     $this->dm->clear();
     $this->ids['tim'] = $tim->getId();
     $this->ids['john'] = $john->getId();
     $this->fc = $this->dm->getFilterCollection();
 }
开发者ID:Wizkunde,项目名称:mongodb-odm,代码行数:25,代码来源:FilterTest.php

示例2: testFlushOptions

 public function testFlushOptions()
 {
     $user = new User();
     $user->setUsername('jwage');
     $this->dm->persist($user);
     $this->dm->flush(null, array('safe' => true));
     $user->setUsername('ok');
     $this->dm->flush(null, array('safe' => true));
 }
开发者ID:romainneutron,项目名称:mongodb-odm,代码行数:9,代码来源:FlushOptionsTest.php

示例3: testFlushOptions

 public function testFlushOptions()
 {
     $user = new User();
     $user->setUsername('jwage');
     $this->dm->persist($user);
     $this->dm->flush();
     $user->setUsername('ok');
     $this->dm->flush();
 }
开发者ID:Wizkunde,项目名称:mongodb-odm,代码行数:9,代码来源:FlushOptionsTest.php

示例4: testDetatchNewDocumentDuringOnFlush

 public function testDetatchNewDocumentDuringOnFlush()
 {
     // create a test document
     $test = new User();
     $test->setUsername('toby');
     $this->dm->persist($test);
     $this->dm->flush();
     $this->dm->clear();
     $repository = $this->dm->getRepository(get_class($test));
     $test = $repository->find($test->getId());
     $this->assertNull($test);
 }
开发者ID:nclavaud,项目名称:mongodb-odm,代码行数:12,代码来源:MODM167Test.php

示例5: testFindAndModifyAlt

 public function testFindAndModifyAlt()
 {
     $doc = new User();
     $doc->setUsername('jwage');
     $this->dm->persist($doc);
     $this->dm->flush();
     // test update findAndModify
     $q = $this->dm->createQueryBuilder()->findAndUpdate('Documents\\User')->returnNew(true)->field('username')->equals('jwage')->field('username')->set('Romain Neutron')->getQuery();
     $result = $q->execute();
     // Test the username was set
     $this->assertEquals('Romain Neutron', $result->getUsername());
 }
开发者ID:nclavaud,项目名称:mongodb-odm,代码行数:12,代码来源:FindAndModifyTest.php

示例6: testCountFoundOnlyBehavior

 public function testCountFoundOnlyBehavior()
 {
     $usernames = array('David', 'Xander', 'Alex', 'Kris', 'Jon');
     foreach ($usernames as $username) {
         $user = new User();
         $user->setUsername($username);
         $this->dm->persist($user);
     }
     $this->dm->flush();
     $cursor = $this->dm->createQueryBuilder('Documents\\User')->sort('username', 'asc')->limit(2)->getQuery()->execute();
     $this->assertEquals(5, $cursor->count());
     $this->assertEquals(2, $cursor->count(true));
 }
开发者ID:Wizkunde,项目名称:mongodb-odm,代码行数:13,代码来源:CursorTest.php

示例7: testOneReference

 public function testOneReference()
 {
     $account = new Account();
     $account->setName('Test Account');
     $user = new User();
     $user->setUsername('jwage');
     $user->setAccount($account);
     $this->dm->persist($user);
     $this->dm->flush();
     $this->dm->flush();
     $this->dm->clear();
     $accountId = $user->getAccount()->getId();
     $user2 = $this->dm->createQuery('Documents\\User')->where('id', $user->getId())->getSingleResult();
 }
开发者ID:poulikov,项目名称:mongodb-odm,代码行数:14,代码来源:ReferencesTest.php

示例8: testDetach

 public function testDetach()
 {
     $user = new User();
     $user->setUsername('jon');
     $user->setPassword('changeme');
     $this->dm->persist($user);
     $this->dm->flush();
     $user->setUsername('whoop');
     $this->dm->detach($user);
     $this->dm->flush();
     $this->dm->clear();
     $user2 = $this->dm->find('Documents\\User', $user->getId());
     $this->assertEquals('jon', $user2->getUsername());
 }
开发者ID:poulikov,项目名称:mongodb-odm,代码行数:14,代码来源:PersistingTest.php

示例9: testDates

 public function testDates()
 {
     $user = new User();
     $user->setUsername('w00ting');
     $this->dm->persist($user);
     $this->dm->flush();
     $this->assertTrue($user->getCreatedAt() instanceof \DateTime);
     $user->setCreatedAt('1985-09-01 00:00:00');
     $this->dm->flush();
     $this->dm->clear();
     $user = $this->dm->getRepository('Documents\\User')->findOneByUsername('w00ting');
     $this->assertEquals('w00ting', $user->getUsername());
     $this->assertTrue($user->getCreatedAt() instanceof \DateTime);
     $this->assertEquals('09/01/1985', $user->getCreatedAt()->format('m/d/Y'));
 }
开发者ID:jacques-sounvi,项目名称:addressbook,代码行数:15,代码来源:DateTest.php

示例10: testOldDate

 public function testOldDate()
 {
     $user = new User();
     $user->setUsername('datetest');
     $user->setCreatedAt('1900-01-01');
     $this->dm->persist($user);
     $this->dm->flush();
     $user->setUsername('datetest2');
     $this->dm->flush();
     $this->dm->clear();
     $test = $this->dm->getDocumentCollection('Documents\\User')->findOne(array('username' => 'datetest2'));
     $this->assertTrue(isset($test['createdAt']));
     $user = $this->dm->getRepository('Documents\\User')->findOneBy(array('username' => 'datetest2'));
     $this->assertTrue($user->getCreatedAt() instanceof \DateTime);
     $this->assertEquals('1900-01-01', $user->getCreatedAt()->format('Y-m-d'));
 }
开发者ID:jackbravo,项目名称:symfony-sandbox,代码行数:16,代码来源:DateTest.php

示例11: testOneReference

 public function testOneReference()
 {
     $account = new Account();
     $account->setName('Test Account');
     $user = new User();
     $user->setUsername('jwage');
     $user->setAccount($account);
     $this->dm->persist($user);
     $this->dm->flush();
     $this->dm->flush();
     $this->dm->clear();
     $accountId = $user->getAccount()->getId();
     $qb = $this->dm->createQueryBuilder('Documents\\User')->field('id')->equals($user->getId());
     $query = $qb->getQuery();
     $user2 = $query->getSingleResult();
 }
开发者ID:jackbravo,项目名称:symfony-sandbox,代码行数:16,代码来源:ReferencesTest.php

示例12: testRemove

 public function testRemove()
 {
     $account = new Account();
     $account->setName('Jon Test Account');
     $user = new User();
     $user->setUsername('jon');
     $user->setPassword('changeme');
     $user->setAccount($account);
     $this->dm->persist($user);
     $this->dm->flush();
     $this->dm->remove($user);
     $this->dm->flush();
     $account = $this->dm->find('Documents\\Account', $account->getId());
     $this->assertNull($account);
     $user = $this->dm->find('Documents\\User', $user->getId());
     $this->assertNull($user);
 }
开发者ID:Wizkunde,项目名称:mongodb-odm,代码行数:17,代码来源:RemoveTest.php

示例13: testInsertIncludesAllNestedCollections

 public function testInsertIncludesAllNestedCollections()
 {
     $user = new User();
     $user->setUsername('malarzm');
     $privateBook = new Phonebook('Private');
     $privateBook->addPhonenumber(new Phonenumber('12345678'));
     $user->addPhonebook($privateBook);
     $this->dm->persist($user);
     $this->dm->flush();
     $this->assertCount(1, $this->ql, 'Inserting a document includes all nested collections and requires one query');
     $this->dm->clear();
     $user = $this->dm->find(get_class($user), $user->getId());
     $this->assertEquals('malarzm', $user->getUsername());
     $this->assertCount(1, $user->getPhonebooks());
     $this->assertEquals('Private', $user->getPhonebooks()->first()->getTitle());
     $this->assertCount(1, $user->getPhonebooks()->first()->getPhonenumbers());
     $this->assertEquals('12345678', $user->getPhonebooks()->first()->getPhonenumbers()->first()->getPhonenumber());
 }
开发者ID:Wizkunde,项目名称:mongodb-odm,代码行数:18,代码来源:CommitImprovementTest.php

示例14: testUnsetFromEmbeddedCollection

 public function testUnsetFromEmbeddedCollection()
 {
     $user = new User();
     $user->setUsername('jon');
     $user->addGroup(new Group('test group 1'));
     $user->addGroup(new Group('test group 2'));
     $user->addGroup(new Group('test group 3'));
     $this->dm->persist($user);
     $this->dm->flush();
     $this->dm->clear();
     $user = $this->dm->find('Documents\\User', $user->getId());
     $groups = $user->getGroups();
     unset($groups[0]);
     $this->assertEquals(2, count($user->getGroups()));
     $this->dm->flush();
     $this->dm->clear();
     $user = $this->dm->getRepository('Documents\\User')->findOneBy(array('username' => 'jon'));
     $this->assertEquals(2, count($user->getGroups()));
 }
开发者ID:jackbravo,项目名称:symfony-sandbox,代码行数:19,代码来源:RemoveTest.php

示例15: testUpdateCollectionDuringOnFlushAndRecomputSingleDocumentChangeSet

 public function testUpdateCollectionDuringOnFlushAndRecomputSingleDocumentChangeSet()
 {
     // create a test document
     $test = new User();
     $test->setUsername('toby');
     $test->addPhonenumber(new Phonenumber('1111'));
     $this->dm->persist($test);
     $this->dm->flush();
     $test->setUsername('lucy');
     $this->dm->flush();
     $this->dm->clear();
     $repository = $this->dm->getRepository(get_class($test));
     $test = $repository->findOneBy(array('username' => 'lucy'));
     $phonenumbers = array();
     foreach ($test->getPhonenumbers() as $phonenumber) {
         $phonenumbers[] = $phonenumber->getPhonenumber();
     }
     sort($phonenumbers);
     $this->assertEquals(array('1111', '2222'), $phonenumbers);
 }
开发者ID:Wizkunde,项目名称:mongodb-odm,代码行数:20,代码来源:MODM166Test.php


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