CakePHP override 'ds' option in ClassRegistry::init when test mode is true.
This change keep user-defined option.
Test case added.
Using user-defined datasource in ClassRegistry when testing
Merge branch 'master' of git://github.com/cakephp/cakephp
Should be if (
Also you can just use empty($settings['ds']) here. Anyone who makes a datasource with the name of '0' deserves a talking to.
Fix coding standard
Updated, but maybe this is not a good ideia.
CakeFixtureManager also override user-defined datasource, so, initialized data/structure can be placed at a different database/schema. What do you think?
I don't really understand why you'd be passing the 'ds' into ClassRegistry::init(). It seems like something that should be declared on the class not dynamically changed at runtime.
In one application, I've default DB connection using PostgreSQL and another using MongoDB.
When I try run tests of Models, CakePHP load connection default 'test', so, I'm forcing initilize Model with specific connection.
I can't declare connection directly at Model because it's a reutilized plugin.
Since 2.1 we support a magic datasource change by using the test_ prefix. For instance if you use a datasource named mongo in a model then the model will be configured to use test_mongo in your test case. Would that work for you?
I did used that option, but are two different scenario, the first it's above, other is when my default connection uses MongoDB. In that case I would like to use it as connection.
So, in my tests cases, I try dynamically check if default source is Mongo, otherwise, I try use another (named test_mongo, like you suggest).
But maybe is better requiring a connection named 'mongo' and 'test_mongo' as plugin dependency.
Well, I thought about "convention over configuration" and is better remove that PR.
This would add edge cases to test and unnecessary complexity into core.