开发者

How to use zend test phpunit in zend project

I am a very new zend framework and phpunit test learner. I have a zend project, I want to use the zend-test-phpunit to test the model and controllers under the application folder. How could I test it? I notice there is a tests folder in this project, and all the tests should be done in 开发者_运维百科this folder? in this case, I have to copy all the controllers and model into this folder? who can provide me a example?

thank you for help in advance!


A good place to start is the Zend Framework documentation and PHPUnit manual: Chapter 3. Installing PHPUnit

You need to populate the phpunit.xml file with something along the lines of:

<phpunit bootstrap="./application/bootstrap.php" colors="true">
        <testsuite name="Application" >
                <directory>./library</directory>
                <directory>./application</directory>
        </testsuite>
        <filter>
                <whitelist>
                        <directory suffix=".php">../application</directory>
                        <directory suffix=".php">../library/My</directory>
                        <exclude>
                                <directory suffix=".phtml">../application/</directory>
                                <file>../application/Bootstrap.php</file>
                        </exclude>
                </whitelist>
        </filter>
    <logging>
        <log type="coverage-html" target="./log/report" charset="UTF-8"
        yui="true" highlight = "true" lowUpperBound="50" highLowerBound="80" />
        <log type="testdox" target="./log/testdox.html" />
    </logging>
</phpunit>

Then it's just to run 'phpunit' from command line when in your test folder. If you want phpunit to produce a code coverage report, then you also need to enable xdebug in your environment

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜