mirror of
https://github.com/VueFileManager/vuefilemanager.git
synced 2026-04-05 18:23:48 +00:00
delete only howdy share links in demo mode
This commit is contained in:
@@ -1,12 +1,20 @@
|
||||
<?php
|
||||
namespace Support\Demo\Actions;
|
||||
|
||||
use App\Users\Models\User;
|
||||
use DB;
|
||||
|
||||
class DeleteAllSharedLinksAction
|
||||
{
|
||||
public function __invoke()
|
||||
{
|
||||
DB::table('shares')->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();
|
||||
}
|
||||
}
|
||||
|
||||
41
tests/Support/Demo/DemoTest.php
Normal file
41
tests/Support/Demo/DemoTest.php
Normal file
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Support\Demo;
|
||||
|
||||
use App\Users\Models\User;
|
||||
use Domain\Sharing\Models\Share;
|
||||
use Support\Demo\Actions\DeleteAllSharedLinksAction;
|
||||
use Tests\TestCase;
|
||||
|
||||
class DemoTest extends TestCase
|
||||
{
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function it_delete_howdy_shared_links()
|
||||
{
|
||||
$user = User::factory()
|
||||
->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,
|
||||
]);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user