本文整理汇总了PHP中EntityManager::clear方法的典型用法代码示例。如果您正苦于以下问题:PHP EntityManager::clear方法的具体用法?PHP EntityManager::clear怎么用?PHP EntityManager::clear使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类EntityManager
的用法示例。
在下文中一共展示了EntityManager::clear方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: should_add_new_group
/** @test */
public function should_add_new_group()
{
$this->repository->add(new Group(GroupId::generate(), 'Cribbb'));
$this->em->clear();
$group = $this->repository->groupOfName('Cribbb');
$this->assertInstanceOf('Cribbb\\Domain\\Model\\Groups\\GroupId', $group->id());
$this->assertEquals('Cribbb', $group->name());
$this->assertEquals('cribbb', $group->slug());
}
示例2: should_add_new_thread
/** @test */
public function should_add_new_thread()
{
$group = new Group(GroupId::generate(), 'Cribbb');
$id = ThreadId::generate();
$thread = new Thread($id, $group, 'Hello World');
$this->repository->add($thread);
$this->em->clear();
$thread = $this->repository->threadOfId($id);
$this->assertInstanceOf('Cribbb\\Domain\\Model\\Discussion\\ThreadId', $thread->id());
$this->assertEquals('hello-world', $thread->slug());
}
示例3: createTagCollection
public function createTagCollection()
{
$tags = new ArrayCollection();
$tags->add(new Tag("foo"));
$tags->add(new Tag("bar"));
foreach ($tags as $tag) {
$this->em->persist($tag);
}
$this->em->flush();
$this->em->clear();
return $tags;
}
示例4: should_add_new_post
/** @test */
public function should_add_new_post()
{
$user = User::register(UserId::generate(), new Email('name@domain.com'), new Username('username'), new HashedPassword('qwerty'));
$group = new Group(GroupId::generate(), 'Cribbb');
$thread = new Thread(ThreadId::generate(), $group, 'Hello World');
$id = PostId::generate();
$post = new Post($id, $user, $thread, 'Hello world');
$this->repository->add($post);
$this->em->clear();
$post = $this->repository->postOfId($id);
$this->assertInstanceOf('Cribbb\\Domain\\Model\\Discussion\\PostId', $post->id());
$this->assertEquals('hello-world', $post->slug());
}
示例5: should_add_new_reminder
/** @test */
public function should_add_new_reminder()
{
$id = ReminderId::generate();
$code = ReminderCode::fromNative('new');
$email = new Email('new@domain.com');
$reminder = new Reminder($id, $email, $code);
$this->repository->add($reminder);
$this->em->clear();
$reminder = $this->repository->findReminderByEmailAndCode($email, $code);
$this->assertInstanceOf('Cribbb\\Domain\\Model\\Identity\\Reminder', $reminder);
$this->assertEquals($code, $reminder->code());
$this->assertEquals($email, $reminder->email());
}
示例6: setUp
public function setUp()
{
$config = new \Doctrine\ORM\Configuration();
$config->setMetadataCacheImpl(new \Doctrine\Common\Cache\ArrayCache());
$config->setQueryCacheImpl(new \Doctrine\Common\Cache\ArrayCache());
$config->setProxyDir(__DIR__ . '/_files');
$config->setProxyNamespace('DoctrineExtensions\\LargeCollections\\Proxies');
$config->setMetadataDriverImpl($config->newDefaultAnnotationDriver());
$conn = array('driver' => 'pdo_sqlite', 'memory' => true);
#$config->setSQLLogger(new \Doctrine\DBAL\Logging\EchoSQLLogger());
$this->em = \Doctrine\ORM\EntityManager::create($conn, $config);
$schemaTool = new \Doctrine\ORM\Tools\SchemaTool($this->em);
$schemaTool->createSchema(array($this->em->getClassMetadata('DoctrineExtensions\\LargeCollections\\Article'), $this->em->getClassMetadata('DoctrineExtensions\\LargeCollections\\Tag'), $this->em->getClassMetadata('DoctrineExtensions\\LargeCollections\\Comment')));
$article = new Article();
$tag1 = new Tag();
$tag2 = new Tag();
$comment1 = new Comment();
$comment2 = new Comment();
$article->addComment($comment1);
$article->addComment($comment2);
$article->addTag($tag1);
$article->addTag($tag2);
$this->em->persist($article);
$this->em->persist($tag1);
$this->em->persist($tag2);
$this->em->persist($comment1);
$this->em->persist($comment2);
$this->em->flush();
$this->articleId = $article->id();
$this->em->clear();
}
示例7: should_update_existing_user
/** @test */
public function should_update_existing_user()
{
$this->executor->execute($this->loader->getFixtures());
$user = $this->repository->userOfUsername(new Username('username'));
$username = new Username('new_username');
$user->updateUsername($username);
$this->repository->update($user);
$this->em->clear();
$user = $this->repository->userOfUsername($username);
$this->assertInstanceOf('Cribbb\\Domain\\Model\\Identity\\User', $user);
$this->assertEquals($username, $user->username());
}
示例8: createArticleFixtures
protected function createArticleFixtures()
{
$articles = new ArrayCollection();
$articles->add(new Article('foo', 'toto'));
$articles->add(new Article('bar', 'toto'));
$articles->add(new Article('bar', 'titi'));
$articles->add(new Article('foo', 'titi'));
$articles->add(new Article('barfoo', 'tata'));
foreach ($articles as $article) {
$this->em->persist($article);
}
$this->em->flush();
$this->em->clear();
return $articles;
}
示例9: clear
/**
* Clears the repository, causing all managed entities to become detached.
*/
public function clear()
{
$this->_em->clear($this->_class->rootEntityName);
}