duanbai1974 2015-12-10 02:46
浏览 216

PHPUnit_Framework_TestCase找到但未定义的方法:: call()

Hi i am working with Laravel 4.2.17 , PHPUnit 5.1.1 and PHP 5.6.16 .

I am using PHPStorm as My Editor .

When i go to app/tests/ExampleTest.php and run it i am getting the error .

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

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 .

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 . :( :(

  • 写回答

1条回答 默认 最新

  • dsfvsdfv23599 2015-12-10 04:11
    关注

    The reason you cannot access call is because you are no longer extending TestCase which provides it. I suggest you revert back to extends TestCase and run your tests again. You should make sure to run the test from the root directory by using phpunit app/tests.

    Running composer dump-autoload also first, just in case it's an autoloading issue.

    评论

报告相同问题?

悬赏问题

  • ¥15 matlab(相关搜索:紧聚焦)
  • ¥15 基于51单片机的厨房煤气泄露检测报警系统设计
  • ¥15 路易威登官网 里边的参数逆向
  • ¥15 Arduino无法同时连接多个hx711模块,如何解决?
  • ¥50 需求一个up主付费课程
  • ¥20 模型在y分布之外的数据上预测能力不好如何解决
  • ¥15 processing提取音乐节奏
  • ¥15 gg加速器加速游戏时,提示不是x86架构
  • ¥15 python按要求编写程序
  • ¥15 Python输入字符串转化为列表排序具体见图,严格按照输入