Adds type hints in tests

This commit is contained in:
Matias Ibargoyen 2021-07-18 14:37:44 +01:00
parent 99b88e8943
commit 728dec946c
2 changed files with 19 additions and 17 deletions

View File

@ -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')

View File

@ -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')