New

Just launched: Vueblocks, a brand-new search engine for Vue packages! Explore Vueblocks →

pdmfc/laravel-nova-test-assertions

Laravel Nova testing helpers
1,876 1
Install
composer require pdmfc/laravel-nova-test-assertions
Latest Version:v0.4.0
PHP:>=7.1.0
Laravel:7 · 8
License:MIT
Last Updated:Jun 1, 2021
Links: GitHub  ·  Packagist
Maintainer: pdmfc

Laravel Nova Test Assertions

A collection of test assertions and helpers to assist you on testing Laravel Nova applications.

Packagist Downloads Packagist Version Packagist License


Installation

composer require pdmfc/laravel-nova-test-assertions --dev

Add the NovaTestAssertions trait to your tests or to the TestCase:

use Pdmfc\NovaTestAssertions\Traits\NovaTestAssertions;

class ExampleTest extends TestCase
{
    use NovaTestAssertions;
}

Test Example

class AssertionsTest extends TestCase
{
    /** @test */
    public function detail_view_has_id_field()
    {
        $this->actingAs($user = factory(User::class)->create());

        $response = $this->resourceDetail(UserResource::class, $user->id);

        $response->assertContainsField(ID::class);
    }

    /** @test */
    public function asserts_total_resources_available_on_index_view(): void
    {
        factory(User::class, 5)->create();

        $actual = $this->resourceCount(UserResource::class);

        $this->assertEquals(6, $actual);
    }

    /** @test */
    public function asserts_run_nova_action(): void
    {
        $user = factory(User::class)->create(['name' => 'Bar']);

        $this->runAction(FooAction::class, UserResource::class, $user->id);

        $this->assertEquals('Foo', $user->fresh()->name);
    }
}

Related Packages

league/factory-muffin

The goal of this package is to enable the rapid creation of objects for the purp...

15,906,405 533
laravel/browser-kit-testing

Provides backwards compatibility for BrowserKit testing in the latest Laravel re...

10,656,994 515
epartment/nova-dependency-container

A Laravel Nova field container allowing to depend on other fields values

4,703,233 378
eminiarts/nova-tabs

Laravel Nova - Tabs.

4,610,439 464

Version History

Version Released PHP Laravel License
v0.4.0 >=7.1.0 ^7.0|^8.0 MIT
v0.3.0 >=7.1.0 ^7.0 MIT
v0.2.0 >=7.1.0 MIT
v0.1.2 >=7.1.0 MIT
v0.1.1 >=7.1.0 MIT
Pre-releases (1)
Version Released PHP License
v0.0.1-alpha >=7.1.0 MIT