Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/Unit Tests have no --domain option, so no .env loaded, so they can not working if needed #115

Closed
MrCanan opened this issue Apr 29, 2024 · 2 comments

Comments

@MrCanan
Copy link

MrCanan commented Apr 29, 2024

Hi,

New problem/question

  • The Feature/Unit test can not work, due to do not have "--domain" option, so .env is missing to load correct database

I got "Database file at path [ABSOLUTE_PATH/database/database.sqlite] does not exist. Ensure this is an absolute path to the database." error (ABSOLUTE_PATH is a example)

Environnement

  • Laravel 11.5.0 (lastest)
  • laravel-multidomain 11.0 (lastest)

Env

  • Delete .env
  • Create .env.test.lan
DB_DATABASE=__ABSOLUTE_PATH__/database/database_test.sqlite

Database

  • Delete database/database.sqlite
  • Create database/database_test.sqlite

Feature/Unit Test

tests\Feature\CustomTest.php

<?php

namespace Tests\Feature;

use Tests\TestCase;

use Illuminate\Foundation\Testing\RefreshDatabase;

use App\Models\User;
use Database\Seeders\UserSeeder;

class CustomTest extends TestCase
{
    use RefreshDatabase;

    /**
     * test_get_db
     */
    public function test_get_db(): void
    {
        $oResponse = $this->get('/');

        $oResponse->assertStatus(302);
    }
}

Run

php artisan test --testsuite=Feature --stop-on-failure --filter CustomTest

Thank you in advance for any help,
Best regards

@gecche
Copy link
Owner

gecche commented Apr 30, 2024

Hi, I close the issue as is the same as #100. However I don't think that can be solved easily. :(

@gecche gecche closed this as completed Apr 30, 2024
@MrCanan
Copy link
Author

MrCanan commented Apr 30, 2024

Hi back,

This is very annoying, because these tests are necessary

Do you have an idea?
Can I help you? (to test or other)

Best regards

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants