php - 当我尝试模拟它时重新声明方法
问题描述
我有一个绑定在服务提供者中的类,
这个类使用我的门面,它扩展了 laravel 的门面,但是
当我尝试模拟它说的类时
Cannot redeclare Mockery_1_App_Classes_Dashboard_class::shouldReceive()
。
我的测试方法:
public function test_method()
{
class::shouldReceive('method')->once()->andReturns(true);
$response = $this->another_class->method();
dd($response);
}
我的门面:
<?php
namespace App\Facades\Dashboard;
use Illuminate\Support\Facades\Facade;
class class extends Facade
{
protected static function getFacadeAccessor()
{
return 'class';
}
}
应用服务提供者:
<?php
namespace App\Providers;
use Illuminate\Database\Eloquent\Relations\Relation;
use Illuminate\Support\Facades\Schema;
use Illuminate\Support\ServiceProvider;
use App\Classes\Dashboard\class;
class AppServiceProvider extends ServiceProvider
{
public function register()
{
$this->app->bind('class', function($app) {
return new class;
});
}
public function boot()
{
Schema::defaultStringLength(191);
}
}
我搜索了网络,不幸的是没有找到任何东西。
解决方案
终于发现问题了。
我不小心在我的类继承中扩展了 laravel 的外观。
推荐阅读
- c# - Visual Studio Code 不会在调试断点处停止
- javascript - How do I apply the same logic to multiple repeated elements?
- c# - 结合多个领域查询结果.net
- c - 如何查看传入浮点数的大小?
- python - 如何修复 SyntaxError:尝试将零填充到数字字符串时语法无效?
- swift - 如何在 Android 等警报控制器中编写 Swift 数字选择器
- c - 链表相同的值
- lazy-loading - 在服务器端 SuiteScript 2.0 中基于上下文加载自定义模块
- php - 一个类如何作为函数参数启动?
- android - 如何更改主题然后构建我的应用程序?