Laravel во время тестирования assertDatabaseHas всегда возвращает «Таблица пуста».Пользователь всегда существует в другой таблице, но не в сущности панели мониторинга.Что не так?
Мое окружение :
<server name="DB_CONNECTION" value="sqlite"/>
<server name="DB_DATABASE" value=":memory:"/>
Мой тест :
use RefreshDatabase;
/**
* test
*/
public function test_create_new_dashboard()
{
$this->withoutExceptionHandling();
$this->actingAs($this->user);
$dashboard = factory(DashboardsModel::class)->create([
'title' => 'some',
'owner_id' => $this->user->id
]);
$this->assertDatabaseHas($dashboard->getTable(), [
'title' => 'some'
]);
}
НоЯ всегда получаю :
ema@0d3db2c1ce07:/var/www/html$ ./vendor/phpunit/phpunit/phpunit --filter test_create_new_dashboard
PHPUnit 7.5.16 by Sebastian Bergmann and contributors.
F 1 / 1 (100%)
Time: 137 ms, Memory: 22.00 MB
There was 1 failure:
1) Tests\Feature\DashboardTest::test_create_new_dashboard
Failed asserting that a row in the table [dashboards] matches the attributes {
"title": "some"
}.
The table is empty.
/var/www/html/vendor/laravel/framework/src/Illuminate/Foundation/Testing/Concerns/InteractsWithDatabase.php:24
/var/www/html/tests/Feature/DashboardTest.php:47
FAILURES!
Tests: 1, Assertions: 1, Failures: 1.