我正在尝试对调用另一个使用存储外观的函数的函数进行单元测试。当我在phpunit中运行该函数时,它返回错误,“错误:未找到类'存储'。”如何在没有错误的情况下运行该函数或者默认第二个函数返回true?
我试图测试的部分代码。
public function newMaterial($fileType, $groupId, $categoryId, $fileName, $file, $open, $close) {
$material = new Mat;
if (!$this->save($fileType, $file, $material)) {
return false;
}
}
这是导致错误的代码部分。
protected function save($fileType, $file, Mat $material) {
//generate random name
do {
$key = str_random(32);
//check if exist
} while (Storage::exists($path . $key . '.' . $ext));
return true;
}
这不是我的所有代码,只是造成问题的部分。
在我的测试中,我只调用newMaterial函数并返回错误。