From 5a3001538be6e41671a615dff89ea374008e99d2 Mon Sep 17 00:00:00 2001 From: John Karlo Date: Sat, 4 Nov 2023 12:19:54 +0800 Subject: [PATCH] Install laravel pint --- .../Auth/NewPasswordController.php | 2 +- .../Auth/PasswordResetLinkController.php | 2 +- app/Http/Livewire/AddComment.php | 1 + app/Http/Livewire/CreateIdea.php | 2 ++ app/Http/Livewire/EditComment.php | 1 + app/Http/Livewire/EditIdea.php | 3 +++ app/Http/Livewire/IdeaComment.php | 1 + app/Http/Livewire/IdeaIndex.php | 4 ++- app/Http/Livewire/IdeaShow.php | 4 ++- app/Http/Livewire/IdeasIndex.php | 5 +++- app/Http/Livewire/MarkCommentAsNotSpam.php | 1 - app/Http/Livewire/SetStatus.php | 2 ++ app/Http/Livewire/StatusFilters.php | 6 ++--- app/Models/Comment.php | 1 + app/Models/Idea.php | 5 ++-- app/Models/Status.php | 12 ++++----- app/Policies/CategoryPolicy.php | 1 - app/Policies/CommentPolicy.php | 1 - app/Policies/IdeaPolicy.php | 1 - app/Policies/StatusPolicy.php | 1 - app/Policies/VotePolicy.php | 1 - composer.json | 2 +- composer.lock | 24 ++++++++--------- database/seeders/CategorySeeder.php | 1 - database/seeders/CommentSeeder.php | 1 - database/seeders/IdeaSeeder.php | 1 - database/seeders/StatusSeeder.php | 1 - database/seeders/VoteSeeder.php | 1 - routes/auth.php | 26 +++++++++---------- tests/Feature/AdminSetStatusTest.php | 3 +-- tests/Feature/Comments/AddCommentTest.php | 1 - .../Comments/CommentsSpamManagementTest.php | 12 ++++----- tests/Feature/Comments/ShowCommentsTest.php | 5 ++-- tests/Feature/DeleteIdeaTest.php | 1 - tests/Feature/Filters/OtherFiltersTest.php | 7 +++-- tests/Feature/GravatarTest.php | 8 +++--- tests/Feature/SpamManagementTest.php | 20 +++++++------- tests/Feature/VoteIndexPageTest.php | 14 +++++----- tests/Feature/VoteShowPageTest.php | 13 +++++----- tests/Unit/IdeaTest.php | 1 - tests/Unit/Jobs/NotifyAllVotersTest.php | 2 -- tests/Unit/StatusTest.php | 2 -- 42 files changed, 100 insertions(+), 103 deletions(-) diff --git a/app/Http/Controllers/Auth/NewPasswordController.php b/app/Http/Controllers/Auth/NewPasswordController.php index f1e2814..79ac3cd 100644 --- a/app/Http/Controllers/Auth/NewPasswordController.php +++ b/app/Http/Controllers/Auth/NewPasswordController.php @@ -56,6 +56,6 @@ function ($user) use ($request) { return $status == Password::PASSWORD_RESET ? redirect()->route('login')->with('status', __($status)) : back()->withInput($request->only('email')) - ->withErrors(['email' => __($status)]); + ->withErrors(['email' => __($status)]); } } diff --git a/app/Http/Controllers/Auth/PasswordResetLinkController.php b/app/Http/Controllers/Auth/PasswordResetLinkController.php index ce813a6..bf1ebfa 100644 --- a/app/Http/Controllers/Auth/PasswordResetLinkController.php +++ b/app/Http/Controllers/Auth/PasswordResetLinkController.php @@ -39,6 +39,6 @@ public function store(Request $request): RedirectResponse return $status == Password::RESET_LINK_SENT ? back()->with('status', __($status)) : back()->withInput($request->only('email')) - ->withErrors(['email' => __($status)]); + ->withErrors(['email' => __($status)]); } } diff --git a/app/Http/Livewire/AddComment.php b/app/Http/Livewire/AddComment.php index 19cb7c6..35748a5 100644 --- a/app/Http/Livewire/AddComment.php +++ b/app/Http/Livewire/AddComment.php @@ -10,6 +10,7 @@ class AddComment extends Component { public $idea; + public $comment; protected $rules = [ diff --git a/app/Http/Livewire/CreateIdea.php b/app/Http/Livewire/CreateIdea.php index 96d8197..eff3d0a 100644 --- a/app/Http/Livewire/CreateIdea.php +++ b/app/Http/Livewire/CreateIdea.php @@ -10,7 +10,9 @@ class CreateIdea extends Component { public $title; + public $category = 1; + public $description; protected $rules = [ diff --git a/app/Http/Livewire/EditComment.php b/app/Http/Livewire/EditComment.php index 5dcaed7..99a2814 100644 --- a/app/Http/Livewire/EditComment.php +++ b/app/Http/Livewire/EditComment.php @@ -9,6 +9,7 @@ class EditComment extends Component { public Comment $comment; + public $body; protected $rules = [ diff --git a/app/Http/Livewire/EditIdea.php b/app/Http/Livewire/EditIdea.php index 85c4d4d..261f957 100644 --- a/app/Http/Livewire/EditIdea.php +++ b/app/Http/Livewire/EditIdea.php @@ -10,8 +10,11 @@ class EditIdea extends Component { public $idea; + public $title; + public $category; + public $description; protected $rules = [ diff --git a/app/Http/Livewire/IdeaComment.php b/app/Http/Livewire/IdeaComment.php index f29f7fd..0fbad3c 100644 --- a/app/Http/Livewire/IdeaComment.php +++ b/app/Http/Livewire/IdeaComment.php @@ -8,6 +8,7 @@ class IdeaComment extends Component { public $comment; + public $ideaUserId; protected $listeners = [ diff --git a/app/Http/Livewire/IdeaIndex.php b/app/Http/Livewire/IdeaIndex.php index 0eda909..c326c58 100644 --- a/app/Http/Livewire/IdeaIndex.php +++ b/app/Http/Livewire/IdeaIndex.php @@ -10,7 +10,9 @@ class IdeaIndex extends Component { public $idea; + public $votesCount; + public $hasVoted; public function mount(Idea $idea, $votesCount) @@ -29,7 +31,7 @@ public function vote() if ($this->hasVoted) { try { $this->idea->removeVote(auth()->user()); - } catch(VoteNotFoundException $e) { + } catch (VoteNotFoundException $e) { // Do nothing } $this->votesCount--; diff --git a/app/Http/Livewire/IdeaShow.php b/app/Http/Livewire/IdeaShow.php index 87cce96..c264941 100644 --- a/app/Http/Livewire/IdeaShow.php +++ b/app/Http/Livewire/IdeaShow.php @@ -10,7 +10,9 @@ class IdeaShow extends Component { public $idea; + public $votesCount; + public $hasVoted; protected $listeners = [ @@ -38,7 +40,7 @@ public function vote() if ($this->hasVoted) { try { $this->idea->removeVote(auth()->user()); - } catch(VoteNotFoundException $e) { + } catch (VoteNotFoundException $e) { // Do nothing } $this->votesCount--; diff --git a/app/Http/Livewire/IdeasIndex.php b/app/Http/Livewire/IdeasIndex.php index 801bfc8..804bf58 100644 --- a/app/Http/Livewire/IdeasIndex.php +++ b/app/Http/Livewire/IdeasIndex.php @@ -14,8 +14,11 @@ class IdeasIndex extends Component use WithPagination; public $status; + public $category; + public $filter; + public $search; protected $queryString = [ @@ -94,7 +97,7 @@ public function render() }) ->addSelect(['voted_by_user' => Vote::select('id') ->where('user_id', auth()->id()) - ->whereColumn('idea_id', 'ideas.id') + ->whereColumn('idea_id', 'ideas.id'), ]) ->withCount('votes') ->withCount('comments') diff --git a/app/Http/Livewire/MarkCommentAsNotSpam.php b/app/Http/Livewire/MarkCommentAsNotSpam.php index 4b51ee0..2db45d6 100644 --- a/app/Http/Livewire/MarkCommentAsNotSpam.php +++ b/app/Http/Livewire/MarkCommentAsNotSpam.php @@ -36,4 +36,3 @@ public function render() return view('livewire.mark-comment-as-not-spam'); } } - diff --git a/app/Http/Livewire/SetStatus.php b/app/Http/Livewire/SetStatus.php index 4dcf23e..c3a6e5f 100644 --- a/app/Http/Livewire/SetStatus.php +++ b/app/Http/Livewire/SetStatus.php @@ -10,7 +10,9 @@ class SetStatus extends Component { public $idea; + public $status; + public $notifyAllVoters; public function mount(Idea $idea) diff --git a/app/Http/Livewire/StatusFilters.php b/app/Http/Livewire/StatusFilters.php index 6229383..f826f54 100644 --- a/app/Http/Livewire/StatusFilters.php +++ b/app/Http/Livewire/StatusFilters.php @@ -2,7 +2,6 @@ namespace App\Http\Livewire; -use App\Models\Idea; use App\Models\Status; use Illuminate\Support\Facades\Route; use Livewire\Component; @@ -10,6 +9,7 @@ class StatusFilters extends Component { public $status; + public $statusCount; public function mount() @@ -29,8 +29,8 @@ public function setStatus($newStatus) if ($this->getPreviousRouteName() === 'idea.show') { return redirect()->route('idea.index', [ - 'status' => $this->status, - ]); + 'status' => $this->status, + ]); } } diff --git a/app/Models/Comment.php b/app/Models/Comment.php index 6be0ee4..68508e5 100644 --- a/app/Models/Comment.php +++ b/app/Models/Comment.php @@ -10,6 +10,7 @@ class Comment extends Model use HasFactory; protected $guarded = []; + protected $perPage = 20; public function user() diff --git a/app/Models/Idea.php b/app/Models/Idea.php index e34ec01..90f2aa5 100644 --- a/app/Models/Idea.php +++ b/app/Models/Idea.php @@ -13,6 +13,7 @@ class Idea extends Model use HasFactory, Sluggable; protected $guarded = []; + protected $perPage = 10; public function comments() @@ -24,8 +25,8 @@ public function sluggable(): array { return [ 'slug' => [ - 'source' => 'title' - ] + 'source' => 'title', + ], ]; } diff --git a/app/Models/Status.php b/app/Models/Status.php index dd4e38a..7a091da 100644 --- a/app/Models/Status.php +++ b/app/Models/Status.php @@ -17,12 +17,12 @@ public function ideas() public static function getCount() { return Idea::query() - ->selectRaw("count(*) as all_statuses") - ->selectRaw("count(case when status_id = 1 then 1 end) as open") - ->selectRaw("count(case when status_id = 2 then 1 end) as considering") - ->selectRaw("count(case when status_id = 3 then 1 end) as in_progress") - ->selectRaw("count(case when status_id = 4 then 1 end) as implemented") - ->selectRaw("count(case when status_id = 5 then 1 end) as closed") + ->selectRaw('count(*) as all_statuses') + ->selectRaw('count(case when status_id = 1 then 1 end) as open') + ->selectRaw('count(case when status_id = 2 then 1 end) as considering') + ->selectRaw('count(case when status_id = 3 then 1 end) as in_progress') + ->selectRaw('count(case when status_id = 4 then 1 end) as implemented') + ->selectRaw('count(case when status_id = 5 then 1 end) as closed') ->first() ->toArray(); } diff --git a/app/Policies/CategoryPolicy.php b/app/Policies/CategoryPolicy.php index b7782e8..f95891e 100644 --- a/app/Policies/CategoryPolicy.php +++ b/app/Policies/CategoryPolicy.php @@ -4,7 +4,6 @@ use App\Models\Category; use App\Models\User; -use Illuminate\Auth\Access\Response; class CategoryPolicy { diff --git a/app/Policies/CommentPolicy.php b/app/Policies/CommentPolicy.php index 77f59a2..2a421ef 100644 --- a/app/Policies/CommentPolicy.php +++ b/app/Policies/CommentPolicy.php @@ -4,7 +4,6 @@ use App\Models\Comment; use App\Models\User; -use Illuminate\Auth\Access\Response; class CommentPolicy { diff --git a/app/Policies/IdeaPolicy.php b/app/Policies/IdeaPolicy.php index 5120b89..0ed65b3 100644 --- a/app/Policies/IdeaPolicy.php +++ b/app/Policies/IdeaPolicy.php @@ -4,7 +4,6 @@ use App\Models\Idea; use App\Models\User; -use Illuminate\Auth\Access\Response; class IdeaPolicy { diff --git a/app/Policies/StatusPolicy.php b/app/Policies/StatusPolicy.php index c9c2526..13b22fc 100644 --- a/app/Policies/StatusPolicy.php +++ b/app/Policies/StatusPolicy.php @@ -4,7 +4,6 @@ use App\Models\Status; use App\Models\User; -use Illuminate\Auth\Access\Response; class StatusPolicy { diff --git a/app/Policies/VotePolicy.php b/app/Policies/VotePolicy.php index aeca9a9..35313e2 100644 --- a/app/Policies/VotePolicy.php +++ b/app/Policies/VotePolicy.php @@ -4,7 +4,6 @@ use App\Models\User; use App\Models\Vote; -use Illuminate\Auth\Access\Response; class VotePolicy { diff --git a/composer.json b/composer.json index ec562d5..3124da1 100644 --- a/composer.json +++ b/composer.json @@ -18,7 +18,7 @@ "barryvdh/laravel-debugbar": "^3.8", "fakerphp/faker": "^1.9.1", "laravel/breeze": "^1.21", - "laravel/pint": "^1.0", + "laravel/pint": "^1.13", "laravel/sail": "^1.22", "mockery/mockery": "^1.4.4", "nunomaduro/collision": "^7.0", diff --git a/composer.lock b/composer.lock index 0b8bc7e..94d05e9 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "c4327ac6c886ca544060d9a80b3d47f4", + "content-hash": "0e8a32fc17ae30c17167c97f0323d2fe", "packages": [ { "name": "brick/math", @@ -6405,16 +6405,16 @@ }, { "name": "laravel/pint", - "version": "v1.10.0", + "version": "v1.13.5", "source": { "type": "git", "url": "https://github.com/laravel/pint.git", - "reference": "c7a01fa9bdd79819e7a2f1ba63ac1b02e6692dbc" + "reference": "df105cf8ce7a8f0b8a9425ff45cd281a5448e423" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/laravel/pint/zipball/c7a01fa9bdd79819e7a2f1ba63ac1b02e6692dbc", - "reference": "c7a01fa9bdd79819e7a2f1ba63ac1b02e6692dbc", + "url": "https://api.github.com/repos/laravel/pint/zipball/df105cf8ce7a8f0b8a9425ff45cd281a5448e423", + "reference": "df105cf8ce7a8f0b8a9425ff45cd281a5448e423", "shasum": "" }, "require": { @@ -6425,13 +6425,13 @@ "php": "^8.1.0" }, "require-dev": { - "friendsofphp/php-cs-fixer": "^3.16.0", - "illuminate/view": "^10.5.1", - "laravel-zero/framework": "^10.0.2", - "mockery/mockery": "^1.5.1", - "nunomaduro/larastan": "^2.5.1", + "friendsofphp/php-cs-fixer": "^3.34.1", + "illuminate/view": "^10.26.2", + "laravel-zero/framework": "^10.1.2", + "mockery/mockery": "^1.6.6", + "nunomaduro/larastan": "^2.6.4", "nunomaduro/termwind": "^1.15.1", - "pestphp/pest": "^2.4.0" + "pestphp/pest": "^2.20.0" }, "bin": [ "builds/pint" @@ -6467,7 +6467,7 @@ "issues": "https://github.com/laravel/pint/issues", "source": "https://github.com/laravel/pint" }, - "time": "2023-04-25T14:52:30+00:00" + "time": "2023-10-26T09:26:10+00:00" }, { "name": "laravel/sail", diff --git a/database/seeders/CategorySeeder.php b/database/seeders/CategorySeeder.php index bc3c0e2..99c46a2 100644 --- a/database/seeders/CategorySeeder.php +++ b/database/seeders/CategorySeeder.php @@ -2,7 +2,6 @@ namespace Database\Seeders; -use Illuminate\Database\Console\Seeds\WithoutModelEvents; use Illuminate\Database\Seeder; class CategorySeeder extends Seeder diff --git a/database/seeders/CommentSeeder.php b/database/seeders/CommentSeeder.php index 5f45105..6569c38 100644 --- a/database/seeders/CommentSeeder.php +++ b/database/seeders/CommentSeeder.php @@ -2,7 +2,6 @@ namespace Database\Seeders; -use Illuminate\Database\Console\Seeds\WithoutModelEvents; use Illuminate\Database\Seeder; class CommentSeeder extends Seeder diff --git a/database/seeders/IdeaSeeder.php b/database/seeders/IdeaSeeder.php index 49bf8cc..e0195f1 100644 --- a/database/seeders/IdeaSeeder.php +++ b/database/seeders/IdeaSeeder.php @@ -2,7 +2,6 @@ namespace Database\Seeders; -use Illuminate\Database\Console\Seeds\WithoutModelEvents; use Illuminate\Database\Seeder; class IdeaSeeder extends Seeder diff --git a/database/seeders/StatusSeeder.php b/database/seeders/StatusSeeder.php index e86695f..477c706 100644 --- a/database/seeders/StatusSeeder.php +++ b/database/seeders/StatusSeeder.php @@ -2,7 +2,6 @@ namespace Database\Seeders; -use Illuminate\Database\Console\Seeds\WithoutModelEvents; use Illuminate\Database\Seeder; class StatusSeeder extends Seeder diff --git a/database/seeders/VoteSeeder.php b/database/seeders/VoteSeeder.php index 1ff24a7..6d8d4ba 100644 --- a/database/seeders/VoteSeeder.php +++ b/database/seeders/VoteSeeder.php @@ -2,7 +2,6 @@ namespace Database\Seeders; -use Illuminate\Database\Console\Seeds\WithoutModelEvents; use Illuminate\Database\Seeder; class VoteSeeder extends Seeder diff --git a/routes/auth.php b/routes/auth.php index 1040b51..3926ecf 100644 --- a/routes/auth.php +++ b/routes/auth.php @@ -13,47 +13,47 @@ Route::middleware('guest')->group(function () { Route::get('register', [RegisteredUserController::class, 'create']) - ->name('register'); + ->name('register'); Route::post('register', [RegisteredUserController::class, 'store']); Route::get('login', [AuthenticatedSessionController::class, 'create']) - ->name('login'); + ->name('login'); Route::post('login', [AuthenticatedSessionController::class, 'store']); Route::get('forgot-password', [PasswordResetLinkController::class, 'create']) - ->name('password.request'); + ->name('password.request'); Route::post('forgot-password', [PasswordResetLinkController::class, 'store']) - ->name('password.email'); + ->name('password.email'); Route::get('reset-password/{token}', [NewPasswordController::class, 'create']) - ->name('password.reset'); + ->name('password.reset'); Route::post('reset-password', [NewPasswordController::class, 'store']) - ->name('password.store'); + ->name('password.store'); }); Route::middleware('auth')->group(function () { Route::get('verify-email', EmailVerificationPromptController::class) - ->name('verification.notice'); + ->name('verification.notice'); Route::get('verify-email/{id}/{hash}', VerifyEmailController::class) - ->middleware(['signed', 'throttle:6,1']) - ->name('verification.verify'); + ->middleware(['signed', 'throttle:6,1']) + ->name('verification.verify'); Route::post('email/verification-notification', [EmailVerificationNotificationController::class, 'store']) - ->middleware('throttle:6,1') - ->name('verification.send'); + ->middleware('throttle:6,1') + ->name('verification.send'); Route::get('confirm-password', [ConfirmablePasswordController::class, 'show']) - ->name('password.confirm'); + ->name('password.confirm'); Route::post('confirm-password', [ConfirmablePasswordController::class, 'store']); Route::put('password', [PasswordController::class, 'update'])->name('password.update'); Route::post('logout', [AuthenticatedSessionController::class, 'destroy']) - ->name('logout'); + ->name('logout'); }); diff --git a/tests/Feature/AdminSetStatusTest.php b/tests/Feature/AdminSetStatusTest.php index 62df5cb..5244433 100644 --- a/tests/Feature/AdminSetStatusTest.php +++ b/tests/Feature/AdminSetStatusTest.php @@ -34,7 +34,7 @@ public function show_page_contains_set_status_livewire_component_when_user_is_ad public function show_page_does_not_contain_set_status_livewire_component_when_user_is_not_admin() { $user = User::factory()->create([ - 'email' => 'testuser@gmail.com' + 'email' => 'testuser@gmail.com', ]); $idea = Idea::factory()->create([ @@ -120,4 +120,3 @@ public function can_set_status_correctly_while_notifying_all_voters() Queue::assertPushed(NotifyAllVoters::class); } } - diff --git a/tests/Feature/Comments/AddCommentTest.php b/tests/Feature/Comments/AddCommentTest.php index 75a2bdb..2f43d37 100644 --- a/tests/Feature/Comments/AddCommentTest.php +++ b/tests/Feature/Comments/AddCommentTest.php @@ -81,4 +81,3 @@ public function add_comment_form__works() $this->assertEquals('This is my first comment', $idea->comments->first()->body); } } - diff --git a/tests/Feature/Comments/CommentsSpamManagementTest.php b/tests/Feature/Comments/CommentsSpamManagementTest.php index 5bafe7b..c76f0dd 100644 --- a/tests/Feature/Comments/CommentsSpamManagementTest.php +++ b/tests/Feature/Comments/CommentsSpamManagementTest.php @@ -100,7 +100,7 @@ public function marking_a_comment_as_spam_shows_on_menu_when_user_has_authorizat Livewire::actingAs($user) ->test(IdeaComment::class, [ 'comment' => $comment, - 'ideaUserId' => $idea->user_id + 'ideaUserId' => $idea->user_id, ]) ->assertSee('Mark as Spam'); } @@ -118,9 +118,9 @@ public function marking_a_comment_as_spam_does_not_show_on_menu_when_user_does_n ]); Livewire::test(IdeaComment::class, [ - 'comment' => $comment, - 'ideaUserId' => $idea->user_id - ]) + 'comment' => $comment, + 'ideaUserId' => $idea->user_id, + ]) ->assertDontSee('Mark as Spam'); } @@ -212,7 +212,7 @@ public function marking_a_comment_as_not_spam_shows_on_menu_when_user_has_author Livewire::actingAs($user) ->test(IdeaComment::class, [ 'comment' => $comment, - 'ideaUserId' => $idea->user_id + 'ideaUserId' => $idea->user_id, ]) ->assertSee('Not Spam'); } @@ -232,7 +232,7 @@ public function marking_a_comment_as_not_spam_does_not_show_on_menu_when_user_do Livewire::actingAs($user) ->test(IdeaComment::class, [ 'comment' => $comment, - 'ideaUserId' => $idea->user_id + 'ideaUserId' => $idea->user_id, ]) ->assertDontSee('Not Spam'); } diff --git a/tests/Feature/Comments/ShowCommentsTest.php b/tests/Feature/Comments/ShowCommentsTest.php index b7b1daa..ca45221 100644 --- a/tests/Feature/Comments/ShowCommentsTest.php +++ b/tests/Feature/Comments/ShowCommentsTest.php @@ -71,7 +71,7 @@ public function list_of_comments_shows_on_idea_page() $response->assertSeeInOrder([ $commentOne->body, - $commentTwo->body + $commentTwo->body, ]); $response->assertSee('2 comments'); } @@ -127,7 +127,7 @@ public function comments_pagination_works() $idea = Idea::factory()->create(); $commentOne = Comment::factory()->create([ - 'idea_id' => $idea + 'idea_id' => $idea, ]); Comment::factory($commentOne->getPerPage())->create([ @@ -148,4 +148,3 @@ public function comments_pagination_works() $response->assertSee(Comment::find(Comment::count())->body); } } - diff --git a/tests/Feature/DeleteIdeaTest.php b/tests/Feature/DeleteIdeaTest.php index 6d5b966..c3c7172 100644 --- a/tests/Feature/DeleteIdeaTest.php +++ b/tests/Feature/DeleteIdeaTest.php @@ -170,4 +170,3 @@ public function deleting_an_idea_does_not_show_on_menu_when_user_does_not_have_a ->assertDontSee('Delete Idea'); } } - diff --git a/tests/Feature/Filters/OtherFiltersTest.php b/tests/Feature/Filters/OtherFiltersTest.php index 128084d..c257a69 100644 --- a/tests/Feature/Filters/OtherFiltersTest.php +++ b/tests/Feature/Filters/OtherFiltersTest.php @@ -200,17 +200,17 @@ public function spam_ideas_filter_works() Idea::factory()->create([ 'title' => 'Idea One', - 'spam_reports' => 1 + 'spam_reports' => 1, ]); Idea::factory()->create([ 'title' => 'Idea Two', - 'spam_reports' => 2 + 'spam_reports' => 2, ]); Idea::factory()->create([ 'title' => 'Idea Three', - 'spam_reports' => 3 + 'spam_reports' => 3, ]); Idea::factory()->create(); @@ -263,4 +263,3 @@ public function spam_comments_filter_works() }); } } - diff --git a/tests/Feature/GravatarTest.php b/tests/Feature/GravatarTest.php index 36c385c..8c5269b 100644 --- a/tests/Feature/GravatarTest.php +++ b/tests/Feature/GravatarTest.php @@ -21,7 +21,7 @@ public function user_can_generate_gravatar_default_image_when_no_email_found_fir $gravatarUrl = $user->getAvatar(); $this->assertEquals( - "https://www.gravatar.com/avatar/" . md5($user->email) . "?s200&d=https://s3.amazonaws.com/laracasts/images/forum/avatars/default-avatar-1.png", + 'https://www.gravatar.com/avatar/'.md5($user->email).'?s200&d=https://s3.amazonaws.com/laracasts/images/forum/avatars/default-avatar-1.png', $gravatarUrl ); } @@ -37,7 +37,7 @@ public function user_can_generate_gravatar_default_image_when_no_email_found_fir $gravatarUrl = $user->getAvatar(); $this->assertEquals( - "https://www.gravatar.com/avatar/" . md5($user->email) . "?s200&d=https://s3.amazonaws.com/laracasts/images/forum/avatars/default-avatar-26.png", + 'https://www.gravatar.com/avatar/'.md5($user->email).'?s200&d=https://s3.amazonaws.com/laracasts/images/forum/avatars/default-avatar-26.png', $gravatarUrl ); } @@ -53,7 +53,7 @@ public function user_can_generate_gravatar_default_image_when_no_email_found_fir $gravatarUrl = $user->getAvatar(); $this->assertEquals( - "https://www.gravatar.com/avatar/" . md5($user->email) . "?s200&d=https://s3.amazonaws.com/laracasts/images/forum/avatars/default-avatar-27.png", + 'https://www.gravatar.com/avatar/'.md5($user->email).'?s200&d=https://s3.amazonaws.com/laracasts/images/forum/avatars/default-avatar-27.png', $gravatarUrl ); } @@ -69,7 +69,7 @@ public function user_can_generate_gravatar_default_image_when_no_email_found_fir $gravatarUrl = $user->getAvatar(); $this->assertEquals( - "https://www.gravatar.com/avatar/" . md5($user->email) . "?s200&d=https://s3.amazonaws.com/laracasts/images/forum/avatars/default-avatar-36.png", + 'https://www.gravatar.com/avatar/'.md5($user->email).'?s200&d=https://s3.amazonaws.com/laracasts/images/forum/avatars/default-avatar-36.png', $gravatarUrl ); } diff --git a/tests/Feature/SpamManagementTest.php b/tests/Feature/SpamManagementTest.php index 4ea7b00..72a4f50 100644 --- a/tests/Feature/SpamManagementTest.php +++ b/tests/Feature/SpamManagementTest.php @@ -61,8 +61,8 @@ public function marking_an_idea_as_spam_does_not_work_when_user_does_not_have_au $idea = Idea::factory()->create(); Livewire::test(MarkIdeaAsSpam::class, [ - 'idea' => $idea, - ]) + 'idea' => $idea, + ]) ->call('markAsSpam') ->assertStatus(Response::HTTP_FORBIDDEN); } @@ -87,9 +87,9 @@ public function marking_an_idea_as_spam_does_not_show_on_menu_when_user_does_not $idea = Idea::factory()->create(); Livewire::test(IdeaShow::class, [ - 'idea' => $idea, - 'votesCount' => 4, - ]) + 'idea' => $idea, + 'votesCount' => 4, + ]) ->assertDontSee('Mark as Spam'); } @@ -137,8 +137,8 @@ public function marking_an_idea_as_not_spam_does_not_work_when_user_does_not_hav $idea = Idea::factory()->create(); Livewire::test(MarkIdeaAsNotSpam::class, [ - 'idea' => $idea, - ]) + 'idea' => $idea, + ]) ->call('markAsNotSpam') ->assertStatus(Response::HTTP_FORBIDDEN); } @@ -165,9 +165,9 @@ public function marking_an_idea_as_not_spam_does_not_show_on_menu_when_user_does $idea = Idea::factory()->create(); Livewire::test(IdeaShow::class, [ - 'idea' => $idea, - 'votesCount' => 4, - ]) + 'idea' => $idea, + 'votesCount' => 4, + ]) ->assertDontSee('Not Spam'); } diff --git a/tests/Feature/VoteIndexPageTest.php b/tests/Feature/VoteIndexPageTest.php index 1f644d3..736d583 100644 --- a/tests/Feature/VoteIndexPageTest.php +++ b/tests/Feature/VoteIndexPageTest.php @@ -43,7 +43,7 @@ public function index_index_livewire_component_correcly_receive_votes_count() ]); Livewire::test(IdeasIndex::class) - ->assertViewHas('ideas', function($ideas) { + ->assertViewHas('ideas', function ($ideas) { return $ideas->first()->votes_count == 2; }); } @@ -55,9 +55,9 @@ public function votes_count_shows_correctly_on_index_page_livewire_component() 'idea' => Idea::factory()->create(), 'votesCount' => 5, ]) - ->assertset('votesCount', 5) - ->assertseehtml('
5
') - ->assertseehtml('
5
'); + ->assertset('votesCount', 5) + ->assertseehtml('
5
') + ->assertseehtml('
5
'); } /** @test */ @@ -90,9 +90,9 @@ public function user_who_is_not_logged_in_is_redirected_to_login_page_when_tryin $idea = Idea::factory()->create(); Livewire::test(IdeaIndex::class, [ - 'idea' => $idea, - 'votesCount' => 5, - ]) + 'idea' => $idea, + 'votesCount' => 5, + ]) ->call('vote') ->assertRedirect(route('login')); } diff --git a/tests/Feature/VoteShowPageTest.php b/tests/Feature/VoteShowPageTest.php index e3c61d6..99e215e 100644 --- a/tests/Feature/VoteShowPageTest.php +++ b/tests/Feature/VoteShowPageTest.php @@ -60,12 +60,11 @@ public function votes_count_shows_correctly_on_show_page_livewire_component() 'idea' => $idea, 'votesCount' => 5, ]) - ->assertSet('votesCount', 5) - ->assertSeeHtml('
5
') - ->assertSeeHtml('
5
'); + ->assertSet('votesCount', 5) + ->assertSeeHtml('
5
') + ->assertSeeHtml('
5
'); } - /** @test */ public function user_who_is_logged_in_shows_voted_if_idea_already_voted_for() { @@ -99,9 +98,9 @@ public function user_who_is_not_logged_in_is_redirected_to_login_page_when_tryin ]); Livewire::test(IdeaShow::class, [ - 'idea' => $idea, - 'votesCount' => 5, - ]) + 'idea' => $idea, + 'votesCount' => 5, + ]) ->call('vote') ->assertRedirect(route('login')); } diff --git a/tests/Unit/IdeaTest.php b/tests/Unit/IdeaTest.php index cc91b70..11134bc 100644 --- a/tests/Unit/IdeaTest.php +++ b/tests/Unit/IdeaTest.php @@ -100,4 +100,3 @@ public function removing_a_vote_that_doesnt_exist_throws_exception() $idea->removeVote($userOne); } } - diff --git a/tests/Unit/Jobs/NotifyAllVotersTest.php b/tests/Unit/Jobs/NotifyAllVotersTest.php index cdc11fb..e93968e 100644 --- a/tests/Unit/Jobs/NotifyAllVotersTest.php +++ b/tests/Unit/Jobs/NotifyAllVotersTest.php @@ -4,9 +4,7 @@ use App\Jobs\NotifyAllVoters; use App\Mail\IdeaStatusUpdatedMailable; -use App\Models\Category; use App\Models\Idea; -use App\Models\Status; use App\Models\User; use App\Models\Vote; use Illuminate\Foundation\Testing\RefreshDatabase; diff --git a/tests/Unit/StatusTest.php b/tests/Unit/StatusTest.php index 8a3a55d..2e37d5f 100644 --- a/tests/Unit/StatusTest.php +++ b/tests/Unit/StatusTest.php @@ -2,10 +2,8 @@ namespace Tests\Unit; -use App\Models\Category; use App\Models\Idea; use App\Models\Status; -use App\Models\User; use Illuminate\Foundation\Testing\RefreshDatabase; use Tests\TestCase;