Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using Event:fake() in tests prevents UUID creation #1

Open
mdcass opened this issue May 3, 2021 · 3 comments
Open

Using Event:fake() in tests prevents UUID creation #1

mdcass opened this issue May 3, 2021 · 3 comments
Labels
good first issue Good for newcomers help wanted Extra attention is needed

Comments

@mdcass
Copy link

mdcass commented May 3, 2021

In a test, you'd expect the following to work (L8)

Event::fake(); $user = User::factory()->create([ 'email_verified_at' => null, ]);

However fails due to the required event not firing. Hacky solution is to implement this in tests which would prevent your package being added to a more established project due to the requirement of refactoring tests (stops you package being as "drop in" as you'd like).

Looks like using dedicated Event classes may be a solution (altering the definition of the vent on the model) but I didn't have time to validate. At the very least this should be mentioned in the documentation.

@salmanzafar949
Copy link
Owner

Hi @mdcass can you open a pr and work on this
i'm busy now a days so cant work on this.

@salmanzafar949 salmanzafar949 added good first issue Good for newcomers help wanted Extra attention is needed labels May 31, 2021
@sloumat
Copy link

sloumat commented Feb 9, 2023

I have the same issue with fake event and UUID
Event::fake();

    Passport::actingAs(
        User::factory()->create(),
    );

Return
SQLSTATE[23000]: Integrity constraint violation: 19 NOT NULL constraint failed: users.id

@plugowski
Copy link

Any solutions? I got the same today :(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

4 participants