【发布时间】:2014-06-20 11:30:30
【问题描述】:
我希望有人可以帮助我。我正在使用 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
现在,如果我有这个权利,那么错误是指一个方法是抽象的,那么它所在的类也必须是抽象的。正如您从 TestCase 类下面看到的那样,它是抽象的。我已经搜索过这个错误,但是画了一个空白。
尝试在 Laracasts https://laracasts.com/lessons/tdd-by-example 上关注此演员阵容,尽管您必须成为订阅者才能观看视频,但文件在其下方,正如您所见,我所做的与 Jeffrey Way 没有什么不同。
我的测试:
<?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);
}
}
TestCase 类的开头:
<?php namespace Illuminate\Foundation\Testing;
use Illuminate\View\View;
use Illuminate\Auth\UserInterface;
abstract class TestCase extends \PHPUnit_Framework_TestCase {
顺便说一句 - Laravel 测试类默认情况下不会自动加载,所以我尝试了完全限定的类名并使用 Illuminate\Foundation\Testing,然后只是扩展了 TestCase。我知道它可以看到它,因为当我没有完全限定它抱怨找不到类的名称时。我也试过:
composer dump-autoload
和
composer update
任何帮助表示赞赏
【问题讨论】: