本文整理汇总了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();
}
示例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());
}
示例3: testFlushOptions
public function testFlushOptions()
{
$user = new User();
$user->setUsername('jwage');
$this->dm->persist($user);
$this->dm->flush();
$user->setUsername('ok');
$this->dm->flush();
}
示例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();
}
示例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]));
}
示例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));
}
示例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());
}
示例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());
}
示例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();
}
示例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);
}
示例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));
}
示例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();
}
示例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());
}
示例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;
}
示例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'));
}