Error extending TestCase abstract class from Laravel (error says that my extended class should be abstract)

I hope someone there can help me. I am using laravel 4 and I have been writing my first unit tests for a while, but I have problems. I am trying to extend the TestCase class, but I am getting the following error:

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

Now, if I have this right, the error refers to the fact that the method is abstract, then its class must be abstract. As you can see below, the TestCase class is abstract. I searched for this error, but drew a space.

Trying to follow this chord on Laracasts https://laracasts.com/lessons/tdd-by-example , and although you must be a subscriber to watch the video below it, and as you can see, I do nothing with Jeffrey Way.

My test:

<?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);
    }
}

Start of the TestCase class:

<?php namespace Illuminate\Foundation\Testing;

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

abstract class TestCase extends \PHPUnit_Framework_TestCase {

By the way, the Laravel testing class does not autostart by default, so I tried both the full name of the class and used Illuminate \ Foundation \ Testing, and then just extended TestCase. I know that he can see this as soon as I do not fully qualify the name that he complains that the class cannot be found. I also tried:

composer dump-autoload

and

composer update

Any help appreciated

+4
source share
1 answer

: Class registrationTest contains 1 abstract method Base Class abstract method, Child Class , , Base Class. , registrationTest , \Illuminate\Foundation\Testing\TestCase :

\Illuminate\Foundation\Testing\TestCase:

abstract public function createApplication();

, child class/registrationTest :

public function createApplication(){
    //...
}

\Illuminate\Foundation\Testing\TestCase, app/tests TestCase/TestCase.php, :

// In app/tests folder
class registrationTest extends TestCase {
    //...
}

TestCase.php :

class TestCase extends Illuminate\Foundation\Testing\TestCase {

public function createApplication()
{
        $unitTesting = true;
        $testEnvironment = 'testing';
        return require __DIR__.'/../../bootstrap/start.php';
    }
}

, TestCase createApplication, . TestCase . , app/tests , :

class registrationTest extends TestCase {
    public function testBasicExample()
    {
        $crawler = $this->client->request('GET', '/');
        $this->assertTrue($this->client->getResponse()->isOk());
    }
}

.

+7

Source: https://habr.com/ru/post/1539134/


All Articles