Skip to content

Can't use Str::createUuidsUsing() with Notification::fake() #57328

@Livijn

Description

@Livijn

I use this to get a deterministic value in my test but I get an exception: Str::createUuidsUsing(fn () => 'some-uuid');

Error: Call to a member function toString() on string in /Users/fredrik/Documents/code/getapet-backend/vendor/laravel/framework/src/Illuminate/Support/Testing/Fakes/NotificationFake.php:317

This is caused by using ->toString(). What we could instead do is to use $notification->id = (string) Str::uuid();.

$notification->id = Str::uuid()->toString();

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions