Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>To setup the unit tests I created a configuration file for phpunit (phpunit.xml) and a TestHelper.php in the test directory. The configuration basically says to phpunit which unit test needs to be executed and wich folders and files needs to be skipped in the coverage. In my config it just are all the unit test files in the application and library folder that are going to be executed.</p> <p>The Testhelper needs to be extended by all your unit tests.</p> <p><strong>phpunit.xml</strong></p> <pre><code>&lt;phpunit bootstrap="./TestHelper.php" colors="true"&gt; &lt;testsuite name="Your Application"&gt; &lt;directory&gt;./application&lt;/directory&gt; &lt;directory&gt;./library&lt;/directory&gt; &lt;/testsuite&gt; &lt;filter&gt; &lt;whitelist&gt; &lt;directory suffix=".php"&gt;../application/&lt;/directory&gt; &lt;directory suffix=".php"&gt;../library/App/&lt;/directory&gt; &lt;exclude&gt; &lt;directory suffix=".phtml"&gt;../application/&lt;/directory&gt; &lt;directory suffix=".php"&gt;../application/database&lt;/directory&gt; &lt;directory suffix=".php"&gt;../application/models/Entities&lt;/directory&gt; &lt;directory suffix=".php"&gt;../application/models/mapping&lt;/directory&gt; &lt;directory suffix=".php"&gt;../application/models/proxy&lt;/directory&gt; &lt;directory suffix=".php"&gt;../application/views&lt;/directory&gt; &lt;file&gt;../application/Bootstrap.php&lt;/file&gt; &lt;file&gt;../application/modules/admin/controllers/ErrorController.php&lt;/file&gt; &lt;/exclude&gt; &lt;/whitelist&gt; &lt;/filter&gt; &lt;logging&gt; &lt;log type="coverage-html" target="./log/report" title="PrintConcept" charset="UTF-8" yui="true" highlight="true" lowUpperBound="35" highLowerBound="70" /&gt; &lt;log type="testdox" target="./log/testdox.html" /&gt; &lt;/logging&gt; &lt;/phpunit&gt; </code></pre> <p><strong>TestHelper.php</strong></p> <pre><code>&lt;?php error_reporting(E_ALL | E_STRICT); // Define path to application directory defined('APPLICATION_PATH') || define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/../application')); // Define testing application environment define('APPLICATION_ENV', 'testing'); // Ensure library/ is on include_path set_include_path(implode(PATH_SEPARATOR, array( realpath(APPLICATION_PATH . '/../library'), get_include_path(), ))); /** * Zend_Application */ require_once 'Zend/Application.php'; /** * Base Controller Test Class * * All controller test should extend this */ require_once 'Zend/Test/PHPUnit/ControllerTestCase.php'; abstract class BaseControllerTestCase extends Zend_Test_PHPUnit_ControllerTestCase { public function setUp() { $application = new Zend_Application(APPLICATION_ENV, APPLICATION_PATH . '/configs/application.ini'); $this-&gt;bootstrap = array($application-&gt;getBootstrap(), 'bootstrap'); Zend_Session::$_unitTestEnabled = true; parent::setUp(); } public function tearDown() { /* Tear Down Routine */ } } </code></pre> <p>This only covers the initial setup for ZF and PHPunit</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload