私はいくつかの会議でこのテーマについて講演しましたが、Zend Webサイトにはウェビナーもあります(以下のリンクを参照)。
セットアップスクリプトを見ると、そこには多くの混乱があり、アプリケーションに機能を追加すると、保守が困難になります。
私のTestHelperクラスには、次のものしか含まれていません。
<?php
/*
* Example test helper script taken from the blog article of Matthew Weier
* O'Phinney on September 11, 2008
*
* {@link http://weierophinney.net/matthew/archives/190-Setting-up-your-Zend_Test-test-suites.html}
*/
/*
* Start output buffering
*/
//ob_start();
/*
* Set error reporting to the level to which code must comply.
*/
error_reporting( E_ALL | E_STRICT );
/*
* Set default timezone
*/
date_default_timezone_set('Europe/Brussels');
/*
* Testing environment
*/
if (!defined('APPLICATION_ENV'))
define('APPLICATION_ENV', 'testing');
/*
* Determine the root, library, tests, and models directories
*/
$root = realpath(dirname(__FILE__) . '/../');
$library = $root . '/library';
$tests = $root . '/tests';
$models = $root . '/application/models';
$controllers = $root . '/application/controllers';
/*
* Set up application and test path constant for easy access helper classes
*/
if (!defined('APPLICATION_PATH'))
define('APPLICATION_PATH', $root . '/application');
define('TEST_PATH', $tests);
/*
* Prepend the library/, tests/, and models/ directories to the
* include_path. This allows the tests to run out of the box.
*/
$localFrameworkPaths = array (
'/usr/local/zend/share/ZendFramework/library',
'/opt/ZendFramework',
);
$include_path = get_include_path();
foreach ($localFrameworkPaths as $zfPath) {
$include_path = str_replace($zfPath . PATH_SEPARATOR, '', $include_path);
}
$path = array(
APPLICATION_PATH,
$models,
$library,
$tests,
$include_path,
);
set_include_path(implode(PATH_SEPARATOR, $path));
/**
* Register autoloader
*/
require_once 'Zend/Loader.php';
Zend_Loader::registerAutoload();
/**
* Store application root in registry
*/
Zend_Registry::set('testRoot', $root);
Zend_Registry::set('testBootstrap', $root . '/application/bootstrap.php');
/**
* Say to the sessions we use unit testing here
*/
Zend_Session::$_unitTestEnabled = true;
/*
* Unset global variables that are no longer needed.
*/
unset($root, $library, $models, $controllers, $tests, $path);
これは、彼のブログで提供されているMWOPの元の設定に似ています(クラスの上部にあるリンクを参照してください)。
これで、モジュールを手動で追加したり、アプリケーションアーキテクチャの変更を追跡したりする必要はありません。これは、アプリケーション独自のブートストラップを使用するためです。
詳細については、次のリンクを確認してください。
それがあなたのケースでもうまくいったかどうか教えてください。