DoctrineDBALDriverPDOException: could not find driver when trying to use a factory in my unit tests
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 TestsUnitHelperResults;
use JobscanHelperResultsFormatHelper;
use IlluminateFoundationTestingWithFaker;
use IlluminateFoundationTestingRefreshDatabase;
use IlluminateFoundationTestingWithoutMiddleware;
use JobscanModelsDocumentCv;
use TestsTestCase;
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
DoctrineDBALDriverPDOException: could not find driver
database.php file
// This database is ephemeral and used for testing purposes.
'test_db' => [
'driver' => 'sqlite',
'database' => ':memory:',
'prefix' => '',
],
laravel driver factory phpunit-testing
add a comment |
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 TestsUnitHelperResults;
use JobscanHelperResultsFormatHelper;
use IlluminateFoundationTestingWithFaker;
use IlluminateFoundationTestingRefreshDatabase;
use IlluminateFoundationTestingWithoutMiddleware;
use JobscanModelsDocumentCv;
use TestsTestCase;
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
DoctrineDBALDriverPDOException: could not find driver
database.php file
// This database is ephemeral and used for testing purposes.
'test_db' => [
'driver' => 'sqlite',
'database' => ':memory:',
'prefix' => '',
],
laravel driver factory phpunit-testing
Are you able to use a model directly? Without a factory?
– adam
Nov 14 '18 at 20:44
@adam nope, I tried using the model directly.
– Aaron
Nov 14 '18 at 22:07
Can you show yourconfig/database.php
file please ?
– Steve Chamaillard
Nov 14 '18 at 22:27
@SteveChamaillard, I just added config/database.php.
– Aaron
Nov 14 '18 at 22:30
@SteveChamaillard, thanks, but now I am getting a PHP Startup: Unable to load dynamic library 'pdo_sqlite' error.
– Aaron
Nov 14 '18 at 22:39
add a comment |
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 TestsUnitHelperResults;
use JobscanHelperResultsFormatHelper;
use IlluminateFoundationTestingWithFaker;
use IlluminateFoundationTestingRefreshDatabase;
use IlluminateFoundationTestingWithoutMiddleware;
use JobscanModelsDocumentCv;
use TestsTestCase;
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
DoctrineDBALDriverPDOException: could not find driver
database.php file
// This database is ephemeral and used for testing purposes.
'test_db' => [
'driver' => 'sqlite',
'database' => ':memory:',
'prefix' => '',
],
laravel driver factory phpunit-testing
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 TestsUnitHelperResults;
use JobscanHelperResultsFormatHelper;
use IlluminateFoundationTestingWithFaker;
use IlluminateFoundationTestingRefreshDatabase;
use IlluminateFoundationTestingWithoutMiddleware;
use JobscanModelsDocumentCv;
use TestsTestCase;
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
DoctrineDBALDriverPDOException: could not find driver
database.php file
// This database is ephemeral and used for testing purposes.
'test_db' => [
'driver' => 'sqlite',
'database' => ':memory:',
'prefix' => '',
],
laravel driver factory phpunit-testing
laravel driver factory phpunit-testing
edited Nov 14 '18 at 22:30
Aaron
asked Nov 14 '18 at 19:49
AaronAaron
1,77254290
1,77254290
Are you able to use a model directly? Without a factory?
– adam
Nov 14 '18 at 20:44
@adam nope, I tried using the model directly.
– Aaron
Nov 14 '18 at 22:07
Can you show yourconfig/database.php
file please ?
– Steve Chamaillard
Nov 14 '18 at 22:27
@SteveChamaillard, I just added config/database.php.
– Aaron
Nov 14 '18 at 22:30
@SteveChamaillard, thanks, but now I am getting a PHP Startup: Unable to load dynamic library 'pdo_sqlite' error.
– Aaron
Nov 14 '18 at 22:39
add a comment |
Are you able to use a model directly? Without a factory?
– adam
Nov 14 '18 at 20:44
@adam nope, I tried using the model directly.
– Aaron
Nov 14 '18 at 22:07
Can you show yourconfig/database.php
file please ?
– Steve Chamaillard
Nov 14 '18 at 22:27
@SteveChamaillard, I just added config/database.php.
– Aaron
Nov 14 '18 at 22:30
@SteveChamaillard, thanks, but now I am getting a PHP Startup: Unable to load dynamic library 'pdo_sqlite' error.
– Aaron
Nov 14 '18 at 22:39
Are you able to use a model directly? Without a factory?
– adam
Nov 14 '18 at 20:44
Are you able to use a model directly? Without a factory?
– adam
Nov 14 '18 at 20:44
@adam nope, I tried using the model directly.
– Aaron
Nov 14 '18 at 22:07
@adam nope, I tried using the model directly.
– Aaron
Nov 14 '18 at 22:07
Can you show your
config/database.php
file please ?– Steve Chamaillard
Nov 14 '18 at 22:27
Can you show your
config/database.php
file please ?– Steve Chamaillard
Nov 14 '18 at 22:27
@SteveChamaillard, I just added config/database.php.
– Aaron
Nov 14 '18 at 22:30
@SteveChamaillard, I just added config/database.php.
– Aaron
Nov 14 '18 at 22:30
@SteveChamaillard, thanks, but now I am getting a PHP Startup: Unable to load dynamic library 'pdo_sqlite' error.
– Aaron
Nov 14 '18 at 22:39
@SteveChamaillard, thanks, but now I am getting a PHP Startup: Unable to load dynamic library 'pdo_sqlite' error.
– Aaron
Nov 14 '18 at 22:39
add a comment |
2 Answers
2
active
oldest
votes
Define a setUp method in your test:
public function setUp()
parent::setUp();
I added the setUp method and am still getting the same error.
– Aaron
Nov 14 '18 at 20:30
add a comment |
Your error means it doesn't find the sqlite driver within your PHP lib which means the extension is not properly loaded.
Look into your php.ini
file (find its path by doing : php --ini
) and find :
extension=pdo_sqlite
If this is written as :
;extension=pdo_sqlite
, then you should remove the ;
.
thanks, but now I am getting a PHP Startup: Unable to load dynamic library 'pdo_sqlite' error.
– Aaron
Nov 14 '18 at 22:44
@Aaron this might help you : stackoverflow.com/questions/44701256/…
– Steve Chamaillard
Nov 14 '18 at 22:44
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53307764%2fdoctrine-dbal-driver-pdoexception-could-not-find-driver-when-trying-to-use-a-fa%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
Define a setUp method in your test:
public function setUp()
parent::setUp();
I added the setUp method and am still getting the same error.
– Aaron
Nov 14 '18 at 20:30
add a comment |
Define a setUp method in your test:
public function setUp()
parent::setUp();
I added the setUp method and am still getting the same error.
– Aaron
Nov 14 '18 at 20:30
add a comment |
Define a setUp method in your test:
public function setUp()
parent::setUp();
Define a setUp method in your test:
public function setUp()
parent::setUp();
answered Nov 14 '18 at 20:20
adamadam
917811
917811
I added the setUp method and am still getting the same error.
– Aaron
Nov 14 '18 at 20:30
add a comment |
I added the setUp method and am still getting the same error.
– Aaron
Nov 14 '18 at 20:30
I added the setUp method and am still getting the same error.
– Aaron
Nov 14 '18 at 20:30
I added the setUp method and am still getting the same error.
– Aaron
Nov 14 '18 at 20:30
add a comment |
Your error means it doesn't find the sqlite driver within your PHP lib which means the extension is not properly loaded.
Look into your php.ini
file (find its path by doing : php --ini
) and find :
extension=pdo_sqlite
If this is written as :
;extension=pdo_sqlite
, then you should remove the ;
.
thanks, but now I am getting a PHP Startup: Unable to load dynamic library 'pdo_sqlite' error.
– Aaron
Nov 14 '18 at 22:44
@Aaron this might help you : stackoverflow.com/questions/44701256/…
– Steve Chamaillard
Nov 14 '18 at 22:44
add a comment |
Your error means it doesn't find the sqlite driver within your PHP lib which means the extension is not properly loaded.
Look into your php.ini
file (find its path by doing : php --ini
) and find :
extension=pdo_sqlite
If this is written as :
;extension=pdo_sqlite
, then you should remove the ;
.
thanks, but now I am getting a PHP Startup: Unable to load dynamic library 'pdo_sqlite' error.
– Aaron
Nov 14 '18 at 22:44
@Aaron this might help you : stackoverflow.com/questions/44701256/…
– Steve Chamaillard
Nov 14 '18 at 22:44
add a comment |
Your error means it doesn't find the sqlite driver within your PHP lib which means the extension is not properly loaded.
Look into your php.ini
file (find its path by doing : php --ini
) and find :
extension=pdo_sqlite
If this is written as :
;extension=pdo_sqlite
, then you should remove the ;
.
Your error means it doesn't find the sqlite driver within your PHP lib which means the extension is not properly loaded.
Look into your php.ini
file (find its path by doing : php --ini
) and find :
extension=pdo_sqlite
If this is written as :
;extension=pdo_sqlite
, then you should remove the ;
.
answered Nov 14 '18 at 22:33
Steve ChamaillardSteve Chamaillard
1,3031023
1,3031023
thanks, but now I am getting a PHP Startup: Unable to load dynamic library 'pdo_sqlite' error.
– Aaron
Nov 14 '18 at 22:44
@Aaron this might help you : stackoverflow.com/questions/44701256/…
– Steve Chamaillard
Nov 14 '18 at 22:44
add a comment |
thanks, but now I am getting a PHP Startup: Unable to load dynamic library 'pdo_sqlite' error.
– Aaron
Nov 14 '18 at 22:44
@Aaron this might help you : stackoverflow.com/questions/44701256/…
– Steve Chamaillard
Nov 14 '18 at 22:44
thanks, but now I am getting a PHP Startup: Unable to load dynamic library 'pdo_sqlite' error.
– Aaron
Nov 14 '18 at 22:44
thanks, but now I am getting a PHP Startup: Unable to load dynamic library 'pdo_sqlite' error.
– Aaron
Nov 14 '18 at 22:44
@Aaron this might help you : stackoverflow.com/questions/44701256/…
– Steve Chamaillard
Nov 14 '18 at 22:44
@Aaron this might help you : stackoverflow.com/questions/44701256/…
– Steve Chamaillard
Nov 14 '18 at 22:44
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53307764%2fdoctrine-dbal-driver-pdoexception-could-not-find-driver-when-trying-to-use-a-fa%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Are you able to use a model directly? Without a factory?
– adam
Nov 14 '18 at 20:44
@adam nope, I tried using the model directly.
– Aaron
Nov 14 '18 at 22:07
Can you show your
config/database.php
file please ?– Steve Chamaillard
Nov 14 '18 at 22:27
@SteveChamaillard, I just added config/database.php.
– Aaron
Nov 14 '18 at 22:30
@SteveChamaillard, thanks, but now I am getting a PHP Startup: Unable to load dynamic library 'pdo_sqlite' error.
– Aaron
Nov 14 '18 at 22:39