create(['status' => UserStatus::INACTIVE]); $action = new ActivateUserStatus(app(UpdateUserStatus::class)); $action->execute($user); expect($user->fresh()->status)->toBe(UserStatus::ACTIVE); Event::assertDispatched(UserWasActivated::class); }); test('it throws exception if user already active', function () { $user = User::factory()->create(['status' => UserStatus::ACTIVE]); $action = new ActivateUserStatus(app(UpdateUserStatus::class)); $this->expectException(Exception::class); $this->expectExceptionMessage(__('domains/identity/messages.exceptions.user_already_active')); $action->execute($user); });