Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/274.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 是否可以在安装夹具中获得当前测试?_Php_Phpunit_Fixtures - Fatal编程技术网

Php 是否可以在安装夹具中获得当前测试?

Php 是否可以在安装夹具中获得当前测试?,php,phpunit,fixtures,Php,Phpunit,Fixtures,我找不到这样的东西,我猜它不存在 class Test extends PHPUnit_Framework_TestCase { public function setUp() { echo $current_test; // Output a string "testOne" } public function testOne() { // This is the first test; before this test is ran

我找不到这样的东西,我猜它不存在

class Test extends PHPUnit_Framework_TestCase {
    public function setUp() {
        echo $current_test; // Output a string "testOne"
    }

    public function testOne() {
        // This is the first test; before this test is ran setUp() is called.
        // The question is, is there any way to know within setUp() what the 
        // current test is?
    }
}

$this->name
应该包含当前的testcase方法名。您可以使用
$this->getName()
访问它(正如David善意地指出的那样)


在上查看TestCase的API。浏览属性及其注释,了解可用的内容。

$name
已更改为private,因此您需要使用
$this->getName()
。实际上,源代码是查找可用内容的最佳方法。:)