-
-
Notifications
You must be signed in to change notification settings - Fork 59
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
Add Entity::setMetadata() method #181
Comments
The error means that you created instance of entity before creating instance of IModel. Create instance of IModel first. |
@JanTvrdik I know, but it's little bit tricky if you want to just create entity and verify it was passed to your mock. Don't you think? |
For now, you can mock IRepository & Metadata and call onAttach. But I will probably create a Metadata setter for better test usability. |
Setter would be nice. I get it why it's in constructor, but we might think about better solution. Perhaps setter. :-) |
Any updates here? It's really complicated to create simple unit tests.. |
Just having same issue, any news regarding this?
|
As mentioned in #181 (comment) you may set the Metadata by onAttach. Actually not sure adding setMetadata would be good. It would pollute interface and API for common usage. |
This is probably not an issue. I would like to test my components. They are very simple just for save entity let say. I've created mock of my facade and should receive a new fresh entity in save method, so this test is without access to database, no sql queries.
But I've got this message:
Nextras\Orm\InvalidStateException: MetadataStorage::get() called too early. You have to instantiate your model first.
.Here is component`s code.
Any idea how to change concept? I think my architecture isn't bad I've just wanted to know the correct solution. I can't use
EntityCreater
it's not a test it's real component.Thank you.
The text was updated successfully, but these errors were encountered: