2009年12月14日星期一

Re: [fw-mvc] Usage of PHPUnit

Hello,

If you need the Database or the Controller TestCase primarily depends
on how much abstraction your application has.

If you have quite a big
of logic going on in your controllers then you probably want to
use the controller test-case. If you have layered your app such that
all the business logic is encapsulated in a model layer, then you
only need the Database TestCase to test this.

If you separated Data-Access and Business-Logic you can even test
the logic only by using the PHPUnit_Framework_TestCase base class,
because you dont need a database.

For a complete test-strategy you will however also need to write
some tests that test the complete mvc layer in an integrated way.
you will soon see that these kind of tests are frikking slow,
so making your tests use as few layers as possible.

In any case I always bootstrap the necessary resources using
Zend_Application,
or I inject my dependencies into the model. This in turn depends on
how your application is structured (Dependency Injection wise).

quite a complex topic :-)

On the issue of an example for Zend application + DatabaseTestCase
you should open up an issue in Jira. I'll pick it up on bughunt days
this week and write some more words on it.

Tests are usally run from the command line. Its pretty easy since
PHPUnit installs its necessary binary if you install it using PEAR
(which is recommended).


On Sun, 13 Dec 2009 22:23:13 -0600, "Seth Atkins" <satkins@nortel.com>
wrote:
> I'm curious about the typical usage for the DatabaseTestCase. Since you
> don't really need a front controller or application bootstrap, is the
> simplest usage to just require_once the necessary files, such as my
> Db_Table class files? Or do you load the Zend Autoloader to make things
> a little simpler? If so does anyone have an example of a minimalist
> bootstrap for DB test cases?
>
> Also, is the typical usage just to run it from command line?
>
> I'm fairly new to using these test tools, and Google is a little sparse
> on answers.
>
> Regards,
> Seth Atkins

没有评论: