DoctrineDBALDriverPDOException: could not find driver when trying to use a factory in my unit tests










2















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' => '',
],









share|improve this question
























  • 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















2















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' => '',
],









share|improve this question
























  • 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













2












2








2








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' => '',
],









share|improve this question
















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






share|improve this question















share|improve this question













share|improve this question




share|improve this question








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 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

















  • 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
















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












2 Answers
2






active

oldest

votes


















0














Define a setUp method in your test:



public function setUp()

parent::setUp();






share|improve this answer























  • I added the setUp method and am still getting the same error.

    – Aaron
    Nov 14 '18 at 20:30


















0














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 ;.






share|improve this answer























  • 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










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
);



);













draft saved

draft discarded


















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









0














Define a setUp method in your test:



public function setUp()

parent::setUp();






share|improve this answer























  • I added the setUp method and am still getting the same error.

    – Aaron
    Nov 14 '18 at 20:30















0














Define a setUp method in your test:



public function setUp()

parent::setUp();






share|improve this answer























  • I added the setUp method and am still getting the same error.

    – Aaron
    Nov 14 '18 at 20:30













0












0








0







Define a setUp method in your test:



public function setUp()

parent::setUp();






share|improve this answer













Define a setUp method in your test:



public function setUp()

parent::setUp();







share|improve this answer












share|improve this answer



share|improve this answer










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

















  • 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













0














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 ;.






share|improve this answer























  • 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















0














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 ;.






share|improve this answer























  • 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













0












0








0







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 ;.






share|improve this answer













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 ;.







share|improve this answer












share|improve this answer



share|improve this answer










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

















  • 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

















draft saved

draft discarded
















































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.




draft saved


draft discarded














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





















































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







這個網誌中的熱門文章

How to read a connectionString WITH PROVIDER in .NET Core?

In R, how to develop a multiplot heatmap.2 figure showing key labels successfully

Museum of Modern and Contemporary Art of Trento and Rovereto