News Feed
Sections




News Archive
Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Debuggable Blog:
Testing Models in CakePHP - Now let's get rid of the unnecessary ModelTest classes!
July 31, 2008 @ 07:51:38

On the Debuggable blog today Tim Koschutzki looks at another testing topics for the CakePHP framework - a cleaner way for testing models.

Up until now there was always a need to create a so-called test model that extends your model-under-test in order to overwrite its $useDbConfig setting to be 'test_suite'. By that you ensured that your models run with the test_suite datasource when the tests are run. [...] Nate proposed ClassRegistry::config(), which allows you to tell the ClassRegistry class which datasource it shall use when ClassRegistry::init() is used the next time (and thereby a model is instantiated).

He includes an example of the new functionality - a test case ensuring that three articles are there and are marked as published. The registry makes it easier to automatically create the ArticleTest instance inside the test case rather than having to manually declare and define it.

0 comments voice your opinion now!
test case cakephp framework registry modeltest class


blog comments powered by Disqus

Similar Posts

Federico Cargnelutti's Blog: Testing Zend Framework Action Controllers With Mocks

Zend Developer Zone: ...Bake Me a Cake as Fast as You Can

Gonzalo Ayuso's Blog: Runtime Classes. A experiment with PHP and Object Oriented Programming

Bradley Holt's Blog: Testing PHP 5.4

Refulz.com: CakePHP evolves to 2.0


Community Events

Don't see your event here?
Let us know!


introduction api community unittest laravel5 version release threedevsandamaybe interview laravel extension framework voicesoftheelephpant podcast library series language security opinion symfony

All content copyright, 2015 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework