Using RefreshDatabase Shows The Driver Not Found Error
I am Trying to write tests in laravel, i have been doing this for some time and it has been working well. With this new project, i am supposed to use TDD still and the Refresh Database. When i include use RefreshDatabase, i get an error that i have not been getting with the other projects i have been working on. What could be the problem.
code i am testing.
class ParentsTest extends TestCase
{
use RefreshDatabase;
/** @test */
public function createParentTest(){
$this->withoutExceptionHandling();
$response = $this->post('/create-parent',[
'fname' => 'Julius',
'lname' => 'Ssemakula',
'contact' => '256702913454'
]);
$this->assertDatabaseHas('Parents', ['fname' => 'Julius']);
}
}
the error I get is
1) Tests\Feature\ParentsTest::createParentTest Illuminate\Database\QueryException: could not find driver (SQL: PRAGMA foreign_keys = ON;)
Answer
You need to install the appropriate driver for the database you are using. If you are on Linux:
First find out which version of PHP you are running using php --version
. I'll use php7.3
for demonstration purposes.
For MySQL:
sudo apt install php7.3-mysql
For SQLite:
sudo apt install php7.3-sqlite
For PostgreSQL:
sudo apt install php7.3-pgsql
After installing the appropriate drivers, your tests should work.
Related Questions
- → "failed to open stream" error when executing "migrate:make"
- → October CMS Plugin Routes.php not registering
- → OctoberCMS Migrate Table
- → OctoberCMS Rain User plugin not working or redirecting
- → October CMS Custom Mail Layout
- → October CMS - How to correctly route
- → October CMS - Conditionally Load a Different Page
- → Make a Laravel collection into angular array (octobercms)
- → In OctoberCMS how do you find the hint path?
- → How to register middlewares in OctoberCMS plugin?
- → Validating fileupload(image Dimensions) in Backend Octobercms
- → OctoberCMS Fileupload completely destroys my backend
- → How do I call the value from another backed page form and use it on a component in OctoberCms