小编Joh*_*ans的帖子

扩展Laravel的抽象TestCase类时出错(错误是说我的扩展类必须是抽象的)

我希望有人可以帮助我.我正在使用laravel 4,我正在编写我的第一个单元测试一段时间但遇到了麻烦.我正在尝试扩展TestCase类,但是我收到以下错误:

PHP Fatal error:  Class registrationTest contains 1 abstract method and must therefore be declared abstract or implement the remaining methods (Illuminate\Foundation\Testing\TestCase::createApplication) in /home/john/www/projects/MyPainChart.com/app/tests/registrationTest.php on line 4
Run Code Online (Sandbox Code Playgroud)

现在,如果我有这个权利,那么错误是指一个方法是抽象的事实,那么它所在的类也必须是抽象的.从下面的TestCase类可以看出它是抽象的.我已经搜索了这个错误,但已经画了一个空白.

试图在Laracasts https://laracasts.com/lessons/tdd-by-example上关注这个演员,虽然你必须是一个订阅者才能观看视频,文件在它下面,你可以看到我没有做任何不同的事情.杰弗里路.

我的测试:

<?php

class registrationTests extends \Illuminate\Foundation\Testing\TestCase
{

    /**
     * Make sure the registration page loads
     * @test
     */
    public function make_sure_the_registration_page_loads_ok()
    {
        $this->assertTrue(true);
    }
}
Run Code Online (Sandbox Code Playgroud)

TestCase类的开头:

<?php namespace Illuminate\Foundation\Testing;

use Illuminate\View\View;
use Illuminate\Auth\UserInterface;

abstract class TestCase extends \PHPUnit_Framework_TestCase {
Run Code Online (Sandbox Code Playgroud)

顺便说一句 - Laravel测试类默认不自动加载,因此我尝试了两个完全限定的类名,并使用Illuminate\Foundation\Testing,然后只扩展TestCase.我知道它可以看到它,因为我没有完全限定它抱怨该类无法找到的名称.我也尝试过:

composer dump-autoload
Run Code Online (Sandbox Code Playgroud)

composer update
Run Code Online (Sandbox Code Playgroud)

任何帮助赞赏

php phpunit laravel

4
推荐指数
1
解决办法
3193
查看次数

标签 统计

laravel ×1

php ×1

phpunit ×1