只要我不试图模仿DB对象,我的单元测试就可以正常工作。我创建了一个工厂,并试图在我的一个测试中使用它。然而,我不断地
a could not find driver error
这是我的测试课。
<?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);
}
}
在我的phpunit测试中
<env name="DB_CONNECTION" value="test_db"/>
<env name="DB_DATABASE" value=":memory:"/>
这就是我一直犯的错误
Caused by
Doctrine\DBAL\Driver\PDOException: could not find driver
数据库.php文件
// This database is ephemeral and used for testing purposes.
'test_db' => [
'driver' => 'sqlite',
'database' => ':memory:',
'prefix' => '',
],