【发布时间】:2017-07-05 09:24:16
【问题描述】:
我正在开发 Laravel (5.4) 包,并且正在尝试进行单元测试。我有这门课:
<?php
namespace Sample;
class Foo
{
public function getConfig()
{
$config = \Config::get('test');
return $config;
}
}
我有这个测试:
<?php
use PHPUnit\Framework\TestCase;
use Sample\Foo;
class FooTest extends TestCase
{
public function testGetConfig()
{
$foo = new Foo;
$config = $foo->getConfig();
}
}
当我执行 phpunit 时出现此错误:
错误:找不到类“配置”
如何对这个类进行单元测试?
谢谢。
【问题讨论】:
-
包括供应商自动加载
标签: php unit-testing laravel-5 phpunit package