Added recycle-bin test to cover type deletions

This commit is contained in:
Dan Brown 2021-02-06 13:22:31 +00:00
parent d547ed4a6b
commit 7843d8f054
No known key found for this signature in database
GPG Key ID: 46D9F943C24A2EF9

View File

@ -1,7 +1,10 @@
<?php namespace Tests;
use BookStack\Entities\Models\Book;
use BookStack\Entities\Models\Bookshelf;
use BookStack\Entities\Models\Chapter;
use BookStack\Entities\Models\Deletion;
use BookStack\Entities\Models\Entity;
use BookStack\Entities\Models\Page;
use DB;
use Illuminate\Support\Carbon;
@ -129,6 +132,21 @@ class RecycleBinTest extends TestCase
$redirectReq->assertNotificationContains('Deleted '.$itemCount.' total items from the recycle bin');
}
public function test_permanent_delete_for_each_type()
{
/** @var Entity $entity */
foreach ([new Bookshelf, new Book, new Chapter, new Page] as $entity) {
$entity = $entity->newQuery()->first();
$this->asEditor()->delete($entity->getUrl());
$deletion = Deletion::query()->orderBy('id', 'desc')->firstOrFail();
$deleteReq = $this->asAdmin()->delete("/settings/recycle-bin/{$deletion->id}");
$deleteReq->assertRedirect('/settings/recycle-bin');
$this->assertDatabaseMissing('deletions', ['id' => $deletion->id]);
$this->assertDatabaseMissing($entity->getTable(), ['id' => $entity->id]);
}
}
public function test_permanent_entity_delete_updates_existing_activity_with_entity_name()
{
$page = Page::query()->firstOrFail();