當前位置: 首頁>>代碼示例>>PHP>>正文


PHP User::setCount方法代碼示例

本文整理匯總了PHP中Documents\User::setCount方法的典型用法代碼示例。如果您正苦於以下問題:PHP User::setCount方法的具體用法?PHP User::setCount怎麽用?PHP User::setCount使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Documents\User的用法示例。


在下文中一共展示了User::setCount方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: testDistinct

 public function testDistinct()
 {
     $user = new User();
     $user->setUsername('distinct_test');
     $user->setCount(1);
     $this->dm->persist($user);
     $user = new User();
     $user->setUsername('distinct_test');
     $user->setCount(1);
     $this->dm->persist($user);
     $user = new User();
     $user->setUsername('distinct_test');
     $user->setCount(2);
     $this->dm->persist($user);
     $user = new User();
     $user->setUsername('distinct_test');
     $user->setCount(3);
     $this->dm->persist($user);
     $this->dm->flush();
     $qb = $this->dm->createQueryBuilder('Documents\\User')->distinct('count')->field('username')->equals('distinct_test');
     $q = $qb->getQuery();
     $results = $q->execute();
     $this->assertEquals(new \Doctrine\MongoDB\ArrayIterator(array(1, 2, 3)), $results);
     $results = $this->dm->createQueryBuilder('Documents\\User')->distinct('count')->field('username')->equals('distinct_test')->getQuery()->execute();
     $this->assertEquals(new \Doctrine\MongoDB\ArrayIterator(array(1, 2, 3)), $results);
 }
開發者ID:jackbravo,項目名稱:symfony-sandbox,代碼行數:26,代碼來源:QueryTest.php

示例2: testAddGroups

 public function testAddGroups()
 {
     $account = new Account();
     $account->setName('Jon Test Account');
     $user = new User();
     $user->setUsername('jon');
     $user->setPassword('changeme');
     $user->setAccount($account);
     $user->setCount(5);
     $user->addGroup(new Group('administrator'));
     $user->addGroup(new Group('member'));
     $user->addGroup(new Group('moderator'));
     $this->dm->persist($user);
     $this->persister->expects($this->once())->method('executeInserts');
     $this->dm->getUnitOfWork()->computeChangeSets();
     $update = $this->persister->prepareUpdateData($user);
     $this->assertTrue(array_key_exists('$set', $update));
     $this->assertFalse(array_key_exists('$unset', $update));
     $this->assertTrue(array_key_exists('$pushAll', $update));
     $this->assertTrue(array_key_exists('groups', $update['$pushAll']));
     $this->assertEquals(3, count($update['$pushAll']['groups']));
     $this->assertFalse(array_key_exists('$pullAll', $update));
     $this->assertTrue(array_key_exists('$inc', $update));
     $this->assertEquals(5, $update['$inc']['count']);
     $user->setCount(20);
     $this->dm->getUnitOfWork()->computeChangeSets();
     $update = $this->persister->prepareUpdateData($user);
     $this->assertTrue(array_key_exists('$inc', $update));
     $this->assertEquals(15, $update['$inc']['count']);
     $user->setCount(5);
     $this->dm->getUnitOfWork()->computeChangeSets();
     $update = $this->persister->prepareUpdateData($user);
     $this->assertTrue(array_key_exists('$inc', $update));
     $this->assertEquals(-15, $update['$inc']['count']);
     $this->dm->flush();
 }
開發者ID:poulikov,項目名稱:mongodb-odm,代碼行數:36,代碼來源:BasicDocumentPersisterTest.php

示例3: testMultipleUpdateQuery

 public function testMultipleUpdateQuery()
 {
     $user = new User();
     $user->setUsername('multiple_test');
     $user->setCount(1);
     $this->dm->persist($user);
     $user = new User();
     $user->setUsername('multiple_test');
     $user->setCount(1);
     $this->dm->persist($user);
     $user = new User();
     $user->setUsername('multiple_test');
     $user->setCount(2);
     $this->dm->persist($user);
     $user = new User();
     $user->setUsername('multiple_test');
     $user->setCount(3);
     $this->dm->persist($user);
     $this->dm->flush();
     $qb = $this->dm->createQueryBuilder('Documents\\User')->update()->multiple()->field('username')->equals('multiple_test')->field('username')->set('foo');
     $q = $qb->getQuery();
     $results = $q->execute();
     $qb = $this->dm->createQueryBuilder('Documents\\User')->find()->field('username')->equals('foo');
     $q = $qb->getQuery();
     $users = array_values($q->execute()->toArray());
     $this->assertEquals(4, count($users));
 }
開發者ID:romainneutron,項目名稱:mongodb-odm,代碼行數:27,代碼來源:QueryTest.php

示例4: testIncrementSetsNull

 public function testIncrementSetsNull()
 {
     $user = new User();
     $user->setUsername('jon');
     $user->setCount(10);
     $this->dm->persist($user);
     $this->dm->flush();
     $this->dm->clear();
     $user = $this->dm->getRepository('Documents\\User')->findOneBy(array('username' => 'jon'));
     $this->assertEquals(10, $user->getCount());
     $user->incrementCount(1);
     $this->dm->flush();
     $this->dm->clear();
     $user = $this->dm->getRepository('Documents\\User')->findOneBy(array('username' => 'jon'));
     $this->assertEquals(11, $user->getCount());
     $user->setCount(null);
     $this->dm->flush();
     $this->dm->clear();
     $user = $this->dm->getRepository('Documents\\User')->findOneBy(array('username' => 'jon'));
     $this->assertEquals(null, $user->getCount());
 }
開發者ID:im286er,項目名稱:ent,代碼行數:21,代碼來源:FunctionalTest.php


注:本文中的Documents\User::setCount方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。