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


PHP User::addPhonenumber方法代码示例

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


在下文中一共展示了User::addPhonenumber方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testManyEmbeddedReference

 public function testManyEmbeddedReference()
 {
     $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->createQuery('Documents\\User')->where('id', $user->getId())->getSingleResult();
     $this->assertEquals($user->getPhonenumbers(), $user2->getPhonenumbers());
 }
开发者ID:poulikov,项目名称:mongodb-odm,代码行数:11,代码来源:ReferencesTest.php

示例2: 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

示例3: 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

示例4: testAddElemMatch

 public function testAddElemMatch()
 {
     $user = new User();
     $user->setUsername('boo');
     $phonenumber = new Phonenumber('6155139185');
     $user->addPhonenumber($phonenumber);
     $this->dm->persist($user);
     $this->dm->flush();
     $qb = $this->dm->createQueryBuilder('Documents\\User');
     $qb->field('phonenumbers')->elemMatch($qb->expr()->field('phonenumber')->equals('6155139185'));
     $query = $qb->getQuery();
     $user = $query->getSingleResult();
     $this->assertNotNull($user);
 }
开发者ID:jackbravo,项目名称:symfony-sandbox,代码行数:14,代码来源:QueryTest.php

示例5: testAddElemMatchWithDeepFields

 public function testAddElemMatchWithDeepFields()
 {
     $user1 = new User();
     $user1->setUsername('ben');
     $user2 = new User();
     $user2->setUsername('boo');
     $phonenumber = new Phonenumber('2125550123', $user1);
     $user2->addPhonenumber($phonenumber);
     $this->dm->persist($user1);
     $this->dm->persist($user2);
     $this->dm->flush();
     $qb = $this->dm->createQueryBuilder('Documents\\User');
     $embeddedQb = $this->dm->createQueryBuilder('Documents\\Phonenumber');
     $qb->field('phonenumbers')->elemMatch($embeddedQb->expr()->field('lastCalledBy.$id')->equals(new \MongoId($user1->getId())));
     $query = $qb->getQuery();
     $user = $query->getSingleResult();
     $this->assertNotNull($user);
 }
开发者ID:romainneutron,项目名称:mongodb-odm,代码行数:18,代码来源:QueryTest.php

示例6: 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);
 }
开发者ID:Wizkunde,项目名称:mongodb-odm,代码行数:20,代码来源:MODM166Test.php

示例7: testRemoveEmbeddedDocument

 public function testRemoveEmbeddedDocument()
 {
     $address = new Address();
     $address->setAddress('6512 Mercomatic Ct.');
     $user = new User();
     $user->setUsername('jwagettt');
     $user->setAddress($address);
     $user->addPhonenumber(new Phonenumber('6155139185'));
     $user->addPhonenumber(new Phonenumber('6155139185'));
     $this->dm->persist($user);
     $this->dm->flush();
     $user->removeAddress();
     $user->getPhonenumbers()->remove(0);
     $user->getPhonenumbers()->remove(1);
     $this->dm->flush();
     $check = $this->dm->getDocumentCollection('Documents\\User')->findOne();
     $this->assertEmpty($check['phonenumbers']);
     $this->assertFalse(isset($check['address']));
 }
开发者ID:Wizkunde,项目名称:mongodb-odm,代码行数:19,代码来源:EmbeddedTest.php

示例8: testPrimeEmbeddedReferenceOneLevelDeep

 public function testPrimeEmbeddedReferenceOneLevelDeep()
 {
     $user1 = new User();
     $user2 = new User();
     $phone = new Phonenumber('555-GET-THIS', $user2);
     $user1->addPhonenumber($phone);
     $user1->setUsername('SomeName');
     $this->dm->persist($user1);
     $this->dm->persist($user2);
     $this->dm->flush();
     $this->dm->clear();
     $qb = $this->dm->createQueryBuilder('Documents\\User')->field('username')->equals('SomeName')->field('phonenumbers.lastCalledBy')->prime(true);
     $user = $qb->getQuery()->getSingleResult();
     $phonenumbers = $user->getPhonenumbers();
     $this->assertCount(1, $phonenumbers);
     $phonenumber = $phonenumbers->current();
     $this->assertNotInstanceOf('Doctrine\\ODM\\MongoDB\\Proxy\\Proxy', $phonenumber);
     $this->assertInstanceOf('Documents\\Phonenumber', $phonenumber);
 }
开发者ID:alcaeus,项目名称:mongodb-odm,代码行数:19,代码来源:ReferencePrimerTest.php

示例9: testSchedulingCollectionDeletionAfterSchedulingForUpdate

 public function testSchedulingCollectionDeletionAfterSchedulingForUpdate()
 {
     $user = new User();
     $user->addPhonenumber(new Phonenumber('12345678'));
     $this->dm->persist($user);
     $this->dm->flush();
     $user->addPhonenumber(new Phonenumber('87654321'));
     $this->uow->computeChangeSet($this->dm->getClassMetadata(get_class($user)), $user);
     $this->assertTrue($this->uow->isCollectionScheduledForUpdate($user->getPhonenumbers()));
     $this->assertFalse($this->uow->isCollectionScheduledForDeletion($user->getPhonenumbers()));
     $user->getPhonenumbers()->clear();
     $this->uow->computeChangeSet($this->dm->getClassMetadata(get_class($user)), $user);
     $this->assertFalse($this->uow->isCollectionScheduledForUpdate($user->getPhonenumbers()));
     $this->assertTrue($this->uow->isCollectionScheduledForDeletion($user->getPhonenumbers()));
     $this->ql->clear();
     $this->dm->flush();
     $this->dm->clear();
     $user = $this->dm->find(get_class($user), $user->getId());
     $this->assertCount(0, $user->getPhonenumbers());
 }
开发者ID:Wizkunde,项目名称:mongodb-odm,代码行数:20,代码来源:CommitImprovementTest.php

示例10: Configuration

$classLoader->register();
$config = new Configuration();
/*
$config->setLoggerCallable(function(array $log) {
    print_r($log);
});
$config->setMetadataCacheImpl(new ApcCache());
*/
$config->setProxyDir(__DIR__ . '/Proxies');
$config->setProxyNamespace('Proxies');
$reader = new AnnotationReader();
$reader->setDefaultAnnotationNamespace('Doctrine\\ODM\\MongoDB\\Mapping\\');
$config->setMetadataDriverImpl(new AnnotationDriver($reader, __DIR__ . '/Documents'));
//$config->setMetadataDriverImpl(new XmlDriver(__DIR__ . '/xml'));
//$config->setMetadataDriverImpl(new YamlDriver(__DIR__ . '/yaml'));
//$config->setMetadataDriverImpl(new PHPDriver());
$dm = DocumentManager::create(new Mongo(), $config);
$profile = new Profile();
$profile->setName('Jonathan H. Wage');
$profile->addSong(new Song('Testinfuckckcg'));
$user = new User();
$user->setUsername('jwage');
$user->setPassword('changeme');
$user->addPhonenumber(new Phonenumber('6155139185'));
$user->setProfile($profile);
$configuration = new ConfigurationDoc();
$configuration->setTimezone('Eastern');
$configuration->setTheme('doctrine');
$user->setConfiguration($configuration);
$dm->persist($user);
$dm->flush();
开发者ID:jacques-sounvi,项目名称:addressbook,代码行数:31,代码来源:example.php


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