Inspired by Euromark's article
(http://www.dereuromark.de/2010/08/17/development-vs-productive-setup/),
I managed to achieve this functionality in my WebTestsWithFixtures
library. So if anyone needs more inspiration, look at the file
database_config_for_web_tests_with_fixtures.php in this library, maybe
it's of use to someone. In my case, the database connection is
established depending on whether a special header is sent by the
browser or not. This way, whenever this special header is sent,
CakePHP connects to the test database (because only web tests send
this header), and elseway it connects to the "normal" database.

I've written more about the library in my blog:

- Why web tests using the development database are a bad thing:
http://josh.ch/wordpress/?p=8
- Finally: use fixtures with your CakePHP web tests!:
http://josh.ch/wordpress/?p=71

I hope somebody else will find this useful. :-) Please leave a message
if you try it... I'm happy to optimize it further.

On Mon, Oct 18, 2010 at 9:43 AM, Joshua Muheim <psybea...@gmail.com> wrote:
> Thanks, guys! I will take a look at these links.
>
> On Fri, Oct 15, 2010 at 1:28 PM, euromark <dereurom...@googlemail.com> wrote:
>> this is nothing compared to not using lazyloading on models
>> like 0.0000001% :)
>> so I wouldn't bother
>>
>> i am sure it can be slightly optimized (caching?), though.
>>
>>
>> On 15 Okt., 13:02, Jeremy Burns | Class Outfit
>> <jeremybu...@classoutfit.com> wrote:
>>> I have thought of doing something like before, but I can't help thinking 
>>> that adding in a 'check which environment this is and change some settings' 
>>> process is a tiny yet present overhead in the production instance. Maybe 
>>> I'm just a coding skin flint ;-)
>>>
>>> Jeremy Burns
>>> Class Outfit
>>>
>>> jeremybu...@classoutfit.comhttp://www.classoutfit.com
>>>
>>> On 15 Oct 2010, at 11:58, euromark wrote:
>>>
>>>
>>>
>>> > you may also setup something like this
>>> >http://www.dereuromark.de/2010/08/17/development-vs-productive-setup/
>>> > it will automatically switch to the setting of the current environment
>>>
>>> > On 15 Okt., 11:19, Jeremy Burns | Class Outfit
>>> > <jeremybu...@classoutfit.com> wrote:
>>> >> From the 1.3 
>>> >> guide:http://book.cakephp.org/view/922/Database-Configuration
>>>
>>> >> Jeremy Burns
>>> >> Class Outfit
>>>
>>> >> jeremybu...@classoutfit.comhttp://www.classoutfit.com
>>>
>>> >> On 15 Oct 2010, at 10:04, MissYeh wrote:
>>>
>>> >>> You can do that by setting the dbconfig in a specific model that needs
>>> >>> another db using the var $useDbConfig
>>>
>>> >>> See for more infohttp://book.cakephp.org/view/310/Configuration
>>>
>>> >>> Or here is an article about changing database configuration on the
>>> >>> fly:
>>> >>>http://insanityville.com/2010/04/how-to-switch-between-databases-in-c...
>>>
>>> >>> Hope this helps!
>>>
>>> >>> Kana
>>>
>>> >>> On Oct 15, 9:49 am, psybear83 <psybea...@gmail.com> wrote:
>>> >>>> Hi everybody
>>>
>>> >>>> Is there an easy way to tell CakePHP to use another db setting instead
>>> >>>> of $default? Maybe something like
>>>
>>> >>>> Configure::write('please.let.me.use.this.database', 'test');
>>>
>>> >>>> Thanks a lot
>>> >>>> Josh
>>>
>>> >>> Check out the new CakePHP Questions sitehttp://cakeqs.organdhelp others 
>>> >>> with their CakePHP related questions.
>>>
>>> >>> You received this message because you are subscribed to the Google 
>>> >>> Groups "CakePHP" group.
>>> >>> To post to this group, send email to cake-php@googlegroups.com
>>> >>> To unsubscribe from this group, send email to
>>> >>> cake-php+unsubscr...@googlegroups.com For more options, visit this 
>>> >>> group athttp://groups.google.com/group/cake-php?hl=en
>>>
>>> > Check out the new CakePHP Questions sitehttp://cakeqs.organd help others 
>>> > with their CakePHP related questions.
>>>
>>> > You received this message because you are subscribed to the Google Groups 
>>> > "CakePHP" group.
>>> > To post to this group, send email to cake-php@googlegroups.com
>>> > To unsubscribe from this group, send email to
>>> > cake-php+unsubscr...@googlegroups.com For more options, visit this group 
>>> > athttp://groups.google.com/group/cake-php?hl=en
>>
>> Check out the new CakePHP Questions site http://cakeqs.org and help others 
>> with their CakePHP related questions.
>>
>> You received this message because you are subscribed to the Google Groups 
>> "CakePHP" group.
>> To post to this group, send email to cake-php@googlegroups.com
>> To unsubscribe from this group, send email to
>> cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
>> http://groups.google.com/group/cake-php?hl=en
>>
>

-- 
Our newest site for the community: CakePHP Video Tutorials 
http://tv.cakephp.org 
Check out the new CakePHP Questions site http://ask.cakephp.org and help others 
with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php

Reply via email to