This release merges @claudiodekker's excellent Inertia Laravel Testing Helpers package into this adapter (#220).
use Inertia\Testing\Assert;
class PodcastsControllerTest extends TestCase
{
public function test_can_view_podcast()
{
$this->get('/podcasts/41')
->assertInertia(fn (Assert $page) => $page
->component('Podcasts/Show')
->has('podcast', fn (Assert $page) => $page
->where('id', $podcast->id)
->where('subject', 'The Laravel Podcast')
->where('description', 'The Laravel Podcast brings you Laravel and PHP development news and discussion.')
->has('seasons', 4)
->has('seasons.4.episodes', 21)
->has('host', fn (Assert $page) => $page
->where('id', 1)
->where('name', 'Matt Stauffer')
)
->has('subscribers', 7, fn (Assert $page) => $page
->where('id', 2)
->where('name', 'Claudio Dekker')
->where('platform', 'Apple Podcasts')
->etc()
->missing('email')
->missing('password')
)
)
);
}
}
Until we're able to add the documentation for these testing helpers to this website, please see the old docs here.
To migrate from inertia-laravel-testing
to the inertia-laravel
adapter, follow these steps:
composer.json
file, remove the claudiodekker/inertia-laravel-testing
dependency.composer.json
file, update the inertiajs/inertia-laravel
version to ^0.4.0
.composer update
.use ClaudioDekker\Inertia\Assert;
with use Inertia\Testing\Assert;
in your project.That's it. All your tests should still be passing.