Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Here's what I did to get it to work:</p> <p>First, we need to resolve the autoloading issue. We'll do this by creating a file that all the tests will include, and put it in the tests directory. Note: I pretty much copied all of this from my /public/index.php.</p> <pre><code># /tests/loader.php &lt;?php define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/../application/')); set_include_path( APPLICATION_PATH . '/../library' . PATH_SEPARATOR . APPLICATION_PATH . '/models' . PATH_SEPARATOR . APPLICATION_PATH . '/forms' . PATH_SEPARATOR . get_include_path() ); require_once "Zend/Loader.php"; Zend_Loader::registerAutoload(); </code></pre> <p>Second, we need to include this file in our test. Our test file is in /tests/application/controllers/ . I'm not going to use my bootstrap as a plugin since my bootstrap file works the same way as the <a href="http://framework.zend.com/docs/quickstart" rel="nofollow noreferrer" title="QuickStart tutorial">QuickStart tutorial</a>. I'll just link to it by setting the location as the public $bootstrap. When <code>Zend_Test_PHPUnit_ControllerTestCase</code> constructs, it will look for the bootstrap file that we set here.</p> <pre><code>&lt;?php require_once '../../loader.php'; class IndexControllerTest extends Zend_Test_PHPUnit_ControllerTestCase { public $bootstrap = '../../../application/bootstrap.php'; public function testIndexAction() { $this-&gt;dispatch('/index'); $this-&gt;assertController('index'); $this-&gt;assertAction('index'); } } </code></pre> <p>And that's it! If my bootstrap file was already a plugin, this might be a little more complicated, but since it's not, it's super easy.</p>
 

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