public function testCascadeRemoveSingleDocument() { $user = new \Doctrine\Tests\Models\CMS\CmsUser(); $user->username = "******"; $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)); }
public function testCascadeManagedDocumentReferenceDuringFlush() { $article = new \Doctrine\Tests\Models\CMS\CmsArticle(); $article->text = "foo"; $article->topic = "bar"; $this->dm->persist($article); $user = new \Doctrine\Tests\Models\CMS\CmsUser(); $user->username = "******"; $user->name = "Benjamin"; $article->user = $user; $this->assertFalse($this->dm->contains($user)); $this->dm->flush(); $this->dm->clear(); $article = $this->dm->find('Doctrine\\Tests\\Models\\CMS\\CmsArticle', $article->id); $this->assertEquals($user->id, $article->user->getId()); }
public function testProxyIsIgnored() { $user = new CmsUser(); $user->name = 'Dominik'; $user->username = '******'; $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 = '******'; $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"); }