/** * delete document * * @param DocumentEntity $doc document entity * @param ConfigEntity $config config entity * @return int */ public function delete(DocumentEntity $doc, ConfigEntity $config) { $this->connection->beginTransaction(); if ($config->get('revision') === true) { $this->revision->delete($doc); } $count = $this->document->delete($doc, $config); $this->connection->commit(); return $count; }
/** * test delete * * @return void */ public function testDelete() { $conn = $this->conn; $repo = new DocumentRepository($conn); $doc = $this->getDocumentEntity(); $config = $this->getConfigEntity(); $config->shouldReceive('get')->with('division')->andReturn(true); $config->shouldReceive('get')->with('instanceId')->andReturn('instanceId'); $this->query->shouldReceive('delete')->andReturn(1); $this->query->shouldReceive('where')->andReturn($this->query); $result = $repo->delete($doc, $config); $this->assertEquals(1, $result); $result = $repo->deleteByInstanceId('instanceId'); $this->assertEquals(1, $result); }