/** * update document * * @param DocumentEntity $doc document entity * @param ConfigEntity $config config entity * @param ConfigEntity $originConfig original instance config entity * @return DocumentEntity */ public function update(DocumentEntity $doc, ConfigEntity $config, ConfigEntity $originConfig = null) { $this->connection->beginTransaction(); $doc = $this->document->update($doc, $config); if ($config->get('revision') === true && $this->revision->isChanged($doc) === true) { $this->revision->insert($doc, $config); } if ($config->get('division') === true) { $diff = $doc->diff(); if (isset($diff['instanceId'])) { $this->document->insertDivision($doc, $config); } else { $this->document->updateDivision($doc, $config); } } // 인스턴스 아이디 변경 시 이전 인스턴스 디비전 테이블 데이터 삭제 if ($originConfig != null && $originConfig->get('division') === true) { $diff = $doc->diff(); if (isset($diff['instanceId'])) { $doc->instanceId = $doc->getOriginal()['instanceId']; $this->document->deleteDivision($doc, $originConfig); } } $this->connection->commit(); return $doc; }
/** * test is changed * * @return void */ public function testIsChanged() { $conn = $this->conn; $revisionManager = $this->revisionManager; $keygen = $this->keygen; $repo = new RevisionRepository($conn, $revisionManager, $keygen); $doc = $this->getDocumentEntity(); $doc->shouldReceive('diff')->once()->andReturn([]); $this->assertFalse($repo->isChanged($doc)); $doc->shouldReceive('diff')->once()->andReturn(['changedColumne' => 'changedValue']); $this->assertTrue($repo->isChanged($doc)); }