public function testRemoveInvertedReference() { // pre conditions $object = new InvertedReferenceMappingObject(); $testReferencedObject = new ProductObject(); $object->referencedField = $testReferencedObject; $referenceMapping = array('referencedField' => array('inversed-by' => 'objectId', 'referenced-by' => 'id', 'target-object' => get_class($testReferencedObject), 'fieldName' => 'referencedField')); $this->classMetadata->expects($this->any())->method('getReferencedObjects')->will($this->returnValue($referenceMapping)); $this->objectAdapterManager->expects($this->any())->method('getManager')->with($this->equalTo($object), $this->equalTo('referencedField'))->will($this->returnValue($this->objectManager)); $this->objectManager->expects($this->once())->method('remove')->with($this->equalTo($testReferencedObject)); $this->UoW->remove($object); // check setting on scheduled lists $this->UoW->getScheduledObjectForInsert($object, 'referencedField'); $this->assertEquals($testReferencedObject, $this->UoW->getScheduledObjectForRemove($object, 'referencedField')); $expectedReferences = array(spl_object_hash($object) => array('referencedField' => $testReferencedObject)); $this->assertEquals($expectedReferences, $this->UoW->getScheduledReferencesForRemove()); $this->assertEquals(array(), $this->UoW->getScheduledReferencesForInsert()); $this->assertEquals(array(), $this->UoW->getScheduledReferencesForUpdate()); $this->assertThatItsClear('dbal-orm'); }
/** * Will trigger a remove() call for all referenced objects on its managers. * * @param $object */ public function removeReference($object) { $this->unitOfWork->remove($object); }