Exemplo n.º 1
0
 public function testRemove()
 {
     $user = $this->dm->find($this->type, 1);
     $this->dm->remove($user);
     $this->dm->flush();
     $newUser = $this->dm->find($this->type, 1);
     $this->assertNull($newUser);
 }
Exemplo n.º 2
0
 /**
  * @expectedException \InvalidArgumentException
  */
 public function testDetachWithRemove()
 {
     $user = $this->dm->find($this->type, '/functional/user');
     $user->username = "******";
     $this->dm->detach($user);
     $this->dm->remove($user);
 }
Exemplo n.º 3
0
 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));
 }
Exemplo n.º 4
0
 public function testRemoveChildParent()
 {
     $parent = $this->dm->find('Doctrine\\Tests\\ODM\\PHPCR\\Functional\\ChildrenTestObj', '/functional/parent');
     $this->assertCount(4, $parent->allChildren);
     $this->dm->remove($parent);
     $this->dm->flush();
     $this->dm->clear();
     $parent = $this->dm->find('Doctrine\\Tests\\ODM\\PHPCR\\Functional\\ChildrenTestObj', '/functional/parent');
     $this->assertNull($parent);
 }
Exemplo n.º 5
0
 /**
  * @expectedException \InvalidArgumentException
  */
 public function testRemoveAndInsertBeforeFlush()
 {
     $this->dm->clear();
     $user = $this->dm->find($this->type, '/functional/user');
     $this->assertNotNull($user, 'User must exist');
     $this->dm->remove($user);
     $user = new User2();
     $user->username = "******";
     $user->id = '/functional/user';
     $this->dm->persist($user);
 }
Exemplo n.º 6
0
 public function testRemoveThenMove()
 {
     $this->dm->clear();
     $user = $this->dm->find($this->type, '/functional/lsmith');
     $this->assertNotNull($user, 'User must exist');
     $this->dm->remove($user);
     $this->dm->move($user, '/functional/user2');
     $this->dm->flush();
     $user = $this->dm->find($this->type, '/functional/user2');
     $this->assertNotNull($user, 'User must exist');
     $user = $this->dm->find($this->type, '/functional/lsmith');
     $this->assertNull($user, 'User must be null after deletion');
 }
Exemplo n.º 7
0
 /**
  * Remove the child, check that parent->child is not set afterwards
  */
 public function testRemove2()
 {
     $parent = new ChildTestObj();
     $child = new ChildChildTestObj();
     $parent->name = 'Parent';
     $parent->id = '/functional/childtest';
     $parent->child = $child;
     $child->name = 'Child';
     $this->dm->persist($parent);
     $this->dm->flush();
     $this->dm->clear();
     $child = $this->dm->find($this->childType, '/functional/childtest/test');
     $this->dm->remove($child);
     $this->dm->flush();
     $this->dm->clear();
     $parent = $this->dm->find($this->type, '/functional/childtest');
     $this->assertNull($parent->child);
     $this->assertTrue($this->node->hasNode('childtest'));
     $this->assertFalse($this->node->getNode('childtest')->hasNode('test'));
 }