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 关于#python#的问题:求帮写python代码
  • ¥20 MATLAB画图图形出现上下震荡的线条
  • ¥15 LiBeAs的带隙等于0.997eV,计算阴离子的N和P
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘
  • ¥15 来真人,不要ai!matlab有关常微分方程的问题求解决,
  • ¥15 perl MISA分析p3_in脚本出错
  • ¥15 k8s部署jupyterlab,jupyterlab保存不了文件
  • ¥15 ubuntu虚拟机打包apk错误
  • ¥199 rust编程架构设计的方案 有偿
  • ¥15 回答4f系统的像差计算