使用PHPUnit 3.7测试方法内的受保护方法

时间:2015-01-13 13:42:23

标签: php phpunit tdd

我需要测试makeFileMatch函数,这个函数里面有2个受保护的方法。 这样做的正确行为是什么? 我有这个类的模拟,我需要创建这个方法的反射,并改变你的返回值? 我需要一个例子:D

public function makeFileMatch($templateUrl,$width,$height)
{
    $result = $this->assembleCurlRequest($templateUrl, $width, $height);

    return $this->parseJsonResult($result);
}

/**
 * @param $result
 * @return array
 */
protected function transformJsonInArray($result)
{
    return (array)json_decode($result);
}

/**
 * @param $result
 * @return bool|string
 */
protected function tryToRetrieveUrlFromJsonResponse($result)
{
    if ($result['status'] == 'success') {

        return $this->getCreatedThumbByUrl($result['data']->url);
    }

    return false;
}

0 个答案:

没有答案