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
"cake bake fixture all" could not find correct table name #5377
Comments
Fixtures should be independent of the models imo. I think the documentation is wrong and should probably be updated as well. The issue with only baking fixtures for models, is that when baking a model + fixture, the model won't exist yet |
Hi markstory, Here I have a use case: In an existing project there are no any unit test cases before, and there are many tables. Some table name not follow CakePHP conventions and not using plural. And some are just exists in database and not used by any Model. Those using tables are well defined in model .php file. In this case, when using "bake fixture all", it will fail because of table name is incorrect. That's because CakePHP will bake fixtures for all tables and read from "Inflector:: tableize" name This situation let me confused, is this the intension that "bake fixture all" intent to help? So, what do you think on automatically creating fixtures for testing model? And how to make it more flexible for the existing project? |
|
I also hope things can be that easy, but the reality is "cake bake all" will stop when it tries to create fixture for the table name which not follow the convention :( |
Do you have a table definition that bake has issues with? I can update bake to skip/work through the problems. |
Hi Mark, I think we just need to create a table in database with name not in plural, for example: "user" |
Thanks, I'll try reproducing 😄 |
When a table is missing print a warning to stderr but don't exit. This allows people to use `bake fixture all` with non-conventional tables. Refs #5377
Closing as #5422 is open now. |
In my use case, if you want to "bake fixture all" at once, if there are many tables in your database which are not follow the table naming convention, the bake fixture all will fail, because of the error "Could not find your selected table "
I think for all() function in FixtureTask, we should only bake fixtures with model file exists? and if the $useTable variable defined in model file, then we should bake fixture from the defined table name.
By doing this, we can easily create model fixtures for existing project more easily.
How do you think?
The text was updated successfully, but these errors were encountered: