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


PHP DocumentManager::contains方法代码示例

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


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

示例1: testCascadeManagedDocumentReferrerDuringFlush

 public function testCascadeManagedDocumentReferrerDuringFlush()
 {
     $user = new \Doctrine\Tests\Models\CMS\CmsUser();
     $user->username = "dbu";
     $user->name = "David";
     $this->dm->persist($user);
     $article = new \Doctrine\Tests\Models\CMS\CmsArticle();
     $article->text = "foo";
     $article->topic = "bar";
     $article->id = '/functional/article_referrer';
     $user->articlesReferrers->add($article);
     $this->assertFalse($this->dm->contains($article));
     $this->dm->flush();
     $this->assertEquals($user, $article->user);
     $this->dm->clear();
     $user = $this->dm->find('Doctrine\\Tests\\Models\\CMS\\CmsUser', '/functional/dbu');
     $this->assertNotNull($user);
     $this->assertTrue(1 <= count($user->articlesReferrers));
     $savedArticle = $user->articlesReferrers->first();
     $this->assertInstanceOf('Doctrine\\Tests\\Models\\CMS\\CmsArticle', $savedArticle);
     $this->assertEquals($article->id, $savedArticle->id);
     $savedArticle->user = null;
     $this->dm->flush();
     $this->dm->clear();
     $removedArticle = $user->articlesReferrers->first();
     $this->assertNull($removedArticle->user);
 }
开发者ID:steffenbrem,项目名称:phpcr-odm,代码行数:27,代码来源:CascadePersistTest.php

示例2: testProxyIsIgnored

 public function testProxyIsIgnored()
 {
     $user = new CmsUser();
     $user->name = 'Dominik';
     $user->username = 'domnikl';
     $user->status = 'developer';
     $this->dm->persist($user);
     $this->dm->flush();
     $this->dm->clear();
     $user = $this->dm->getReference(get_class($user), $user->id);
     $otherUser = new CmsUser();
     $otherUser->name = 'Dominik2';
     $otherUser->username = 'domnikl2';
     $otherUser->status = 'developer';
     $this->dm->persist($otherUser);
     $this->dm->flush($user);
     $this->assertTrue($this->dm->contains($otherUser), "Other user is contained in DocumentManager");
     $this->assertTrue($otherUser->id != null, "other user has no id");
 }
开发者ID:steffenbrem,项目名称:phpcr-odm,代码行数:19,代码来源:FlushTest.php

示例3: testTriggerEvents

 public function testTriggerEvents()
 {
     $this->dm->getEventManager()->addEventListener(array(Event::prePersist, Event::postPersist, Event::preUpdate, Event::postUpdate, Event::preRemove, Event::postRemove, Event::onFlush, Event::postFlush, Event::preFlush, Event::preMove, Event::postMove, Event::endFlush), $this->listener);
     $page = new CmsPage();
     $page->title = "my-page";
     $page->content = "long story";
     $this->dm->persist($page);
     $this->assertTrue($this->listener->pagePrePersist);
     $this->assertFalse($this->listener->itemPrePersist);
     $this->assertFalse($this->listener->postFlush);
     $this->assertFalse($this->listener->endFlush);
     $this->assertFalse($this->listener->preFlush);
     $this->dm->flush();
     $this->assertTrue($this->listener->onFlush);
     $this->assertTrue($this->listener->postFlush);
     $this->assertTrue($this->listener->endFlush);
     $this->assertTrue($this->listener->preFlush);
     $this->assertFalse($this->listener->preUpdate);
     $this->assertFalse($this->listener->postUpdate);
     $this->assertTrue($this->listener->pagePostPersist);
     $this->assertFalse($this->listener->itemPostPersist);
     $this->assertFalse($this->listener->pagePreRemove);
     $this->assertFalse($this->listener->pagePostRemove);
     $this->assertFalse($this->listener->itemPreRemove);
     $this->assertFalse($this->listener->pagePreMove);
     $this->assertFalse($this->listener->pagePostMove);
     $this->assertFalse($this->listener->itemPreMove);
     $this->assertFalse($this->listener->itemPostMove);
     $this->dm->move($page, '/functional/moved-' . $page->title);
     $this->assertFalse($this->listener->pagePreMove);
     $this->assertFalse($this->listener->pagePostMove);
     $this->dm->flush();
     $this->assertTrue($this->listener->pagePreMove);
     $this->assertTrue($this->listener->pagePostMove);
     $this->assertFalse($this->listener->itemPreMove);
     $this->assertFalse($this->listener->itemPostMove);
     $this->dm->flush();
     $item = new CmsItem();
     $item->name = "my-item";
     $item->documentTarget = $page;
     $page->content = "short story";
     $this->dm->persist($item);
     $page->addItem($item);
     $this->dm->flush();
     $this->assertTrue($this->listener->preUpdate);
     $this->assertTrue($this->listener->itemPrePersist);
     $this->assertTrue($this->listener->postUpdate);
     $this->assertTrue($this->listener->itemPostPersist);
     $this->assertEquals('long story is now short story', $page->content);
     $pageId = $this->dm->getUnitOfWork()->getDocumentId($page);
     $itemId = $this->dm->getUnitOfWork()->getDocumentId($item);
     $this->dm->clear();
     $page = $this->dm->find(null, $pageId);
     $item = $this->dm->find(null, $itemId);
     $this->assertEquals('long story is now short story', $page->content);
     $this->dm->remove($item);
     $this->dm->remove($page);
     $this->assertTrue($this->listener->pagePreRemove);
     $this->assertTrue($this->listener->itemPreRemove);
     $this->assertFalse($this->listener->pagePostRemove);
     $this->assertFalse($this->listener->itemPostRemove);
     $this->assertFalse($this->dm->contains($page));
     $this->assertFalse($this->dm->contains($item));
     $this->dm->flush();
     $this->assertFalse($this->dm->contains($page));
     $this->assertFalse($this->dm->contains($item));
     $this->assertTrue($this->listener->pagePostRemove);
     $this->assertTrue($this->listener->itemPostRemove);
 }
开发者ID:nikophil,项目名称:cmf-tests,代码行数:69,代码来源:EventManagerTest.php


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