Bird
0
0

You want to use a SQLite in-memory database for testing in Laravel. Which configuration should you set in config/database.php?

hard📝 Application Q9 of 15
Laravel - Database Basics and Migrations
You want to use a SQLite in-memory database for testing in Laravel. Which configuration should you set in config/database.php?
A'sqlite' => ['driver' => 'sqlite', 'database' => null]
B'sqlite' => ['driver' => 'sqlite', 'database' => ':memory:']
C'sqlite' => ['driver' => 'sqlite', 'database' => 'database.sqlite']
D'sqlite' => ['driver' => 'sqlite', 'database' => '']
Step-by-Step Solution
Solution:
  1. Step 1: Understand SQLite in-memory database

    SQLite uses ':memory:' as a special value to create a temporary in-memory database.
  2. Step 2: Check config syntax

    'sqlite' => ['driver' => 'sqlite', 'database' => ':memory:'] correctly sets 'database' => ':memory:' to enable in-memory DB for tests.
  3. Final Answer:

    Use 'database' => ':memory:' for SQLite in-memory DB -> Option B
  4. Quick Check:

    SQLite in-memory DB uses ':memory:' string [OK]
Quick Trick: Use ':memory:' for SQLite in-memory testing DB [OK]
Common Mistakes:
  • Using file name instead of ':memory:'
  • Setting database to null or empty string

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Laravel Quizzes