2
我正在使用PHPUnit来单元测试我的应用程序(使用Zend Framework 2)。我陷入了一种情况,我需要从另一个测试类中调用一个测试类 中的方法。让我用一个小例子解释一下:从另一个测试类调用测试类的方法
<?php
// TestUser.php
namespace Test\User;
class UserTest extends \PHPUnit_Framework_TestCase
{
public static function GetUserCount(){
// some code here
}
}
?>
<?php
// TestAdmin.php
namespace Test\Admin;
use Test\User;
class AdminTest extends \PHPUnit_Framework_TestCase
{
public static function AdminAction(){
Test\User::GetUserCount();
}
}
?>
当我打电话Test\User::GetUserCount();
或User::GetUserCount();
我收到以下错误:
PHP Fatal error: Class 'Test\User' not found in path/to/TestAdmin.php on line 11
任何想法,如果该方法是从一个测试类调用到另一个测试类?如果是,如何?
感谢
类名称是:UserTest不是用户 – Pakspul