Note that there are some explanatory texts on larger screens.

plurals
  1. POZend Framework: Getting started with Zend_Test
    text
    copied!<p>Has anyone had any success setting up Zend_Test? What was your method/approach and how do you run your tests/test suites?</p> <p>I already have PHPUnit installed and working. Now I'm trying to write some simple controller tests. The Zend Framework documentation assumes that autoloading is setup, which I haven't done. What method do <strong>you</strong> use to autoload the appropriate files? I do so in my normal bootstrap file, but I don't want to clutter up my Test with a bunch of includes and setting up paths. Would an abstract controller test case class be the way to go?</p> <p>What about the bootstrap plugin like the documentation uses...is that how you bootstrap your tests, or do you like to do it a different way? I would like to re-use as much of the regular bootstrap file as I can. How should I DRY up my bootstrap for testing and normal use?</p> <p>Here's my test so far:</p> <pre><code>&lt;?php class IndexControllerTest extends Zend_Test_PHPUnit_ControllerTestCase { public function setUp() { $this-&gt;bootstrap = array($this, 'appBootstrap'); parent::setUp(); } public function appBootstrap() { $this-&gt;frontController-&gt;registerPlugin(new Bootstrapper('testing')); } public function testIndexAction() { $this-&gt;dispatch('/index'); $this-&gt;assertController('index'); $this-&gt;assertAction('index'); } } //straight from the documentation class Bootstrapper extends Zend_Controller_Plugin_Abstract { /** * @var Zend_Config */ protected static $_config; /** * @var string Current environment */ protected $_env; /** * @var Zend_Controller_Front */ protected $_front; /** * @var string Path to application root */ protected $_root; /** * Constructor * * Initialize environment, root path, and configuration. * * @param string $env * @param string|null $root * @return void */ public function __construct($env, $root = null) { $this-&gt;_setEnv($env); if (null === $root) { $root = realpath(dirname(__FILE__) . '/../../../'); } $this-&gt;_root = $root; $this-&gt;initPhpConfig(); $this-&gt;_front = Zend_Controller_Front::getInstance(); } /** * Route startup * * @return void */ public function routeStartup(Zend_Controller_Request_Abstract $request) { $this-&gt;initDb(); $this-&gt;initHelpers(); $this-&gt;initView(); $this-&gt;initPlugins(); $this-&gt;initRoutes(); $this-&gt;initControllers(); } // definition of methods would follow... } </code></pre> <p>What should I do?</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