team invitation notification with broadcasting

This commit is contained in:
Čarodej
2022-03-10 16:23:13 +01:00
parent 64e80d387b
commit 9ae2d54a5e
50 changed files with 331 additions and 201 deletions

View File

@@ -386,12 +386,11 @@ class FileTest extends TestCase
});
}
/**
* @test
*/
/**
* @test
*/
public function it_store_file_exif_data_after_file_upload()
{
$file = UploadedFile::fake()
->image('fake-image.jpg', 2000, 2000);
@@ -417,5 +416,4 @@ class FileTest extends TestCase
'width' => 2000,
]);
}
}

View File

@@ -1,11 +1,10 @@
<?php
namespace Tests\Domain\Notifications;
use App\Users\Models\User;
use Tests\TestCase;
use Str;
use DB;
use Str;
use Tests\TestCase;
use App\Users\Models\User;
class NotificationsTest extends TestCase
{
@@ -131,4 +130,4 @@ class NotificationsTest extends TestCase
$this->assertDatabaseCount('notifications', 0);
}
}
}

View File

@@ -1,5 +1,4 @@
<?php
namespace Tests\Domain\Settings;
use Storage;

View File

@@ -62,11 +62,41 @@ class TeamManagementTest extends TestCase
'permission' => 'can-view',
]);
DB::table('notifications')
->insert([
'id' => Str::uuid(),
'type' => 'Domain\UploadRequest\Notifications\UploadRequestFulfilledNotification',
'notifiable_type' => 'App\Users\Models\User',
'notifiable_id' => $member->id,
'data' => json_encode([
'type' => 'team-invitation',
'title' => 'New Team Invitation',
'description' => 'Jane Doe invite you to join into Team Folder..',
'action' => [
'type' => 'invitation',
'params' => [
'type' => 'invitation',
'params' => [
'id' => $invitation->id,
],
],
],
]),
'created_at' => now(),
'updated_at' => now(),
]);
$this
->actingAs($member)
->putJson("/api/teams/invitations/{$invitation->id}")
->assertNoContent();
// Get notification
$notification = json_decode(DB::table('notifications')->first()->data);
// Check if action is null
$this->assertEquals(null, $notification->action);
$this
->assertDatabaseHas('team_folder_invitations', [
'parent_id' => $folder->id,
@@ -174,11 +204,41 @@ class TeamManagementTest extends TestCase
'permission' => 'can-edit',
]);
DB::table('notifications')
->insert([
'id' => Str::uuid(),
'type' => 'Domain\UploadRequest\Notifications\UploadRequestFulfilledNotification',
'notifiable_type' => 'App\Users\Models\User',
'notifiable_id' => $member->id,
'data' => json_encode([
'type' => 'team-invitation',
'title' => 'New Team Invitation',
'description' => 'Jane Doe invite you to join into Team Folder..',
'action' => [
'type' => 'invitation',
'params' => [
'type' => 'invitation',
'params' => [
'id' => $invitation->id,
],
],
],
]),
'created_at' => now(),
'updated_at' => now(),
]);
$this
->actingAs($member)
->deleteJson("/api/teams/invitations/{$invitation->id}")
->assertNoContent();
// Get notification
$notification = json_decode(DB::table('notifications')->first()->data);
// Check if action is null
$this->assertEquals(null, $notification->action);
$this
->assertDatabaseHas('team_folder_invitations', [
'parent_id' => $folder->id,

View File

@@ -1,8 +1,6 @@
<?php
namespace Tests\Domain\UploadRequest;
use Domain\UploadRequest\Notifications\UploadRequestFulfilledNotification;
use Storage;
use Notification;
use Tests\TestCase;
@@ -12,6 +10,7 @@ use Illuminate\Http\UploadedFile;
use Domain\UploadRequest\Models\UploadRequest;
use Support\Scheduler\Actions\ExpireUnfilledUploadRequestAction;
use Domain\UploadRequest\Notifications\UploadRequestNotification;
use Domain\UploadRequest\Notifications\UploadRequestFulfilledNotification;
class UploadRequestTest extends TestCase
{