Skip to end of metadata
Go to start of metadata

<h1>Reasons for ZFTestManager</h1>

<ul>
<li>Ability to isolate unit test suites and unit test tests.</li>
<li>Ability to auto-generate Module's Directory and stock AllTests.php file with stock functionality for autolocating and loading tests.</li>
<li>Simplify unit test writing by reducing the learning curve and by adding Zend Framework conventions.</li>
<li>Standardized suite/test configuration.. uses native parse_ini_file().</li>
<li>Ability to add functionality to the test runner later to better report on test failure. (to be implemented later).</li>
</ul>

<h1>Installing PHPUnit on your box</h1>

<ul>
<li>Zend Framework unit tests are written for <a href="http://www.phpunit.de/">PHPUnit</a>.
<ul>
<li>New install:
<ac:macro ac:name="code"><ac:plain-text-body><![CDATA[
$ pear channel-discover pear.phpunit.de
$ pear config-set preferred_state alpha
$ pear install phpunit/PHPUnit
]]></ac:plain-text-body></ac:macro></li>
<li>Upgrading:
<ac:macro ac:name="code"><ac:plain-text-body><![CDATA[
$ pear upgrade phpunit/PHPUnit
]]></ac:plain-text-body></ac:macro></li>
<li>Upgrading from PEAR/PHPUnit2:
<ac:macro ac:name="code"><ac:plain-text-body><![CDATA[
$ pear uninstall PHPUnit2
$ pear channel-discover pear.phpunit.de
$ pear config-set preferred_state alpha
$ pear install phpunit/PHPUnit
]]></ac:plain-text-body></ac:macro></li>
</ul>
</li>
</ul>

<p>When you're having trouble installing the newest PHPUnit Version 3 and after upgrading your PEAR say that the newest PHPUnit Version 2.3.6 is already installed the following instuctions will help you</p>

<p>Look per browser at <a href="http://pear.phpunit.de/get/">http://pear.phpunit.de/get/</a> and see what's the latest release...<br />
Today for example the latest release version is <a href="http://pear.phpunit.de/get/PHPUnit-3.0.0alpha18.tar">http://pear.phpunit.de/get/PHPUnit-3.0.0alpha18.tar</a>.<br />
Now do the following</p>
<ac:macro ac:name="code"><ac:plain-text-body><![CDATA[
$ pear uninstall phpunit/PHPUnit
$ pear channel-discover pear.phpunit.de
$ pear install phpunit/PHPUnit-3.0.0alpha18
]]></ac:plain-text-body></ac:macro>
<p>and you will have the latest PHPUnit Version installed.</p>

<p>Check your version by changing your working directory to PHP and run phpunit on command line.<br />
The actual version and help should show up.</p>

<h1>Getting the new unit tests (only until this is in production)</h1>

<ul>
<li> pull down from subversion repository</li>
<li><a href="http://www.ralphschindler.com/subversion/Zend_UnitTests/">http://www.ralphschindler.com/subversion/Zend_UnitTests/</a></li>
</ul>

<h1>Using ZFTestManager.php / ZFTestManager</h1>

<ul>
<li>Help
<ac:macro ac:name="code"><ac:plain-text-body><![CDATA[
$ php ZFTestManager.php --help
Zend Framework - Unit Test Runner and Manager Script
built on PHPUnit 3.0.0alpha19 by Sebastian Bergmann.

Usage:
ZFTestManager [PLAY:options] - if installed in a bin with path to php.
php ZFTestManager.php [PLAY:options] - from unit test directory.

  • With no options, ZFTestManager will run all found tests.

Options:
--list-suites Prints a hierarchical list of suites for testing.
--new-suite <name> Create a new suite at the <name> location.
--suite-filter <filter> Where filter is:
Zend_Suite - run this suite and its sub-suites.
@Zend_Suite - run only this suite.
Zend_Suite::MyTestCase - run only this TestCase in this suite.
--test-filter <filter> Where filter is a regex of the test cases you wish to run.
--help Prints this usage information.
--version Prints the version and exits.

-d key[PLAY:=value] Sets a php.ini value.
]]></ac:plain-text-body></ac:macro></li>
</ul>

<ul>
<li>Adding a new Suite
<ac:macro ac:name="code"><ac:plain-text-body><![CDATA[
$ php ZFTestManager.php --new-suite Zend_View
Zend Framework - Unit Testrunner and Manager Script
built on PHPUnit 3.0.0alpha19 by Sebastian Bergmann.

Attempting to create a suite shell named: Zend_View

Creating directory Zend/View in suite..
Writing AllTests.php file..
Complete.
]]></ac:plain-text-body></ac:macro></li>
</ul>

<ul>
<li>Listing Suites
<ac:macro ac:name="code"><ac:plain-text-body><![CDATA[
$ php ZFTestManager.php --list-suites
Zend Framework - Unit Test Runner and Manager Script
built on PHPUnit 3.0.0alpha19 by Sebastian Bergmann.

Zend
Zend_Cache
Zend_Db_Adapter_Pdo
Zend_Feed
Zend_Config
Zend_Controller
Zend_Http
Zend_Mime
Zend_Uri
Zend_View
Zend_Mail
Zend_Filter
Zend_Json
]]></ac:plain-text-body></ac:macro></li>
</ul>

<ul>
<li>Running All Suites
<ac:macro ac:name="code"><ac:plain-text-body><![CDATA[
$ php ZFTestManager.php
Zend Framework - Unit Test Runner and Manager Script
built on PHPUnit 3.0.0alpha19 by Sebastian Bergmann.

.........................................
.........................................
.........................................
.........................................
.........................................
...........

Time: 00:00

OK (216 tests)
]]></ac:plain-text-body></ac:macro></li>
</ul>

<ul>
<li>Running Isolated Suite
<ul>
<li>Running suite and all branches.
<ac:macro ac:name="code"><ac:plain-text-body><![CDATA[
$ php ZFTestManager.php --suite-filter Zend_View
Zend Framework - Unit Test Runner and Manager Script
built on PHPUnit 3.0.0alpha19 by Sebastian Bergmann.

............

Time: 00:00

OK (12 tests)
]]></ac:plain-text-body></ac:macro></li>
<li>Running Single Suite Node, no branches
<ac:macro ac:name="code"><ac:plain-text-body><![CDATA[
$ php ZFTestManager.php --suite-filter @Zend
Zend Framework - Unit Test Runner and Manager Script
built on PHPUnit 3.0.0alpha19 by Sebastian Bergmann.

...........

Time: 00:00

OK (11 tests)
]]></ac:plain-text-body></ac:macro></li>
<li>Running Single Suite Node, Single TestCase
<ac:macro ac:name="code"><ac:plain-text-body><![CDATA[
$ php ZFTestManager.php --suite-filter Zend_Cache#CoreTest
Zend Framework - Unit Test Runner and Manager Script
built on PHPUnit 3.0.0alpha19 by Sebastian Bergmann.

.....................................

Time: 00:00

OK (37 tests)
]]></ac:plain-text-body></ac:macro></li>
<li>Running Single Suite Node, Single TestCase, Single Test
<ac:macro ac:name="code"><ac:plain-text-body><![CDATA[
$ php ZFTestManager.php --suite-filter Zend_Cache#CoreTest --test-filter testConstructorBadOption
Zend Framework - Unit Test Runner and Manager Script
built on PHPUnit 3.0.0alpha19 by Sebastian Bergmann.

.

Time: 00:00

OK (1 test)
]]></ac:plain-text-body></ac:macro></li>
</ul>
</li>
</ul>

<h1>Writing Tests</h1>

<ul>
<li>See also: <a href="http://framework.zend.com/wiki/x/cQo">Testing Standards</a></li>
<li>see notes inside generated AllTests.php file inside your Suite directory.</li>
</ul>

<h1>ZFTestManager Configuration / TestConfiguration.ini</h1>
<h2>Global Options</h2>
<ac:macro ac:name="code"><ac:plain-text-body><![CDATA[
TestConfiguration.ini file:

[ZFTestManager]

library = "../path/to/library"
library2 = "../path/to/library2"

generate_report = true
generate_report_directory = "../path/to/writable/directory/"

]]></ac:plain-text-body></ac:macro>

Labels:
None
Enter labels to add to this page:
Please wait 
Looking for a label? Just start typing.
  1. Dec 31, 2007

    <p>Since 3.2.x PHPUnit supports the --filter-argument which is used to filter tests. I'm not sure whether it is possible to filter complete suites or test cases but as I know Sebastian Bergmann he would be very willing to add something like this.</p>

  2. Mar 21, 2008

    <p>Please take a look on critic article <a class="external-link" href="http://techblog.tilllate.com/2007/06/07/so-what-does-zftestmanager-do/">http://techblog.tilllate.com/2007/06/07/so-what-does-zftestmanager-do/</a> it makes important point.</p>