Skip to content

Commit

Permalink
Added test + used different solution for forceDelete
Browse files Browse the repository at this point in the history
  • Loading branch information
BlazOrazem committed Oct 15, 2019
1 parent 57580e6 commit a78e795
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ public function delete()
*/
public function forceDelete()
{
return $this->query->delete() && $this->i18nDeleteQuery(false)->delete();
return $this->i18nDeleteQuery(false)->delete() & $this->query->delete();
}

/**
Expand Down
19 changes: 19 additions & 0 deletions tests/TestCRUD.php
Original file line number Diff line number Diff line change
Expand Up @@ -312,4 +312,23 @@ public function testHasQuery()

$this->assertCount(1, Tag::has('children')->get());
}

public function testForceDelete()
{
$post = Post::forceCreateInLocale('de', ['title' => 'Title DE']);
$post->forceSaveTranslation('en', ['title' => 'Title EN']);

$this->assertCount(1, Post::all());
$this->assertCount(2, Post::i18nQuery()->get());

$post->translations()->delete();

$this->assertCount(1, Post::all());
$this->assertCount(0, Post::i18nQuery()->get());

$post->forceDelete();

$this->assertCount(0, Post::all());
$this->assertCount(0, Post::i18nQuery()->get());
}
}

0 comments on commit a78e795

Please sign in to comment.