本文整理汇总了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();
}
示例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));
}
示例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: 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);
}
示例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());
}
示例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));
}
示例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();
}
示例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());
}
示例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'));
}
示例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'));
}
示例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();
}
示例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);
}
示例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());
}
示例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()));
}
示例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);
}