dimanche 8 septembre 2019

RuntimeException: A facade root has not been set

I am trying to develop on a fork of another package a utility to work with the schemas of the data bases of a Laravel application.

In my development I want to use Tests since the previous one had nothing. Although the package works perfectly integrated in an application with Laravel 6.X when I try to test the package it fails me

<?php

namespace Abkrim\DbSchema\Tests;

use Illuminate\Support\Facades\Config;
use Illuminate\Support\Facades\DB;
use PHPUnit\Framework\TestCase;
use Faker\Factory as Faker;

class DbSchemaTest extends TestCase
{
    /** @test */
    function it_can_access_the_database()
    {
       $faker = Faker::create();

       $user = DB::table('users')->insert([
           'email' => $faker->unique()->email,
           'name' => $faker->unique()->name,
           'password' => $faker->password(10),
           'rememberToken' => $faker->md5
       ]);
    }
}


If try running test

vendor/bin/phpunit --filter DbSchemaTest

1) Abkrim\DbSchema\Tests\DbSchemaTest::it_can_access_the_database
RuntimeException: A facade root has not been set.

/home/abkrim/Sites/db-schema/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php:236
/home/abkrim/Sites/db-schema/tests/DbSchemaTest.php:17


Aucun commentaire:

Enregistrer un commentaire