From 80b237186898dceacc59268037bdaa172e6f1be9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C4=8Carodej?= Date: Mon, 4 Apr 2022 17:49:18 +0200 Subject: [PATCH] delete only howdy share links in demo mode --- .../Actions/DeleteAllSharedLinksAction.php | 10 ++++- tests/Support/Demo/DemoTest.php | 41 +++++++++++++++++++ 2 files changed, 50 insertions(+), 1 deletion(-) create mode 100644 tests/Support/Demo/DemoTest.php diff --git a/src/Support/Demo/Actions/DeleteAllSharedLinksAction.php b/src/Support/Demo/Actions/DeleteAllSharedLinksAction.php index 389b516f..964087ad 100644 --- a/src/Support/Demo/Actions/DeleteAllSharedLinksAction.php +++ b/src/Support/Demo/Actions/DeleteAllSharedLinksAction.php @@ -1,12 +1,20 @@ delete(); + // Get howdy account + $user = User::where('email', 'howdy@hi5ve.digital') + ->first(); + + // Delete howdy shared links + DB::table('shares') + ->where('user_id', $user->id) + ->delete(); } } diff --git a/tests/Support/Demo/DemoTest.php b/tests/Support/Demo/DemoTest.php new file mode 100644 index 00000000..963b8329 --- /dev/null +++ b/tests/Support/Demo/DemoTest.php @@ -0,0 +1,41 @@ +hasSettings() + ->create(); + + $howdy = User::factory() + ->hasSettings() + ->create([ + 'email' => 'howdy@hi5ve.digital', + ]); + + Share::factory() + ->create(['user_id' => $user->id]); + + Share::factory() + ->create(['user_id' => $howdy->id]); + + resolve(DeleteAllSharedLinksAction::class)(); + + $this->assertDatabaseHas('shares', [ + 'user_id' => $user->id, + ])->assertDatabaseMissing('shares', [ + 'user_id' => $howdy->id, + ]); + } +} \ No newline at end of file