Skip to content

add support for faking snowflake creation #4

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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

skylerkatz
Copy link

During testing, it may be useful to "fake" the value that is returned by the Snowflake::make and Sonyflake::make method.

This PR adds an identical API that Laravel uses for their Str::uuid(), Str::ulid(), and Str::random() methods for allowing fakes during testing.

I ran into a use case where I am using a snowflake in a filename, and in my tests I want to assert the filename is something deterministic, but right now, I am unable to do that.

During testing, it may be useful to "fake" the value that is returned by the `Snowflake::make` and `Sonyflake::make` method.

Signed-off-by: Skyler Katz <[email protected]>
@inxilpro
Copy link
Contributor

Wouldn't it make sense to introduce an actual fake for the MakesBits/etc interfaces and put all the testing features on there? That would mean that basically none of the existing code would need to be modified…

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants