Source for file Ethna_UnitTestManager.php
Documentation is available at Ethna_UnitTestManager.php
* Ethna_UnitTestManager.php
* @author Takuya Ookubo <sfio@sakura.ai.to>
* @license http://www.opensource.org/licenses/bsd-license.php The BSD License
require_once('simpletest/unit_tester.php');
require_once('Ethna_UnitTestCase.php');
require_once('Ethna_UnitTestReporter.php');
* @author Takuya Ookubo <sfio@sakura.ai.to>
/** @var object Ethna_Controller コントローラオブジェクト */
/** @var array 一般テストケース定義 */
* Ethna_UnitTestManagerのコンストラクタ
* @param object Ethna_Backend &$backend Ethna_Backendオブジェクト
* action, view 以外のテストケースの一覧を取得する
* @param テストケースが含まれているディレクトリ名
function _getTestCaseList($test_dir =
NULL)
// WARNING が出る可能性があるのをケアする
$child_dir_list =
array();
while (($file =
readdir($dh)) !==
false) {
if ($file ==
"." ||
$file ==
"..") {
$file =
$test_dir .
$file;
$child_dir_list[] =
$file;
foreach ($child_dir_list as $child_dir) {
$tmp =
$this->_getTestCaseList($child_dir .
"/");
return $im->getActionList();
* @param string $class_name ビュークラス名
if (preg_match("/$prefix(.*)/", $class_name, $match) ==
0) {
* 指定されたクラス名を継承しているかどうかを返す
* @param string $class_name チェック対象のクラス名
* @param string $parent_name 親クラス名
* @return bool true:継承している false:いない
function _isSubclassOf($class_name, $parent_name)
* @param string $script ファイル名
* @return array ビュークラス定義一覧
function __analyzeViewScript($script)
$fp =
fopen($script, 'r');
while (feof($fp) ==
false) {
$source .=
fgets($fp, 8192);
for ($i =
0; $i <
count($token_list); $i++
) {
$token =
$token_list[$i];
if ($token[0] ==
T_CLASS) {
$class_name =
$token_list[$i][1]; // should be T_STRING
if ($this->_isSubclassOf($class_name, 'Ethna_ViewClass')) {
$class_list[$view_name] =
array(
'template_file' =>
$this->ctl->_getForwardPath($view_name),
'view_class' =>
$class_name,
if (count($class_list) ==
0) {
* @param string $action_dir 解析対象のディレクトリ
* @return array ビュークラス定義一覧
function __analyzeViewList($view_dir =
null)
while (($file =
readdir($dh)) !==
false) {
$path =
"$view_dir/$file";
if ($file !=
'.' &&
$file !=
'..' &&
is_dir($path)) {
$tmp =
$this->__analyzeViewList($path);
if (substr($file, -
$ext_len, $ext_len) !=
$ext) {
$class_list =
$this->__analyzeViewScript($path);
if (is_null($class_list) ==
false) {
//$view_class_list = array_keys($im->getForwardList());
$forward_list =
$im->_analyzeForwardList();
$view_list =
$this->__analyzeViewList();
$manifest_forward_list =
$im->_getForwardList_Manifest($forward_list);
$implicit_forward_list =
$im->_getForwardList_Implicit($forward_list, $manifest_forward_list);
$r =
array_merge($view_list, $manifest_forward_list, $implicit_forward_list);
function _getTestAction()
foreach ($action_class_list as $key =>
$action_name) {
unset
($action_class_list[$key]);
return $action_class_list;
foreach ($view_class_list as $key =>
$view_name) {
unset
($view_class_list[$key]);
* @return mixed 0:正常終了 Ethna_Error:エラー
$action_class_list =
$this->_getTestAction();
$view_class_list =
$this->_getTestView();
$test =
& new GroupTest("Ethna UnitTest");
foreach ($action_class_list as $action_name) {
$test->addTestCase(new $action_class($this->ctl));
$test->addTestCase(new $action_form($this->ctl));
foreach ($view_class_list as $view_name) {
$test->addTestCase(new $view_class($this->ctl));
foreach ($this->testcase as $class_name =>
$file_name) {
include_once $dir .
$file_name;
$testcase_name =
$class_name.
'_TestCase';
$test->addTestCase(new $testcase_name($this->ctl));
$this->ctl->action_form =
& $af;
$this->backend->action_form =
& $af;
$this->backend->af =
& $af;
return array($reporter->report, $reporter->result);
Documentation generated on Fri, 11 Nov 2011 04:00:59 +0900 by phpDocumentor 1.4.3