0

I have installed a fresh Laravel project. I tried to set different database for PHPUnit testing, by adding "DB_DATABASE" And adding "use DatabaseMigrations" trait inside the test..

<server name="APP_ENV" value="testing"/>
<server name="BCRYPT_ROUNDS" value="4"/>
<server name="CACHE_DRIVER" value="array"/>
<server name="MAIL_DRIVER" value="array"/>
<server name="QUEUE_CONNECTION" value="sync"/>
<server name="SESSION_DRIVER" value="array"/>
<server name="DB_DATABASE" value="test_homestead" />

But I am getting this error:

1) Tests\Feature\ViewArticleTest::user_can_view_an_article
Illuminate\Database\QueryException: SQLSTATE[HY000] [1049] Unknown database 'test_homestead' (SQL: SHOW FULL TABLES WHERE table_type = 'BASE TABLE')`
2
  • you can remove <server name="DB_DATABASE" value="test_homestead" /> it will pick the value from the .env file Commented Apr 25, 2019 at 23:10
  • Or alternatively you can set <server name="DB_DATABASE" value="sqlite" /> Commented Apr 25, 2019 at 23:11

1 Answer 1

1

The error indicates that your test_homestead isn't available in your MySQL.

You should create a database by perform CREATE DATABASE test_homestead; in MySQL.

Or

Change the value in <server name="DB_DATABASE" value="test_homestead" /> to your desirable existing database name.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.