Skip to content

Cannot run any of HTTP tests with Laravel plugin #965

Closed Answered by owenvoke
maximal asked this question in Q&A
Discussion options

You must be logged in to vote

Are you adding tests to an existing Laravel app? 🤔 There should be an existing TestCase.php which looks like this:

<?php

namespace Tests;

use Illuminate\Foundation\Testing\TestCase as BaseTestCase;

abstract class TestCase extends BaseTestCase
{
    use CreatesApplication;
}

And a CreatesApplication.php which looks like this:

<?php

namespace Tests;

use Illuminate\Contracts\Console\Kernel;
use Illuminate\Foundation\Application;

trait CreatesApplication
{
    public function createApplication(): Application
    {
        $app = require __DIR__.'/../bootstrap/app.php';

        $app->make(Kernel::class)->bootstrap();

        return $app;
    }
}

Try using those files, and it should all…

Replies: 1 comment 4 replies

Comment options

You must be logged in to vote
4 replies
@maximal
Comment options

@owenvoke
Comment options

Answer selected by maximal
@maximal
Comment options

@owenvoke
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants