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


PHP Documents\User类代码示例

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


在下文中一共展示了User类的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: 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


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