public function testLoadOne() { $otherObject = new OtherDataObject(); $otherObject->setName('Other object one-to-many'); $this->objectMapper->save($otherObject); $object = new ExtendedDataObject(); $object->setMyColumn('one-to-many')->setOtherDataObjectId($otherObject->getId()); $this->repository->save($object); $return = $this->repository->loadOne([$object], OtherDataObject::class); $this->assertInstanceOf(OtherDataObject::class, $object->getOtherDataObject()); $this->assertEquals('Other object one-to-many', $object->getOtherDataObject()->getName()); $this->assertCount(1, $return); $this->assertInstanceOf(OtherDataObject::class, $return[$otherObject->getId()]); }
/** * Executes all operations * * @param callable $exceptionHandler */ public function flush(callable $exceptionHandler = null) { $this->executeTransaction(function () { foreach ($this->objectsToSave as $objects) { if (count($objects) == 1) { $this->orm->save($objects[0]); } else { $this->orm->saveAll($objects); } } foreach ($this->objectsToDelete as $objects) { if (count($objects) == 1) { $this->orm->delete($objects[0]); } else { $this->orm->deleteAll($objects); } } }, $exceptionHandler); $this->objectsToSave = []; $this->objectsToDelete = []; }