Zend for eclipse 中PHPUnit 的环境变量path设置文件梳理

jackxiang 2010-6-23 14:22 | |
D:\Program Files\Zend\Zend Studio - 7.2.0\plugins\com.zend.php.phpunit_7.2.0.v20100324-1300\resources\ZendPHPUnit.php

require_once $_SERVER['ZEND_PHPUNIT_TESTS_LOCATION'];

define('PHPUnit_MAIN_METHOD', '');

set_include_path(get_include_path()
  . PATH_SEPARATOR . $_SERVER['ZEND_PHPUNIT_LOCATION']
  . PATH_SEPARATOR . $_SERVER['ZEND_PHPUNIT_PROJECT_LOCATION']
  . PATH_SEPARATOR . $_SERVER['ZEND_PHPUNIT_CONTAINER_INCLUDE_PATH']
);

开始继承PHPUnit_Framework_TestSuite:

require_once 'PHPUnit/TextUI/TestRunner.php';

$cwd = getCwd();

foreach ($ZendPHPUnitTests as $test) {
  chDir(dirname($test['file']));
  require_once $test['file'];
  chDir(dirname($cwd));
}

class ZendPHPUnitSuite extends PHPUnit_Framework_TestSuite {

    public static function suite() {
    $suite = new self();
    $suite->setName(__CLASS__);
    foreach ($GLOBALS['ZendPHPUnitTests'] as $test)
      if ($test['type'] === 'suite') {
        $suite->addTest(call_user_func(array ($test['name'], 'suite')));
      } else $suite->addTestSuite($test['name']);
    return $suite;
  }
}

首先是加入环境变量:
.;Z:\soa1.3.1_code;;Z:\soa1.3.1_code;
然后,才是自己继承它加入自己的变量:
VoteTest.php 内容:
<?php
require_once 'component/test/service/DirTest**.include.php';
包含被测试文件
继承文件:require_once 'component/test/ComponentPHPUnit_Framework_TestCase***.php';其内容大体如下:
class ComponentPHPUnit_Framework_TestCase extends PHPUnit_Framework_TestCase{



开始测试的函数编写
EOF!

=================================================================
DirTest**.include.phpcode如下:

<?php
define("ROOT_PATH",realpath("../../../").'/');
define("LIB_PATH",ROOT_PATH."PHP_TM_LIB***/");

set_include_path(
    get_include_path()
    .PATH_SEPARATOR . ROOT_PATH
    .PATH_SEPARATOR . LIB_PATH
);
?>


首先:path里面已经包含:
.;Z:\soa1.3.1_code;D:\Program Files\Zend\Zend Studio - 7.2.0\plugins\com.zend.php.phpunit_7.2.0.v20100324-1300\resources\library\
然后:

set_include_path(get_include_path()
  . PATH_SEPARATOR . $_SERVER['ZEND_PHPUNIT_LOCATION']
  . PATH_SEPARATOR . $_SERVER['ZEND_PHPUNIT_PROJECT_LOCATION']
  . PATH_SEPARATOR . $_SERVER['ZEND_PHPUNIT_CONTAINER_INCLUDE_PATH']
);

把本地文件包含进来:
注意:zend unit里面的:
var_dump( $_SERVER['ZEND_PHPUNIT_LOCATION']); 就是源文件工程目录path位置:Z:\soa1.3.1_code

作者:jackxiang@向东博客 专注WEB应用 构架之美 --- 构架之美,在于尽态极妍 | 应用之美,在于药到病除
地址:https://jackxiang.com/post/3230/
版权所有。转载时必须以链接形式注明作者和原始出处及本声明!


最后编辑: jackxiang 编辑于2010-6-23 14:45
评论列表
发表评论

昵称

网址

电邮

打开HTML 打开UBB 打开表情 隐藏 记住我 [登入] [注册]