joshgaber / NovaUnit

Unit testing suite for Laravel Nova, built to extend PHPUnit
https://joshgaber.github.io/NovaUnit
MIT License
67 stars 23 forks source link

Asserting Action message contents fails #60

Open Jigsaw5279 opened 1 year ago

Jigsaw5279 commented 1 year ago

When asserting that an action responds with a specific message, the test case fails with the following error

Failed asserting that Laravel\Nova\Actions\ActionResponse Object #1410 (
    'danger' => null
    'deleted' => null
    'download' => null
    'message' => 'Registrierung bestätigt'
    'name' => null
    'openInNewTab' => null
    'redirect' => null
    'visit' => null
    'modal' => null
    'data' => Array &0 ()
) is of type array and matches the "message" Action response.
/var/www/html/vendor/joshgaber/novaunit/src/Actions/MockActionResponse.php:33
/var/www/html/vendor/joshgaber/novaunit/src/Actions/MockActionResponse.php:47
/var/www/html/tests/Feature/QuickConfirmActionTest.php:154
/var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Testing/TestCase.php:174

Here's the excerpt from the test case

self::novaAction(QuickConfirmAction::class)
            ->handle([], $registration)
            ->assertMessage('Registrierung bestätigt');

Version:

name     : joshgaber/novaunit
descrip. : Unit testing suite for Laravel Nova, built to extend PHPUnit
keywords : joshgaber, laravel, nova, novaunit
versions : * 3.1.0
greatwitenorth commented 1 year ago

I'm having the same issue. As a workaround for now I'm using:

$response = $action->handle([], [$model]);
$response->assertMessageContains('my message here');
Jigsaw5279 commented 1 year ago

I think PR #59 is related to this