Zend_Testの設定に成功した人はいますか?あなたの方法/アプローチは何でしたか、そしてあなたはどのようにあなたのテスト/テストスイートを実行しますか?
私はすでにPHPUnitをインストールして動作しています。今、私はいくつかの簡単なコントローラーテストを書こうとしています。Zend Frameworkのドキュメントでは、自動読み込みがセットアップされていることを前提としていますが、これはまだ行っていません。適切なファイルを自動ロードするためにどのような方法を使用しますか?私は通常のブートストラップファイルでそうしますが、たくさんのインクルードと設定パスでテストを乱雑にしたくありません。抽象コントローラーのテストケースクラスが進むべき道でしょうか?
ドキュメントで使用されているようなブートストラッププラグインはどうですか...テストをブートストラップする方法ですか、それとも別の方法で実行しますか?通常のブートストラップファイルをできるだけ多く再利用したいと思います。テストと通常の使用のためにブートストラップをどのように乾かす必要がありますか?
これまでの私のテストは次のとおりです。
<?php
class IndexControllerTest extends Zend_Test_PHPUnit_ControllerTestCase
{
public function setUp()
{
$this->bootstrap = array($this, 'appBootstrap');
parent::setUp();
}
public function appBootstrap()
{
$this->frontController->registerPlugin(new Bootstrapper('testing'));
}
public function testIndexAction()
{
$this->dispatch('/index');
$this->assertController('index');
$this->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->_setEnv($env);
if (null === $root) {
$root = realpath(dirname(__FILE__) . '/../../../');
}
$this->_root = $root;
$this->initPhpConfig();
$this->_front = Zend_Controller_Front::getInstance();
}
/**
* Route startup
*
* @return void
*/
public function routeStartup(Zend_Controller_Request_Abstract $request)
{
$this->initDb();
$this->initHelpers();
$this->initView();
$this->initPlugins();
$this->initRoutes();
$this->initControllers();
}
// definition of methods would follow...
}
私は何をすべきか?