• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP Documents\User类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



在下文中一共展示了User类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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: testSlaveOkayOnPersistentCollection

 public function testSlaveOkayOnPersistentCollection()
 {
     $user = new User();
     $user->addGroup(new Group('Test'));
     $this->dm->persist($user);
     $this->dm->flush();
     $this->dm->clear();
     $user = $this->dm->getRepository('Documents\\User')->createQueryBuilder()->slaveOkay(false)->getQuery()->getSingleResult();
     $this->assertEquals(array(), $user->getGroups()->getHints());
     $this->dm->clear();
     $users = $this->dm->getRepository('Documents\\User')->createQueryBuilder()->getQuery()->execute();
     $this->assertEquals(array(), $users->getHints());
     $users = array_values($users->toArray());
     $user = $users[0];
     $this->assertEquals(array(), $user->getGroups()->getHints());
     $this->dm->clear();
     $user = $this->dm->getRepository('Documents\\User')->createQueryBuilder()->slaveOkay(true)->getQuery()->getSingleResult();
     $this->assertEquals(array(Query::HINT_SLAVE_OKAY => true), $user->getGroups()->getHints());
     $this->dm->clear();
     $users = $this->dm->getRepository('Documents\\User')->createQueryBuilder()->getQuery()->execute()->slaveOkay(true);
     $this->assertEquals(array(Query::HINT_SLAVE_OKAY => true), $users->getHints());
     $users = array_values($users->toArray());
     $user = $users[0];
     $this->assertEquals(array(Query::HINT_SLAVE_OKAY => true), $user->getGroups()->getHints());
     $this->dm->clear();
     $user = $this->dm->getRepository('Documents\\User')->createQueryBuilder()->getQuery()->getSingleResult();
     $groups = $user->getGroups();
     $groups->setHints(array(Query::HINT_SLAVE_OKAY => true));
     $this->assertEquals(array(Query::HINT_SLAVE_OKAY => true), $groups->getHints());
 }
开发者ID:romainneutron,项目名称:mongodb-odm,代码行数:30,代码来源:SlaveOkayTest.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: setUp

 public function setUp()
 {
     parent::setUp();
     $user = new User();
     $user->addGroup(new Group('Test'));
     $this->dm->persist($user);
     $this->dm->flush();
     $this->dm->clear();
 }
开发者ID:nclavaud,项目名称:mongodb-odm,代码行数:9,代码来源:ReadPreferenceTest.php


示例5: testFindByEmbedMany

 public function testFindByEmbedMany()
 {
     $user = new User();
     $phonenumber = new Phonenumber('12345678');
     $user->addPhonenumber($phonenumber);
     $this->dm->persist($user);
     $this->dm->flush();
     $this->assertSame($user, $this->dm->getRepository(User::class)->findOneBy(['phonenumbers' => $phonenumber]));
 }
开发者ID:dominium,项目名称:mongodb-odm,代码行数:9,代码来源:DocumentRepositoryTest.php


示例6: 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


示例7: 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


示例8: testManyEmbedded

 public function testManyEmbedded()
 {
     $user = new \Documents\User();
     $user->addPhonenumber(new Phonenumber('6155139185'));
     $user->addPhonenumber(new Phonenumber('6153303769'));
     $this->dm->persist($user);
     $this->dm->flush();
     $this->dm->clear();
     $user2 = $this->dm->createQueryBuilder('Documents\\User')->field('id')->equals($user->getId())->getQuery()->getSingleResult();
     $this->assertNotNull($user2);
     $this->assertEquals($user->getPhonenumbers()->toArray(), $user2->getPhonenumbers()->toArray());
 }
开发者ID:jackbravo,项目名称:symfony-sandbox,代码行数:12,代码来源:EmbeddedTest.php


示例9: setUp

 public function setUp()
 {
     if (version_compare(phpversion('mongo'), '1.3.0', '<')) {
         $this->markTestSkipped('This test is not applicable to driver versions < 1.3.0');
     }
     parent::setUp();
     $user = new User();
     $user->addGroup(new Group('Test'));
     $this->dm->persist($user);
     $this->dm->flush();
     $this->dm->clear();
 }
开发者ID:briareos,项目名称:mongodb-odm,代码行数:12,代码来源:ReadPreferenceTest.php


示例10: 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


示例11: 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


示例12: 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


示例13: 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


示例14: createCompany

 /**
  * 创建公司
  * @param \Documents\User $user 公司的创建者
  * @return \Documents\Company - 返回的是新创建的公司的对象
  * @throws \Angel_Exception_Company
  */
 public function createCompany(\Documents\User $user)
 {
     $result = null;
     if ($user->isStartup()) {
         $company = new $this->_document_class();
         $company->owner = $user;
         $this->_dm->persist($company);
         $this->_dm->flush();
         $result = $company;
     } else {
         // 只有创业者才能创建公司
         throw new \Angel_Exception_Company(Angel_Exception_Company::ONLY_STARTUP_CAN_CREATE_COMPANY);
     }
     return $result;
 }
开发者ID:ud223,项目名称:yj,代码行数:21,代码来源:Company.php


示例15: 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


示例16: 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


示例17: 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


示例18: 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:jacques-sounvi,项目名称:addressbook,代码行数:17,代码来源:RemoveTest.php


示例19: testUnsetFromEmbeddedCollection

 public function testUnsetFromEmbeddedCollection()
 {
     $userRepository = $this->dm->getRepository('Documents\\User');
     $user = new User();
     $user->addGroup(new Group('group1'));
     $user->addGroup(new Group('group2'));
     $user->addGroup(new Group('group3'));
     $this->dm->persist($user);
     $this->dm->flush();
     $this->dm->clear();
     $this->assertCount(3, $user->getGroups());
     $user = $userRepository->find($user->getId());
     $user->getGroups()->remove(0);
     $this->dm->flush();
     $this->dm->clear();
     $user = $userRepository->find($user->getId());
     $this->assertCount(2, $user->getGroups());
 }
开发者ID:Wizkunde,项目名称:mongodb-odm,代码行数:18,代码来源:RemoveTest.php


示例20: testClonedPersistentCollectionUpdatesCorrectly

 public function testClonedPersistentCollectionUpdatesCorrectly()
 {
     $u = new User();
     $u->getPhonenumbers()->add(new Phonenumber('123456'));
     $u2 = new User();
     $u2->getPhonenumbers()->add(new Phonenumber('9876543'));
     $u2->getPhonenumbers()->add(new Phonenumber('7654321'));
     $this->dm->persist($u);
     $this->dm->persist($u2);
     $this->dm->flush();
     $u2->setPhonenumbers(clone $u->getPhonenumbers());
     $this->dm->flush();
     $this->dm->clear();
     $u = $this->dm->find(get_class($u), $u->getId());
     $this->assertCount(1, $u->getPhonenumbers());
     $u2 = $this->dm->find(get_class($u2), $u2->getId());
     $this->assertCount(1, $u2->getPhonenumbers());
     $this->assertSame('123456', $u2->getPhonenumbers()->first()->getPhonenumber());
 }
开发者ID:Wizkunde,项目名称:mongodb-odm,代码行数:19,代码来源:GH1132Test.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP ckeditor\CKEditor类代码示例发布时间:2022-05-23
下一篇:
PHP CMS\CmsUser类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap