Since: 1.0
Author: Jordi Boggiano (j.boggiano@seld.be)
Author: Pascal Helfenstein (nicam@nicam.ch)
Author: Lukas Kahwe Smith (smith@pooteeweet.org)
Author: Brian King (brian@liip.ch)
Author: David Buchmann (david@liip.ch)
Author: Daniel Barsotti (daniel.barsotti@liip.ch)
Example #1
0
 public function testFetchingMultipleHierarchicalObjectsWithChildIdFirst()
 {
     $parent = new ParentTestObj();
     $parent->nodename = 'parent';
     $parent->name = 'parent';
     $parent->parent = $this->dm->find(null, 'functional');
     $child = new ParentTestObj();
     $child->nodename = 'child';
     $child->name = 'child';
     $child->parent = $parent;
     $this->dm->persist($parent);
     $this->dm->persist($child);
     $parentId = $this->uow->getDocumentId($parent);
     $childId = $this->uow->getDocumentId($child);
     $this->dm->flush();
     $this->dm->clear();
     // this forces the objects to be loaded in an order where the $parent will become a proxy
     $documents = $this->dm->findMany('Doctrine\\Tests\\Models\\References\\ParentTestObj', array($childId, $parentId));
     $this->assertCount(2, $documents);
     /* @var $child ParentTestObj */
     /* @var $parent ParentTestObj */
     $child = $documents->first();
     $parent = $documents->last();
     $this->assertSame($child->parent, $parent);
     $this->assertSame('parent', $parent->nodename);
 }
 /**
  * Helper method to initialize a lazy loading proxy or persistent collection.
  *
  * This method is a no-op for other objects
  *
  * @param object $document
  */
 public function initializeObject($document)
 {
     if (!is_object($document)) {
         throw new \InvalidArgumentException(gettype($document));
     }
     $this->unitOfWork->initializeObject($document);
 }
Example #3
0
 /**
  * {@inheritDoc}
  */
 public function getNodeForDocument($document)
 {
     if (!is_object($document)) {
         throw new InvalidArgumentException('Parameter $document needs to be an object, ' . gettype($document) . ' given');
     }
     $path = $this->unitOfWork->getDocumentId($document);
     return $this->session->getNode($path);
 }
Example #4
0
 /**
  * @see https://github.com/doctrine/phpcr-odm/issues/637
  * @covers Doctrine\ODM\PHPCR\UnitOfWork::computeSingleDocumentChangeSet
  */
 public function testComputeSingleDocumentChangeSetForRemovedDocument()
 {
     $object = new UoWUser();
     $object->username = "******";
     $object->id = '/somepath';
     $this->uow->scheduleRemove($object);
     // Should not throw "InvalidArgumentException: Document has to be managed for single computation"
     $this->uow->computeSingleDocumentChangeSet($object);
 }
 /**
  * @covers Doctrine\ODM\PHPCR\UnitOfWork::scheduleRemove
  * @covers Doctrine\ODM\PHPCR\UnitOfWork::scheduleInsert
  * @covers Doctrine\ODM\PHPCR\UnitOfWork::doScheduleInsert
  */
 public function testScheduleInsertCancelsScheduleRemove()
 {
     $object = new UoWUser();
     $object->username = "******";
     $object->id = '/somepath';
     $this->uow->scheduleInsert($object);
     $this->uow->scheduleRemove($object);
     $method = new \ReflectionMethod($this->uow, 'getDocumentState');
     $method->setAccessible(true);
     $state = $method->invoke($this->uow, $object);
     $method->setAccessible(false);
     $this->assertEquals(UnitOfWork::STATE_REMOVED, $state);
     $this->uow->scheduleInsert($object);
     $method->setAccessible(true);
     $state = $method->invoke($this->uow, $object);
     $method->setAccessible(false);
     $this->assertEquals(UnitOfWork::STATE_MANAGED, $state);
 }
Example #6
0
 /**
  * Helper method to initialize a lazy loading proxy or persistent collection.
  *
  * This method is a no-op for other objects
  *
  * @param object $obj
  */
 public function initializeObject($obj)
 {
     $this->unitOfWork->initializeObject($obj);
 }
 /**
  * @param object $document
  */
 public function refreshDocumentForProxy($document)
 {
     $this->uow->refreshDocumentForProxy($this->className, $document);
 }