public function testCommitReference() { // pre conditions $object = new ReferenceMappingObject(); $object->entityName = 'entity name on object'; $testReferencedObject = new ProductDocument(); $object->referencedField = $testReferencedObject; $testReferencedObject->uuid = 'test-uuid'; $testReferencedObject->docName = 'Name on document'; $referenceMapping = array('referencedField' => array('inversed-by' => 'uuid', 'referenced-by' => 'uuid', 'target-object' => get_class($testReferencedObject), 'fieldName' => 'referencedField', 'sync-type' => 'from-reference')); $commonFieldMappings = array('uuid' => array('referenced-by' => 'uuid', 'inversed-by' => 'uuid', 'target-field' => 'referencedField', 'sync-type' => 'from-reference'), 'entityName' => array('referenced-by' => 'docName', 'inversed-by' => 'entityName', 'target-field' => 'referencedField', 'sync-type' => 'to-reference')); $this->classMetadata->expects($this->any())->method('getReferencedObjects')->will($this->returnValue($referenceMapping)); $this->classMetadata->expects($this->any())->method('getCommonFields')->will($this->returnValue($commonFieldMappings)); $this->objectAdapterManager->expects($this->any())->method('getManager')->with($this->equalTo($object), $this->equalTo('referencedField'))->will($this->returnValue($this->documentManager)); $this->documentManager->expects($this->once())->method('persist')->with($this->equalTo($testReferencedObject)); $this->UoW->persist($object); // check setting on scheduled lists $this->UoW->getScheduledObjectForInsert($object, 'referencedField'); $this->assertEquals($testReferencedObject, $this->UoW->getScheduledObjectForInsert($object, 'referencedField')); $expectedReferences = array(spl_object_hash($object) => array('referencedField' => $testReferencedObject)); $this->assertEquals($expectedReferences, $this->UoW->getScheduledReferencesForInsert()); $this->documentManager->expects($this->once())->method('flush'); $this->UoW->commit(); $this->assertThatItsClear(); }