Fixing a bug that appears when trying to bake plugin models#303
Merged
markstory merged 2 commits intocakephp:masterfrom Jan 31, 2017
burzum:bug/getTableObject
Merged
Fixing a bug that appears when trying to bake plugin models#303markstory merged 2 commits intocakephp:masterfrom burzum:bug/getTableObject
markstory merged 2 commits intocakephp:masterfrom
burzum:bug/getTableObject
Conversation
This fixes a problem that happens when you already have an existing model in your app but want to bake one of the same name in your plugin. I've used as well the --table option. My main app is using an users table, now for a plugin I wanted to bake a Users model that is using the wp_users table from another DB. This was not possible without this change.
Codecov Report@@ Coverage Diff @@
## master #303 +/- ##
==========================================
+ Coverage 95.76% 95.77% +<.01%
==========================================
Files 23 23
Lines 1866 1869 +3
==========================================
+ Hits 1787 1790 +3
Misses 79 79
Continue to review full report at Codecov.
|
markstory
reviewed
Jan 30, 2017
| { | ||
| $plugin = $this->param('plugin'); | ||
| if (!empty($plugin)) { | ||
| $className = $plugin . '.' . $className; |
Member
There was a problem hiding this comment.
Any way we could get a test for this?
Author
There was a problem hiding this comment.
If you tell me how? All I know is that testing console stuff is pain in the ass. :(
Member
There was a problem hiding this comment.
We could unit test the getTableObject() here. Mock the rest away.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This fixes a problem that happens when you already have an existing model of the same name in your app but want to bake one of the same name in your plugin. I've used as well the --table option. My main app is using an users table, now for a plugin I wanted to bake a Users model that is using the wp_users table from another DB. This was not possible without this change.
Tried this:
Resulting in: