Permalink
Browse files

No-op on delete or restore on previously scheduled documents.

  • Loading branch information...
jjbohn committed Mar 20, 2012
1 parent 6dc4bd4 commit d80621baa161d773068ec853d318abfd4c429376
@@ -220,13 +220,12 @@ public function restoreBy($className, array $criteria, array $flags = array())
* Schedules a SoftDeleteable document instance for deletion on next flush.
*
* @param SoftDeleteable $document
- * @throws InvalidArgumentException
*/
public function delete(SoftDeleteable $document)
{
$oid = spl_object_hash($document);
if (isset($this->documentDeletes[$oid])) {
- throw new \InvalidArgumentException('Document is already scheduled for delete.');
+ return;
}
// If scheduled for restore then remove it
@@ -243,13 +242,12 @@ public function delete(SoftDeleteable $document)
* Schedules a SoftDeleteable document instance for restoration on next flush.
*
* @param SoftDeleteable $document
- * @throws InvalidArgumentException
*/
public function restore(SoftDeleteable $document)
{
$oid = spl_object_hash($document);
if (isset($this->documentRestores[$oid])) {
- throw new \InvalidArgumentException('Document is already scheduled for restore.');
+ return;
}
// If scheduled for delete then remove it
@@ -36,12 +36,20 @@ public function testDelete()
{
$this->sdm->delete($this->softDeleteable);
$this->assertTrue($this->sdm->isScheduledForDelete($this->softDeleteable));
+
+ $deletes = $this->sdm->getDocumentDeletes();
+ $this->sdm->delete($this->softDeleteable);
+ $this->assertEquals($deletes, $this->sdm->getDocumentDeletes(), 'Delete of already scheduled document does nothing');
}
public function testRestore()
{
$this->sdm->restore($this->softDeleteable);
$this->assertTrue($this->sdm->isScheduledForRestore($this->softDeleteable));
+
+ $restores = $this->sdm->getDocumentRestores();
+ $this->sdm->restore($this->softDeleteable);
+ $this->assertEquals($restores, $this->sdm->getDocumentRestores(), 'Restore of already scheduled document does nothing');
}
private function getMockConfiguration()

0 comments on commit d80621b

Please sign in to comment.