当前位置: 首页>>代码示例>>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;未经允许,请勿转载。