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


PHP DocumentManager::flush方法代码示例

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


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

示例1: testLuceneIndexing

 public function testLuceneIndexing()
 {
     $this->dm->getConfiguration()->addDesignDocument('lucene_users', 'Doctrine\\Tests\\ODM\\CouchDB\\Functional\\LuceneQueryDesignDoc', array());
     $query = $this->dm->createLuceneQuery('lucene_users', 'by_name');
     $response = $query->createDesignDocument();
     $user1 = new \Doctrine\Tests\Models\CMS\CmsUser();
     $user1->username = "beberlei";
     $user1->status = "active";
     $user1->name = "Benjamin";
     $user2 = new \Doctrine\Tests\Models\CMS\CmsUser();
     $user2->username = "lsmith";
     $user2->status = "active";
     $user2->name = "Lukas";
     $this->dm->persist($user1);
     $this->dm->persist($user2);
     $this->dm->flush();
     $query->setQuery("Lukas");
     try {
         $result = $query->execute();
     } catch (\Doctrine\CouchDB\HTTP\HTTPException $e) {
         if ($e->getCode() == 404) {
             $this->markTestSkipped("Lucene is not integrated");
         } else {
             throw $e;
         }
     }
     $this->assertEquals(1, count($result));
     foreach ($result as $user) {
         $this->assertEquals($user2->id, $user['id']);
         $this->assertEquals(1, $user['score']);
     }
     $query->setIncludeDocs(true)->setDocumentName('Doctrine\\Tests\\Models\\CMS\\CmsUser');
     $result = $query->execute();
     $this->assertSame($user2, $result[0]['doc']);
 }
开发者ID:kevinyien,项目名称:couchdb-odm,代码行数:35,代码来源:LuceneQueryTest.php

示例2: testReferenceOneDifferentTargetDocuments

 public function testReferenceOneDifferentTargetDocuments()
 {
     $ref1 = new MODEL\RefType1TestObj();
     $ref1->id = '/functional/ref1';
     $ref1->name = 'Ref1';
     $ref2 = new MODEL\RefType2TestObj();
     $ref2->id = '/functional/ref2';
     $ref2->name = 'Ref2';
     $this->dm->persist($ref1);
     $this->dm->persist($ref2);
     $referer1 = new ReferenceOneObj();
     $referer1->id = '/functional/referer1';
     $referer1->reference = $ref1;
     $this->dm->persist($referer1);
     $referer2 = new ReferenceOneObj();
     $referer2->id = '/functional/referer2';
     $referer2->reference = $ref2;
     $this->dm->persist($referer2);
     $this->dm->flush();
     $this->dm->clear();
     $referer = $this->dm->find('Doctrine\\Tests\\ODM\\PHPCR\\Functional\\ReferenceOneObj', '/functional/referer1');
     $this->assertTrue($referer->reference instanceof MODEL\RefType1TestObj);
     $referer = $this->dm->find('Doctrine\\Tests\\ODM\\PHPCR\\Functional\\ReferenceOneObj', '/functional/referer2');
     $this->assertTrue($referer->reference instanceof MODEL\RefType2TestObj);
 }
开发者ID:nicam,项目名称:phpcr-odm,代码行数:25,代码来源:TargetDocumentTest.php

示例3: testPropertyname

 public function testPropertyname()
 {
     $doc = new PropertyTestObj();
     $doc->id = '/functional/p';
     $doc->string = 'astring';
     $doc->long = 123;
     $doc->int = 321;
     $doc->decimal = '343';
     $doc->double = 3.14;
     $doc->float = 2.8;
     $date = new \DateTime();
     $doc->date = $date;
     $doc->boolean = true;
     $doc->name = 'aname';
     $doc->path = '../';
     $doc->uri = 'http://cmf.symfony.com:8080/about.html#there';
     $this->dm->persist($doc);
     $this->dm->flush();
     $this->dm->clear();
     $this->assertTrue($this->node->getNode('p')->hasProperty('string'));
     $this->assertTrue($this->node->getNode('p')->hasProperty('long'));
     $this->assertTrue($this->node->getNode('p')->hasProperty('int'));
     $this->assertTrue($this->node->getNode('p')->hasProperty('decimal'));
     $this->assertTrue($this->node->getNode('p')->hasProperty('double'));
     $this->assertTrue($this->node->getNode('p')->hasProperty('float'));
     $this->assertTrue($this->node->getNode('p')->hasProperty('date'));
     $this->assertTrue($this->node->getNode('p')->hasProperty('boolean'));
     $this->assertTrue($this->node->getNode('p')->hasProperty('name'));
     $this->assertTrue($this->node->getNode('p')->hasProperty('path'));
     $this->assertTrue($this->node->getNode('p')->hasProperty('uri'));
     $doc = $this->dm->find($this->type, '/functional/p');
     $this->assertNotNull($doc->string);
     $this->assertEquals('astring', $doc->string);
     $this->assertNotNull($doc->long);
     $this->assertEquals(123, $doc->long);
     $this->assertNotNull($doc->int);
     $this->assertEquals(321, $doc->int);
     $this->assertNotNull($doc->decimal);
     $this->assertEquals('343', $doc->decimal);
     $this->assertNotNull($doc->double);
     $this->assertEquals(3.14, $doc->double);
     $this->assertNotNull($doc->float);
     $this->assertEquals(2.8, $doc->float);
     $this->assertNotNull($doc->date);
     $this->assertEquals($date->getTimestamp(), $doc->date->getTimestamp());
     $this->assertNotNull($doc->boolean);
     $this->assertEquals(true, $doc->boolean);
     $this->assertNotNull($doc->name);
     $this->assertEquals('aname', $doc->name);
     $this->assertNotNull($doc->path);
     $this->assertEquals('../', $doc->path);
     $this->assertNotNull($doc->uri);
     $this->assertEquals('http://cmf.symfony.com:8080/about.html#there', $doc->uri);
 }
开发者ID:nicam,项目名称:phpcr-odm,代码行数:54,代码来源:PropertyTest.php

示例4: testCreateFromFile

 public function testCreateFromFile()
 {
     $parent = new FixPHPCR1TestObj();
     $parent->id = '/functional/filetest';
     $this->dm->persist($parent);
     $parent->file = new File();
     $parent->file->setFileContentFromFilesystem(dirname(__FILE__) . '/_files/foo.txt');
     $this->dm->flush();
     $this->dm->clear();
     $this->assertTrue($this->node->getNode('filetest')->hasNode('file'));
     $this->assertTrue($this->node->getNode('filetest')->getNode('file')->hasNode('jcr:content'));
     $this->assertTrue($this->node->getNode('filetest')->getNode('file')->getNode('jcr:content')->hasProperty('jcr:data'));
 }
开发者ID:nicam,项目名称:phpcr-odm,代码行数:13,代码来源:FixPHPCR1Test.php

示例5: testCreatedDate

 public function testCreatedDate()
 {
     $parent = new FileTestObj();
     $parent->file = new File();
     $parent->id = '/functional/filetest';
     $parent->file->setFileContentFromFilesystem(dirname(__FILE__) . '/_files/foo.txt');
     $this->dm->persist($parent);
     $this->dm->flush();
     $this->dm->clear();
     $file = $this->dm->find('Doctrine\\ODM\\PHPCR\\Document\\File', '/functional/filetest/file');
     $this->assertNotNull($file);
     $this->assertNotNull($file->getCreated());
 }
开发者ID:nicam,项目名称:phpcr-odm,代码行数:13,代码来源:FileTest.php

示例6: testReorderChildren

 public function testReorderChildren()
 {
     $this->testModifyChildren();
     try {
         $parent = $this->dm->find('Doctrine\\Tests\\ODM\\PHPCR\\Functional\\ChildrenTestObj', '/functional/parent');
         $this->assertCount(2, $parent->allChildren);
         $data = array('child-g' => $parent->allChildren->last(), 'child-f' => $parent->allChildren->first());
         $parent->allChildren = new ArrayCollection($data);
         $this->dm->flush();
         $this->dm->clear();
         $parent = $this->dm->find('Doctrine\\Tests\\ODM\\PHPCR\\Functional\\ChildrenTestObj', '/functional/parent');
         $this->assertCount(count($data), $parent->allChildren);
         $this->assertEquals(array_keys($data), $parent->allChildren->getKeys());
         $child1 = new ChildrenTestObj();
         $child1->name = 'Child H';
         $child2 = new ChildrenTestObj();
         $child2->name = 'Child I';
         $child3 = new ChildrenTestObj();
         $child3->name = 'Child J';
         $data = array('child-i' => $child2, 'child-h' => $child1, 'child-f' => $parent->allChildren->last(), 'child-g' => $parent->allChildren->first(), 'child-j' => $child3);
         $parent->allChildren = new ArrayCollection($data);
         $this->dm->flush();
         $this->dm->clear();
         $parent = $this->dm->find('Doctrine\\Tests\\ODM\\PHPCR\\Functional\\ChildrenTestObj', '/functional/parent');
         $this->assertCount(count($data), $parent->allChildren);
         $this->assertEquals(array_keys($data), $parent->allChildren->getKeys());
     } catch (UnsupportedRepositoryOperationException $e) {
         $this->markTestSkipped('Reordering of children not supported');
     }
 }
开发者ID:richardmiller,项目名称:phpcr-odm,代码行数:30,代码来源:ChildrenTest.php

示例7: testAddRemoveAttachment

 public function testAddRemoveAttachment()
 {
     $fh = fopen(__DIR__ . '/_files/logo.jpg', 'r');
     $user = $this->dm->find('Doctrine\\Tests\\Models\\CMS\\CmsUser', 'user_with_attachment');
     $user->attachments['logo.jpg'] = Attachment::createFromBinaryData($fh, 'image/jpeg');
     $this->dm->flush();
     $this->dm->clear();
     // dont re-use identity map
     $user = $this->dm->find('Doctrine\\Tests\\Models\\CMS\\CmsUser', 'user_with_attachment');
     unset($user->attachments['foo.txt']);
     $this->dm->flush();
     $this->dm->clear();
     // dont re-use identity map
     $user = $this->dm->find('Doctrine\\Tests\\Models\\CMS\\CmsUser', 'user_with_attachment');
     $this->assertArrayHasKey('logo.jpg', $user->attachments);
     $this->assertArrayNotHasKey('foo.txt', $user->attachments);
 }
开发者ID:doctrine,项目名称:couchdb-odm,代码行数:17,代码来源:AttachmentTest.php

示例8: testCascadeRemoveSingleDocument

 public function testCascadeRemoveSingleDocument()
 {
     $user = new \Doctrine\Tests\Models\CMS\CmsUser();
     $user->username = "beberlei";
     $user->name = "Benjamin";
     $article = new \Doctrine\Tests\Models\CMS\CmsArticle();
     $article->text = "foo";
     $article->topic = "bar";
     $article->user = $user;
     $this->dm->persist($article);
     $this->dm->persist($user);
     $this->dm->flush();
     $this->dm->remove($article);
     $this->dm->flush();
     $this->assertFalse($this->dm->contains($user));
     $this->assertFalse($this->dm->contains($article));
 }
开发者ID:doctrine,项目名称:couchdb-odm,代码行数:17,代码来源:CascadeRemoveTest.php

示例9: testPropertyname

 public function testPropertyname()
 {
     $doc = new TestObj();
     $doc->id = '/functional/pn';
     $doc->name = 'Testname';
     $doc->othername = 'Testothername';
     $this->dm->persist($doc);
     $this->dm->flush();
     $this->dm->clear();
     $this->assertTrue($this->node->getNode('pn')->hasProperty('name'));
     $this->assertTrue($this->node->getNode('pn')->hasProperty('myname'));
     $doc = $this->dm->find($this->type, '/functional/pn');
     $this->assertNotNull($doc->name);
     $this->assertEquals('Testname', $doc->name);
     $this->assertNotNull($doc->othername);
     $this->assertEquals('Testothername', $doc->othername);
 }
开发者ID:nicam,项目名称:phpcr-odm,代码行数:17,代码来源:PropertyNameTest.php

示例10: testSecoundLevelOverwrite

 public function testSecoundLevelOverwrite()
 {
     $localePrefs = array('en' => array('en', 'de'), 'de' => array('de', 'en'));
     $this->dm->setLocaleChooserStrategy(new LocaleChooser($localePrefs, 'en'));
     $secondTrans = new SecondLevelWithDuplicateOverwrite();
     $secondTrans->id = '/functional/secondTrans';
     $secondTrans->text = 'deutsch';
     $this->dm->persist($secondTrans);
     $this->dm->bindTranslation($secondTrans, 'de');
     $secondTrans->text = 'english';
     $this->dm->bindTranslation($secondTrans, 'en');
     $this->dm->flush();
     $tmpDocDe = $this->dm->findTranslation(null, '/functional/secondTrans', 'de');
     $this->assertEquals($tmpDocDe->text, 'deutsch');
     $tmpDocEn = $this->dm->findTranslation(null, '/functional/secondTrans', 'en');
     $this->assertEquals($tmpDocEn->text, 'english');
 }
开发者ID:richardmiller,项目名称:phpcr-odm,代码行数:17,代码来源:AnnotationMappingTest.php

示例11: testCascadeRemoveReferrer

 public function testCascadeRemoveReferrer()
 {
     $user = new \Doctrine\Tests\Models\CMS\CmsUser();
     $user->username = 'beberlei';
     $user->name = 'Benjamin';
     $this->dm->persist($user);
     $this->dm->flush();
     $this->dm->flush();
 }
开发者ID:steffenbrem,项目名称:phpcr-odm,代码行数:9,代码来源:CascadeRemoveTest.php

示例12: testCascadeRefresh

 public function testCascadeRefresh()
 {
     $group1 = new \Doctrine\Tests\Models\CMS\CmsGroup();
     $group1->name = "Test!";
     $user = new \Doctrine\Tests\Models\CMS\CmsUser();
     $user->username = "beberlei";
     $user->name = "Benjamin";
     $user->addGroup($group1);
     $this->dm->persist($user);
     $this->dm->persist($group1);
     $this->dm->flush();
     $this->assertEquals(1, count($user->groups));
     $group1->name = "Test2";
     $user->username = "beberlei2";
     $this->dm->refresh($user);
     $this->assertEquals("beberlei", $user->username);
     $this->assertEquals("Test!", $group1->name);
 }
开发者ID:doctrine,项目名称:couchdb-odm,代码行数:18,代码来源:CascadeRefreshTest.php

示例13: testProxyForChildIsUsed

 function testProxyForChildIsUsed()
 {
     $doc = $this->dm->find($this->type, '/functional/thename');
     $doc->child = new NameDoc();
     $this->dm->flush();
     $this->dm->clear();
     $doc = $this->dm->find($this->type, '/functional/thename');
     $this->assertTrue($doc->child instanceof Proxy);
 }
开发者ID:nicam,项目名称:phpcr-odm,代码行数:9,代码来源:HierarchyTest.php

示例14: testChildOfRoot

 function testChildOfRoot()
 {
     $root = $this->dm->find(null, '/');
     $child = new NameDoc();
     $child->parent = $root;
     $child->nodename = 'childOfRoot';
     $this->dm->persist($child);
     $this->dm->flush();
     $this->assertEquals('/childOfRoot', $child->id);
 }
开发者ID:richardmiller,项目名称:phpcr-odm,代码行数:10,代码来源:HierarchyTest.php

示例15: testDetach

 public function testDetach()
 {
     $user = $this->dm->find($this->type, '/functional/user');
     $user->username = "new-name";
     $this->dm->detach($user);
     $this->dm->flush();
     $this->dm->clear();
     $newUser = $this->dm->find($this->type, '/functional/user');
     $this->assertEquals('lsmith', $newUser->username);
 }
开发者ID:nicam,项目名称:phpcr-odm,代码行数:10,代码来源:BasicCrudTest.php


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