phpUnit-测试类中不是测试的函数

phpUnit-测试类中不是测试的函数,php,curl,phpunit,Php,Curl,Phpunit,我在phpunit中对报告进行速度比较,因为我试图找出一个优化问题 我有两个功能不一定是测试,但也不属于项目的功能。我使用它们是为了使我的测试小而可读。我使用的函数使用我传递给它的参数执行cUrl操作 所以,我运行了两个URL,一个是项目的两个版本,一个是原始版本,另一个是优化版本,看看它们返回的文本是否相等。我不会在应用程序本身中这样做。我这样做是因为它比试图找出正确的函数调用要快,因为项目有点混乱 所以我有一个这样的测试: public function testOne(){ $r

我在phpunit中对报告进行速度比较,因为我试图找出一个优化问题

我有两个功能不一定是测试,但也不属于项目的功能。我使用它们是为了使我的测试小而可读。我使用的函数使用我传递给它的参数执行cUrl操作

所以,我运行了两个URL,一个是项目的两个版本,一个是原始版本,另一个是优化版本,看看它们返回的文本是否相等。我不会在应用程序本身中这样做。我这样做是因为它比试图找出正确的函数调用要快,因为项目有点混乱

所以我有一个这样的测试:

public function testOne(){

    $results = $this->testRange(13,1,2013,16,1,2013);
    $this->assertEquals($results['opt'], $results['non_opt']);

}//tests
以及我的两个非测试功能:

protected function testRange($fromDay,
                          $fromMonth,
                          $fromYear,
                          $toDay,
                          $toMonth,
                          $toYear){

    $this->params['periodFromDay'] = $fromDay;
    $this->params['periodFromMonth'] = $fromMonth;
    $this->params['periodFromYear'] = $fromYear;
    $this->params['periodToDay'] = $toDay;
    $this->params['periodToMonth'] = $toMonth;
    $this->params['periodToYear'] = $toYear;

    $this->data['from']=$fromDay."-".$fromMonth."-".$fromYear;
    $this->data['to']=$toDay."-".$toMonth."-".$toYear;;

    return $this->testRunner();

}//testOneDay


protected function testRunner(){

    //include"test_bootstrap.php";
    $response = array();

    foreach($this->types as $key=>$type){

        $params = http_build_query($this->params);
        $url=$this->paths[$type];
        $curl_url = $url."?".$params;
        $ch = curl_init($curl_url);
        $cookieFile = "tmp/cookie.txt";

        if(!file_exists($cookieFile))
        {

            $fh = fopen($cookieFile, "w");
            fwrite($fh, "");
            fclose($fh);

        }//if

        curl_setopt($ch,CURLOPT_COOKIEFILE,$cookieFile);
        curl_setopt($ch,CURLOPT_COOKIEJAR,$cookieFile);
        curl_setopt($ch,CURLOPT_FOLLOWLOCATION,1);
        curl_setopt($ch,CURLOPT_HEADER,0);
        curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);

        $result[$type] = curl_exec($ch);

        $dump = "logs/report_results/".
                 $this->data['from']."_".
                 $this->data['to']."_".
                 $type.".txt";

        $fh = fopen($dump, "w");
        fwrite($fh, $result[$type]);
        fclose($fh);

    }//foreach

    return $result;

}//testRunner
我想知道

答:可以在测试文件中写入函数,并让phpunit忽略它们,或者如果有更合适的位置放置它们


有一种更明智的方法来处理这类事情。我喜欢这种方式,,但是我愿意接受建议。

PHPUnit将忽略任何名称不以test*开头的方法,并且没有@test注释,因此可以随意将内容放在私有助手函数中。

PHPUnit将忽略任何名称不以test*开头且没有@test注释的方法,因此可以随意将内容放在私有助手中功能