From 728dec946cfdc8d3dfd81963aa8df26943704db5 Mon Sep 17 00:00:00 2001 From: Matias Ibargoyen Date: Sun, 18 Jul 2021 14:37:44 +0100 Subject: [PATCH] Adds type hints in tests --- tests/Feature/ContactsTest.php | 21 +++++++++++---------- tests/Feature/OrganizationsTest.php | 15 ++++++++------- 2 files changed, 19 insertions(+), 17 deletions(-) diff --git a/tests/Feature/ContactsTest.php b/tests/Feature/ContactsTest.php index ea30143..c5d67b6 100644 --- a/tests/Feature/ContactsTest.php +++ b/tests/Feature/ContactsTest.php @@ -5,6 +5,7 @@ namespace Tests\Feature; use App\Models\Account; use App\Models\User; use Illuminate\Foundation\Testing\RefreshDatabase; +use Inertia\Testing\Assert; use Tests\TestCase; class ContactsTest extends TestCase @@ -56,26 +57,26 @@ class ContactsTest extends TestCase { $this->actingAs($this->user) ->get('/contacts') - ->assertInertia(fn ($assert) => $assert + ->assertInertia(fn (Assert $assert) => $assert ->component('Contacts/Index') ->has('contacts.data', 2) - ->has('contacts.data.0', fn ($assert) => $assert + ->has('contacts.data.0', fn (Assert $assert) => $assert ->where('id', 1) ->where('name', 'Martin Abbott') ->where('phone', '555-111-2222') ->where('city', 'Murphyland') ->where('deleted_at', null) - ->has('organization', fn ($assert) => $assert + ->has('organization', fn (Assert $assert) => $assert ->where('name', 'Example Organization Inc.') ) ) - ->has('contacts.data.1', fn ($assert) => $assert + ->has('contacts.data.1', fn (Assert $assert) => $assert ->where('id', 2) ->where('name', 'Lynn Kub') ->where('phone', '555-333-4444') ->where('city', 'Woodstock') ->where('deleted_at', null) - ->has('organization', fn ($assert) => $assert + ->has('organization', fn (Assert $assert) => $assert ->where('name', 'Example Organization Inc.') ) ) @@ -86,17 +87,17 @@ class ContactsTest extends TestCase { $this->actingAs($this->user) ->get('/contacts?search=Martin') - ->assertInertia(fn ($assert) => $assert + ->assertInertia(fn (Assert $assert) => $assert ->component('Contacts/Index') ->where('filters.search', 'Martin') ->has('contacts.data', 1) - ->has('contacts.data.0', fn ($assert) => $assert + ->has('contacts.data.0', fn (Assert $assert) => $assert ->where('id', 1) ->where('name', 'Martin Abbott') ->where('phone', '555-111-2222') ->where('city', 'Murphyland') ->where('deleted_at', null) - ->has('organization', fn ($assert) => $assert + ->has('organization', fn (Assert $assert) => $assert ->where('name', 'Example Organization Inc.') ) ) @@ -109,7 +110,7 @@ class ContactsTest extends TestCase $this->actingAs($this->user) ->get('/contacts') - ->assertInertia(fn ($assert) => $assert + ->assertInertia(fn (Assert $assert) => $assert ->component('Contacts/Index') ->has('contacts.data', 1) ->where('contacts.data.0.name', 'Lynn Kub') @@ -122,7 +123,7 @@ class ContactsTest extends TestCase $this->actingAs($this->user) ->get('/contacts?trashed=with') - ->assertInertia(fn ($assert) => $assert + ->assertInertia(fn (Assert $assert) => $assert ->component('Contacts/Index') ->has('contacts.data', 2) ->where('contacts.data.0.name', 'Martin Abbott') diff --git a/tests/Feature/OrganizationsTest.php b/tests/Feature/OrganizationsTest.php index c1a6b1f..efd49a2 100644 --- a/tests/Feature/OrganizationsTest.php +++ b/tests/Feature/OrganizationsTest.php @@ -5,6 +5,7 @@ namespace Tests\Feature; use App\Models\Account; use App\Models\User; use Illuminate\Foundation\Testing\RefreshDatabase; +use Inertia\Testing\Assert; use Tests\TestCase; class OrganizationsTest extends TestCase @@ -50,17 +51,17 @@ class OrganizationsTest extends TestCase { $this->actingAs($this->user) ->get('/organizations') - ->assertInertia(fn ($assert) => $assert + ->assertInertia(fn (Assert $assert) => $assert ->component('Organizations/Index') ->has('organizations.data', 2) - ->has('organizations.data.0', fn ($assert) => $assert + ->has('organizations.data.0', fn (Assert $assert) => $assert ->where('id', 1) ->where('name', 'Apple') ->where('phone', '647-943-4400') ->where('city', 'Toronto') ->where('deleted_at', null) ) - ->has('organizations.data.1', fn ($assert) => $assert + ->has('organizations.data.1', fn (Assert $assert) => $assert ->where('id', 2) ->where('name', 'Microsoft') ->where('phone', '877-568-2495') @@ -74,11 +75,11 @@ class OrganizationsTest extends TestCase { $this->actingAs($this->user) ->get('/organizations?search=Apple') - ->assertInertia(fn ($assert) => $assert + ->assertInertia(fn (Assert $assert) => $assert ->component('Organizations/Index') ->where('filters.search', 'Apple') ->has('organizations.data', 1) - ->has('organizations.data.0', fn ($assert) => $assert + ->has('organizations.data.0', fn (Assert $assert) => $assert ->where('id', 1) ->where('name', 'Apple') ->where('phone', '647-943-4400') @@ -94,7 +95,7 @@ class OrganizationsTest extends TestCase $this->actingAs($this->user) ->get('/organizations') - ->assertInertia(fn ($assert) => $assert + ->assertInertia(fn (Assert $assert) => $assert ->component('Organizations/Index') ->has('organizations.data', 1) ->where('organizations.data.0.name', 'Apple') @@ -107,7 +108,7 @@ class OrganizationsTest extends TestCase $this->actingAs($this->user) ->get('/organizations?trashed=with') - ->assertInertia(fn ($assert) => $assert + ->assertInertia(fn (Assert $assert) => $assert ->component('Organizations/Index') ->has('organizations.data', 2) ->where('organizations.data.0.name', 'Apple')