Skip to content

Commit

Permalink
style issues fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
muhammadmp97 committed Sep 12, 2023
1 parent a4f14c2 commit 192f160
Show file tree
Hide file tree
Showing 31 changed files with 51 additions and 53 deletions.
2 changes: 1 addition & 1 deletion app/Actions/Achievement/CreateUserAchievement.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public function execute(User $user, array $achievement)
]);

$user->notify(new AchievementEarnedNotification($achievement));

$user->score += $achievement['score'];
$user->save();
});
Expand Down
2 changes: 1 addition & 1 deletion app/Actions/Challenge/CreateCommentAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public function execute(User $user, Challenge $challenge, array $data): Comment
$challenge
->user
->notify(new ChallengeCommentedNotification($comment));

CommentCreated::dispatch($comment);

return $comment;
Expand Down
2 changes: 0 additions & 2 deletions app/Actions/Challenge/UpdateCommentAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@

namespace App\Actions\Challenge;

use App\Models\Challenge;
use App\Models\Comment;
use App\Models\User;

class UpdateCommentAction
{
Expand Down
2 changes: 1 addition & 1 deletion app/Actions/User/ChangePasswordAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public function execute(User $user, $data): void
}

$user->update([
'password' => Hash::make($data['password'])
'password' => Hash::make($data['password']),
]);
}
}
4 changes: 2 additions & 2 deletions app/Actions/User/FollowUserAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ public function execute(User $follower, User $following): void

if (! $userIsFollowed) {
$follower
->following()
->attach($following->id);
->following()
->attach($following->id);

$following->notify(new NewFollowerNotification($follower));
}
Expand Down
18 changes: 9 additions & 9 deletions app/Console/Commands/HandleDeactivationRequests.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,19 @@ public function handle()
$userIds = DeactivationRequest::query()
->where('created_at', '<', now()->subDays(10))
->pluck('user_id');

DB::transaction(function () use ($userIds) {
$users = User::query()
->whereIn('id', $userIds)
->get();
->whereIn('id', $userIds)
->get();

foreach ($users as $user) {
$user->delete();
}
foreach ($users as $user) {
$user->delete();
}

DeactivationRequest::query()
->whereIn('user_id', $userIds)
->delete();
DeactivationRequest::query()
->whereIn('user_id', $userIds)
->delete();
});

return $this->comment('Done!');
Expand Down
2 changes: 1 addition & 1 deletion app/Console/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ protected function schedule(Schedule $schedule): void
$schedule->command('sanctum:prune-expired --hours=24')->daily();

$schedule->command('app:close-abandoned-challenges')->hourly();

$schedule->command('app:handle-deactivation-requests')->daily();
}

Expand Down
3 changes: 2 additions & 1 deletion app/Events/ChallengeContinued.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@ class ChallengeContinued

public function __construct(
public Challenge $challenge
) {}
) {
}
}
3 changes: 2 additions & 1 deletion app/Events/ChallengeCreated.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@ class ChallengeCreated

public function __construct(
public Challenge $challenge
) {}
) {
}
}
3 changes: 2 additions & 1 deletion app/Events/CommentCreated.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,6 @@ class CommentCreated

public function __construct(
public Comment $comment
) {}
) {
}
}
4 changes: 2 additions & 2 deletions app/Http/Controllers/ChallengeCommentsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@

use App\Actions\Challenge\CreateCommentAction;
use App\Actions\Challenge\UpdateCommentAction;
use App\Http\Resources\CommentResource;
use App\Models\Challenge;
use App\Http\Requests\CreateCommentRequest;
use App\Http\Requests\UpdateCommentRequest;
use App\Http\Resources\CommentResource;
use App\Models\Challenge;
use App\Models\Comment;
use Illuminate\Validation\UnauthorizedException;

Expand Down
2 changes: 1 addition & 1 deletion app/Http/Controllers/NotificationsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public function index()
->user()
->unreadNotifications
->markAsRead();

return $this->ok(
NotificationResource::collection($notifications)
);
Expand Down
1 change: 0 additions & 1 deletion app/Http/Resources/CommentResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

namespace App\Http\Resources;

use App\Models\Challenge;
use Illuminate\Http\Request;
use Illuminate\Http\Resources\Json\JsonResource;

Expand Down
3 changes: 2 additions & 1 deletion app/Listeners/ChallengeAchievementsListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ class ChallengeAchievementsListener implements ShouldQueue
{
public function __construct(
public CreateUserAchievement $createUserAchievement
) {}
) {
}

public function handle($event)
{
Expand Down
3 changes: 2 additions & 1 deletion app/Listeners/CheckCommentContent.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ class CheckCommentContent implements ShouldQueue
public function __construct(
public AbuseDetector $abuseDetector,
public ReportAction $reportAction
) {}
) {
}

public function handle(CommentCreated $event): void
{
Expand Down
3 changes: 2 additions & 1 deletion app/Notifications/AchievementEarnedNotification.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ class AchievementEarnedNotification extends Notification implements ShouldQueue

public function __construct(
private array $achievement
) {}
) {
}

public function via(object $notifiable): array
{
Expand Down
3 changes: 2 additions & 1 deletion app/Notifications/ChallengeCommentedNotification.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ class ChallengeCommentedNotification extends Notification implements ShouldQueue

public function __construct(
private Comment $comment
) {}
) {
}

public function via(object $notifiable): array
{
Expand Down
3 changes: 2 additions & 1 deletion app/Notifications/ChallengeLikedNotification.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ class ChallengeLikedNotification extends Notification implements ShouldQueue
public function __construct(
private User $user,
private Challenge $challenge,
) {}
) {
}

public function via(object $notifiable): array
{
Expand Down
3 changes: 2 additions & 1 deletion app/Notifications/NewFollowerNotification.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ class NewFollowerNotification extends Notification implements ShouldQueue

public function __construct(
private User $follower
) {}
) {
}

public function via(object $notifiable): array
{
Expand Down
3 changes: 2 additions & 1 deletion app/Services/AbuseDetection/Komprehend.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ class Komprehend implements AbuseDetector

public function __construct(
public string $token
) {}
) {
}

public function check(string $text): bool
{
Expand Down
2 changes: 1 addition & 1 deletion app/Services/Achievement.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

class Achievement
{
public static function getByPassedDays(int $days): array|null
public static function getByPassedDays(int $days): ?array
{
$achievements = config('hope.achievements');

Expand Down
2 changes: 0 additions & 2 deletions database/seeders/DatabaseSeeder.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ class DatabaseSeeder extends Seeder
{
/**
* Seed the application's database.
*
* @return void
*/
public function run(): void
{
Expand Down
2 changes: 1 addition & 1 deletion routes/api.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<?php

use App\Http\Controllers\CountriesController;
use App\Http\Controllers\AuthController;
use App\Http\Controllers\ChallengeCommentsController;
use App\Http\Controllers\ChallengeLikesController;
use App\Http\Controllers\ChallengesController;
use App\Http\Controllers\ContinueChallengeController;
use App\Http\Controllers\CountriesController;
use App\Http\Controllers\DeactivationRequestsController;
use App\Http\Controllers\NotificationsController;
use App\Http\Controllers\ProfileController;
Expand Down
4 changes: 2 additions & 2 deletions tests/Feature/AuthControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public function test_user_logs_in()

$this->postJson('api/auth/login', [
'email' => $user->email,
'password' => '12345678'
'password' => '12345678',
])->assertOk();
}

Expand All @@ -52,7 +52,7 @@ public function test_wrong_credentials_dont_work()

$this->postJson('api/auth/login', [
'email' => $user->email,
'password' => 'password'
'password' => 'password',
])->assertStatus(401);
}

Expand Down
2 changes: 1 addition & 1 deletion tests/Feature/ChallengeCommentsControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public function test_user_leaves_a_comment()
User::factory()->create([
'email' => config('hope.hope_bot_mail'),
]);

$response = $this->postJson('api/challenges/1/comments', [
'text' => 'You ****** *****!',
]);
Expand Down
4 changes: 2 additions & 2 deletions tests/Feature/ChallengeLikesControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public function test_user_likes_a_challenge()

$this->postJson('api/challenges/1/likes')
->assertOk();

$this->assertEquals(1, Challenge::first()->likes()->count());

Notification::assertSentTo($this->user, ChallengeLikedNotification::class);
Expand All @@ -76,7 +76,7 @@ public function test_user_unlikes_a_challenge()

$this->deleteJson('api/challenges/1/likes')
->assertOk();

$this->assertEquals(0, Challenge::first()->likes()->count());
}
}
4 changes: 2 additions & 2 deletions tests/Feature/DeactivationRequestsControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ public function setUp(): void

public function test_user_requests_account_deactivation()
{
Sanctum::actingAs($this->user);
Sanctum::actingAs($this->user);
$this->user->currentAccessToken()->shouldReceive('delete')->once();

$this
->postJson('api/deactivate')
->assertOk();
Expand Down
8 changes: 0 additions & 8 deletions tests/Feature/NotificationsControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,9 @@

namespace Tests\Feature;

use App\Models\Challenge;
use App\Models\Country;
use App\Models\User;
use App\Notifications\ChallengeCommentedNotification;
use App\Notifications\NewFollowerNotification;
use App\Services\AbuseDetection\AbuseDetector;
use App\Services\AbuseDetection\Komprehend;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Facades\Notification;
use Mockery;
use Mockery\MockInterface;
use Tests\TestCase;

class NotificationsControllerTest extends TestCase
Expand Down
2 changes: 1 addition & 1 deletion tests/Feature/ProfileControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ public function test_user_profile_can_be_updated()
];

$response = $this->patchJson('api/profile', $data);

$response
->assertOk()
->assertJson([
Expand Down
4 changes: 3 additions & 1 deletion tests/Feature/UserAchievementsControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,11 @@ class UserAchievementsControllerTest extends TestCase
use RefreshDatabase;

private $user;

private $challenge;

private CreateChallengeAction $createChallengeAction;

private ContinueChallengeAction $continueChallengeAction;

public function setUp(): void
Expand Down
1 change: 0 additions & 1 deletion tests/Feature/UserFollowingControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
use App\Models\Country;
use App\Models\User;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Facades\DB;
use Tests\TestCase;

class UserFollowingControllerTest extends TestCase
Expand Down

0 comments on commit 192f160

Please sign in to comment.