[英]PHPUnit_Framework_TestCase Found but undefined method ::call()
Hi i am working with Laravel 4.2.17 , PHPUnit 5.1.1 and PHP 5.6.16 . 嗨,我正在使用Laravel 4.2.17,PHPUnit 5.1.1和PHP 5.6.16。
I am using PHPStorm as My Editor . 我使用PHPStorm作为我的编辑器。
When i go to app/tests/ExampleTest.php and run it i am getting the error . 当我转到app / tests / ExampleTest.php并运行它时,出现了错误。
PHP Fatal error: Class 'TestCase' not found in /..../app/tests/ExampleTest.php on line 3
Then i changed TestCase
to PHPUnit_Framework_TestCase
Now the ExampleTest.php looks like this 然后我将
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());
}
}
Now the PHPUnit_Framework_TestCase
calls is identified . 现在,将识别
PHPUnit_Framework_TestCase
调用。
But when i try to do 但是当我尝试去做
public function testBasicExample()
{
$this->call("POST","test");
}
It is saying that 就是说
Fatal error: Call to undefined method ExampleTest::call()
I checked the larval documents and in there 我检查了幼虫文件,并在那里
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);
SO i am not sure what i am doing wrong . 所以我不确定我在做什么错。
I also tried by updating the composer , but no luck . 我也尝试过更新作曲家,但是没有运气。 :( :(
:( :(
The reason you cannot access call
is because you are no longer extending TestCase
which provides it. 您无法访问
call
的原因是因为您不再扩展提供call
TestCase
。 I suggest you revert back to extends TestCase
and run your tests again. 我建议您还原到
extends TestCase
并再次运行测试。 You should make sure to run the test from the root directory by using phpunit app/tests
. 您应该确保使用
phpunit app/tests
从根目录运行phpunit app/tests
。
Running composer dump-autoload
also first, just in case it's an autoloading issue. 还要先运行
composer dump-autoload
,以防万一这是一个自动加载问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.