From f0cf67346889825e56c586def16d0c5675cc3091 Mon Sep 17 00:00:00 2001 From: Tetiana Blindaruk Date: Fri, 1 Jun 2018 19:42:44 +0300 Subject: [PATCH] [soft deleting] add testSoftDeleteAfterRestoring. --- ...abaseEloquentSoftDeletesIntegrationTest.php | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/tests/Database/DatabaseEloquentSoftDeletesIntegrationTest.php b/tests/Database/DatabaseEloquentSoftDeletesIntegrationTest.php index 88d859fcd001..af700bb44a01 100644 --- a/tests/Database/DatabaseEloquentSoftDeletesIntegrationTest.php +++ b/tests/Database/DatabaseEloquentSoftDeletesIntegrationTest.php @@ -283,6 +283,24 @@ public function testRestoreAfterSoftDelete() $this->assertEquals($userModel->id, SoftDeletesTestUser::find(2)->id); } + + /** + * @throws \Exception + */ + public function testSoftDeleteAfterRestoring() + { + $this->createUsers(); + + /** @var SoftDeletesTestUser $userModel */ + $userModel = SoftDeletesTestUser::withTrashed()->find(1); + $userModel->restore(); + $this->assertEquals($userModel->deleted_at, SoftDeletesTestUser::find(1)->deleted_at); + $this->assertEquals($userModel->getOriginal('deleted_at'), SoftDeletesTestUser::find(1)->deleted_at); + $userModel->delete(); + $this->assertNull(SoftDeletesTestUser::find(1)); + $this->assertEquals($userModel->deleted_at, SoftDeletesTestUser::withTrashed()->find(1)->deleted_at); + $this->assertEquals($userModel->getOriginal('deleted_at'), SoftDeletesTestUser::withTrashed()->find(1)->deleted_at); + } public function testUpdateOrCreate() {