PHP   发布时间:2022-04-01  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了phpunit – 在单元测试中模拟时未找到Laravel外观类大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我可能在这里遗漏了一些东西,但我有一个非常简单的帮助类,它创建了一个目录:
// Helper class

<?php namespace MyApp\Helpers;

    use User;
    use File;

    class FileSystemHelper
    {
        protected $userBin = 'users/uploads';

        public function createUserUploadBin(User $user)
        {
            $path = $this->userBin . '/' . $user->id;

            if ( ! File::isDirectory($path))
            {
                File::makeDirectory($path);
            }
        }
    }

以及相关的测试:

// Associated test class

<?php 

    use MyApp\Helpers\FileSystemHelper;

    class FileSystemHelperTest extends TESTCase {

        protected $fileSystemHelper;

        public function setUp()
        {
            $this->fileSystemHelper = new FileSystemHelper;
        }

        public function testNewUploadBinCreatedWhenNotExists()
        {
            $user = new User; // this would be mocked

            File::shouldReceive('makeDirectory')->once();

            $this->fileSystemHelper->createUserUploadBin($user);
        }
    }

但是在运行测试时出现致命错误:

我看过嘲笑门面的文档,我看不出我哪里出错了.有什么建议?

谢谢

解决方法

我在文档中错过了这个:

打电话说就是解决了这个问题.卫生署!

大佬总结

以上是大佬教程为你收集整理的phpunit – 在单元测试中模拟时未找到Laravel外观类全部内容,希望文章能够帮你解决phpunit – 在单元测试中模拟时未找到Laravel外观类所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。