pdmfc / laravel-nova-test-assertions-php-8-support
Laravel Nova testing helpers
Installs: 2 058
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
Requires
- php: ^8.1
- laravel/framework: ^8.0|^9.0
- laravel/nova: ^3.32 | ^4.0
Requires (Dev)
- orchestra/testbench: ^5.0|^6.0
- phpunit/phpunit: ^9.0
This package is not auto-updated.
Last update: 2024-10-28 20:34:36 UTC
README
A collection of test assertions and helpers to assist you on testing Laravel Nova applications.
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); } }