mirror of
https://github.com/solidtime-io/solidtime.git
synced 2026-08-16 20:22:15 +01:00
Added member and invitation endpoints
This commit is contained in:
@@ -4,6 +4,7 @@ declare(strict_types=1);
|
||||
|
||||
namespace Tests\Feature;
|
||||
|
||||
use App\Models\Membership;
|
||||
use App\Models\User;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Tests\TestCase;
|
||||
@@ -14,13 +15,20 @@ class CreateTeamTest extends TestCase
|
||||
|
||||
public function test_teams_can_be_created(): void
|
||||
{
|
||||
$this->actingAs($user = User::factory()->withPersonalOrganization()->create());
|
||||
// Arrange
|
||||
$user = User::factory()->withPersonalOrganization()->create();
|
||||
$this->actingAs($user);
|
||||
|
||||
// Act
|
||||
$response = $this->post('/teams', [
|
||||
'name' => 'Test Organization',
|
||||
]);
|
||||
|
||||
// Assert
|
||||
$newOrganization = $user->fresh()->ownedTeams()->latest('id')->first();
|
||||
$this->assertCount(2, $user->fresh()->ownedTeams);
|
||||
$this->assertEquals('Test Organization', $user->fresh()->ownedTeams()->latest('id')->first()->name);
|
||||
$this->assertEquals('Test Organization', $newOrganization->name);
|
||||
$member = Membership::query()->whereBelongsTo($user, 'user')->whereBelongsTo($newOrganization, 'organization')->firstOrFail();
|
||||
$this->assertSame('owner', $member->role);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user