add tests batch 20

This commit is contained in:
root
2026-06-09 01:03:53 -04:00
parent 95efb9652e
commit 6be4875c5e
1502 changed files with 13797 additions and 11313 deletions
@@ -75,7 +75,7 @@ class MessagesController extends BaseApiController
public function show(int $id): JsonResponse
{
$message = $this->queryService->findForUser($id);
if (! $message) {
if (!$message) {
return $this->error('Message not found.', Response::HTTP_NOT_FOUND);
}
@@ -104,8 +104,7 @@ class MessagesController extends BaseApiController
try {
$message = $this->commandService->create($guard, $request->validated(), $request->file('attachment'));
} catch (\Throwable $e) {
Log::error('Message send failed: '.$e->getMessage());
Log::error('Message send failed: ' . $e->getMessage());
return $this->error($e->getMessage(), Response::HTTP_BAD_REQUEST);
}
@@ -151,7 +150,7 @@ class MessagesController extends BaseApiController
public function update(MessageUpdateRequest $request, int $id): JsonResponse
{
$message = Message::query()->find($id);
if (! $message) {
if (!$message) {
return $this->error('Message not found.', Response::HTTP_NOT_FOUND);
}
@@ -160,8 +159,7 @@ class MessagesController extends BaseApiController
try {
$updated = $this->commandService->update($message, $request->validated());
} catch (\Throwable $e) {
Log::error('Message update failed: '.$e->getMessage());
Log::error('Message update failed: ' . $e->getMessage());
return $this->error('Unable to update message.', Response::HTTP_INTERNAL_SERVER_ERROR);
}
@@ -173,7 +171,7 @@ class MessagesController extends BaseApiController
public function destroy(int $id): JsonResponse
{
$message = Message::query()->find($id);
if (! $message) {
if (!$message) {
return $this->error('Message not found.', Response::HTTP_NOT_FOUND);
}
@@ -182,12 +180,11 @@ class MessagesController extends BaseApiController
try {
$trashed = $this->commandService->trash($message);
} catch (\Throwable $e) {
Log::error('Message delete failed: '.$e->getMessage());
Log::error('Message delete failed: ' . $e->getMessage());
return $this->error('Unable to delete message.', Response::HTTP_INTERNAL_SERVER_ERROR);
}
if (! $trashed) {
if (!$trashed) {
return $this->error('Unable to delete message.', Response::HTTP_INTERNAL_SERVER_ERROR);
}
@@ -223,6 +220,9 @@ class MessagesController extends BaseApiController
]);
}
/**
* @return int|JsonResponse
*/
private function authenticatedUserIdOrUnauthorized(): int|JsonResponse
{
$userId = (int) (auth()->id() ?? 0);
@@ -117,12 +117,11 @@ class WhatsappController extends BaseApiController
try {
$result = $this->inviteService->send($request->validated());
} catch (\Throwable $e) {
Log::error('WhatsApp invite send failed: '.$e->getMessage());
Log::error('WhatsApp invite send failed: ' . $e->getMessage());
return $this->error('Invite processing failed.', Response::HTTP_INTERNAL_SERVER_ERROR);
}
if (! ($result['ok'] ?? false)) {
if (!($result['ok'] ?? false)) {
return $this->error($result['message'] ?? 'Invite processing failed.', Response::HTTP_UNPROCESSABLE_ENTITY);
}
@@ -141,12 +140,11 @@ class WhatsappController extends BaseApiController
try {
$result = $this->membershipService->updateMembership($request->validated(), $userId);
} catch (\Throwable $e) {
Log::error('WhatsApp membership update failed: '.$e->getMessage());
Log::error('WhatsApp membership update failed: ' . $e->getMessage());
return $this->error('Failed to save membership.', Response::HTTP_INTERNAL_SERVER_ERROR);
}
if (! ($result['ok'] ?? false)) {
if (!($result['ok'] ?? false)) {
$code = str_contains((string) ($result['message'] ?? ''), 'missing')
? Response::HTTP_INTERNAL_SERVER_ERROR
: Response::HTTP_UNPROCESSABLE_ENTITY;
@@ -160,6 +158,9 @@ class WhatsappController extends BaseApiController
], 'Membership saved.');
}
/**
* @return int|JsonResponse
*/
private function authenticatedUserIdOrUnauthorized(): int|JsonResponse
{
$userId = (int) (auth()->id() ?? 0);