lukeraymonddowning / pest-plugin-larastrap

Wraps your Pest suite in a Laravel application instance, allowing global use of the framework in tests.
MIT License
9 stars 1 forks source link

phpunit.xml database connection ignored after this plugin installation #4

Open abdulwahhabkhan opened 1 year ago

abdulwahhabkhan commented 1 year ago

Hi Luke,

I really like your videos on youtube and was impressed with the talk on Laracone EU so started playing around with Higher Order Tests.

To resolve the route helper I installed the plugin and it works :)

But rain into a problem as now the test communicates with the local DB instead of the test DB.

Please can you let me know is this expected behaviour or if I missed some information?

rabol commented 1 year ago

Same issue here - seems like the settings in phpunit.xml is ignored

swilla commented 5 months ago

Same issue here, I cannot get pest to use the .env.testing with this installed.

swilla commented 5 months ago

I was able to get this working by adding a line in the CreatesApplication.php trait to force loading .env.testing:

<?php

namespace Tests;

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

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

        $app->loadEnvironmentFrom('.env.testing');

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

        return $app;
    }
}