My unit tests work fine as long as I do not try to mock a DB object. I created a Factory and am trying to use it in one of my tests. However, I keep getting a could not find driver error
. I have looked up a couple of stack answers and my version of php is 7.1, so not really sure what is causing the error.
Here is my testing class.
<?php
/**
* Created by PhpStorm.
*/
namespace Tests\Unit\Helper\Results;
use Jobscan\Helper\Results\FormatHelper;
use Illuminate\Foundation\Testing\WithFaker;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Foundation\Testing\WithoutMiddleware;
use Jobscan\Models\Document\Cv;
use Tests\TestCase;
class FormatHelperTest extends TestCase
{
public function testFindingsForUploadedDocxResume_whenFontTypeIsNotStandard_resultFontTypeShowsNegativeResult()
{
$cv = factory(Cv::class)->create([
'content' => "Testing Test test",
]);
dd($cv);
}
}
In my phpunit test
<env name="DB_CONNECTION" value="test_db"/>
<env name="DB_DATABASE" value=":memory:"/>
This is the error I keep getting
Caused by
Doctrine\DBAL\Driver\PDOException: could not find driver
database.php file
// This database is ephemeral and used for testing purposes.
'test_db' => [
'driver' => 'sqlite',
'database' => ':memory:',
'prefix' => '',
],