phpunit说我对类有双重定义
我有几个测试文件,一个其他人将从中继承的文件 这是父文件:phpunit说我对类有双重定义,php,phpunit,Php,Phpunit,我有几个测试文件,一个其他人将从中继承的文件 这是父文件: <?php namespace Initial\Reports\Tests; use Illuminate\Database\Eloquent\Model; use Initial\Reports\DataFetcher; const DONT_CARE = true; class ReportTest extends \TestCase { } 我明白了 听起来您正在对包含类的文件执行多个include。includ
<?php
namespace Initial\Reports\Tests;
use Illuminate\Database\Eloquent\Model;
use Initial\Reports\DataFetcher;
const DONT_CARE = true;
class ReportTest extends \TestCase {
}
我明白了
听起来您正在对包含类的文件执行多个
include
。include
使PHP的行为就像所包含文件的内容只是在include
语句所在的位置键入一样。多次这样做,您将有两个类的定义
您应该使用(1)(请参阅)或(2)使用require
,而不是include
当然,另一种可能性是,您确实有两个类定义,在这种情况下,您需要重命名一个。这是因为我的测试父级的命名:
ReportTest
因此,phpunit将其视为另一个测试类
我把它改成了
ReportTestCase
than phpunit没有发现它是一个测试,而且所有的工作都很好。在您的
path/to/folder
或Initial\Reports\Tests
命名空间中的某个地方必须是另一个名为ReportTest
的类。重命名一个。
ReportTest
ReportTestCase