murilo's avatar
Level 10

Test with Pest php , I cant get mysql data

hello , I am working with Pest . I was working with a project that was getting some user information froma seeded Mysql database . but now I am not able to get it any more . I dont know why .

I added this code in TestCase.php

protected $seed = true;

inside the TestCase.php file, with that I was able to seed those users and use that after in those tests .

but now , it is nt working any more .

my TestCase file is like this -

<?php

namespace Tests;

use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Foundation\Testing\TestCase as BaseTestCase;
use Illuminate\Foundation\Testing\DatabaseTransactions;

abstract class TestCase extends BaseTestCase
{
    //use CreatesApplication, RefreshDatabase;
    use CreatesApplication, DatabaseTransactions;
    protected $seed = true;

}

and after I am getting the user like this -

test('users', function () {
    $user = User::get();
dd($user);

})

but is getting null . it is not seeding .

0 likes
2 replies
murilo's avatar
murilo
OP
Best Answer
Level 10

thanks @amaury I solved that with .

php artisan cache:clear

Please or to participate in this conversation.