您好我正在使用Laravel 4.2.17,PHPUnit 5.1.1和PHP 5.6.16。
我正在使用PHPStorm作为我的编辑器。
当我去app / tests / ExampleTest.php并运行它时,我收到错误。
PHP Fatal error: Class 'TestCase' not found in /..../app/tests/ExampleTest.php on line 3
然后我将TestCase
更改为PHPUnit_Framework_TestCase
现在ExampleTest.php看起来像这样
class ExampleTest extends PHPUnit_Framework_TestCase {
/**
* A basic functional test example.
*
* @return void
*/
public function testBasicExample()
{
$crawler = $this->client->request('GET', '/');
$this->assertTrue($this->client->getResponse()->isOk());
}
}
现在识别出PHPUnit_Framework_TestCase
次来电。
但是当我尝试做的时候
public function testBasicExample()
{
$this->call("POST","test");
}
这是说
Fatal error: Call to undefined method ExampleTest::call()
我检查了幼虫文件并在那里
Calling A Route From A Test
You may easily call one of your routes for a test using the call method:
$response = $this->call('GET', 'user/profile');
$response = $this->call($method, $uri, $parameters, $files, $server, $content);
所以我不确定我做错了什么。
我也试过更新作曲家,但没有运气。 :( :(
答案 0 :(得分:0)
您无法访问call
的原因是因为您不再扩展提供它的TestCase
。我建议你恢复extends TestCase
并再次运行测试。您应该确保使用phpunit app/tests
从根目录运行测试。
首先运行composer dump-autoload
,以防它是自动加载问题。