mercredi 27 mars 2019

PDO Extention on laravel unit testing

I've been struggling with setting up unit test with my laravel application, I'm facing error... it says that PDO extention is not installed and giving me error that pdo exeption driver not found but it's installed!!!. when i serve my application everything is ok!!!

pdo is also installed

  28 => "json"
  29 => "exif"
  30 => "mysqli"
  31 => "pdo_mysql"
  32 => "pdo_sqlite"
  33 => "Phar"
  34 => "posix"
  35 => "readline"
  36 => "shmop"

here is my test code

<?php

namespace Tests\Unit;

use App\Models\User\User;
use Tests\TestCase;
use Illuminate\Foundation\Testing\RefreshDatabase;

class ExampleTest extends TestCase
{
    /**
     * A basic test example.
     *
     * @return void
     */
    public function testBasicTest()
    {
        factory(User::class)->create();
        $this->assertTrue(true);
    }
}



trace of error

 /home/soheil/Documents/Projects/PHP/EcollegeMe/vendor/laravel/framework/src/Illuminate/Database/Connection.php:664
 /home/soheil/Documents/Projects/PHP/EcollegeMe/vendor/laravel/framework/src/Illuminate/Database/Connection.php:624
 /home/soheil/Documents/Projects/PHP/EcollegeMe/vendor/laravel/framework/src/Illuminate/Database/Connection.php:459
 /home/soheil/Documents/Projects/PHP/EcollegeMe/vendor/laravel/framework/src/Illuminate/Database/Connection.php:411
 /home/soheil/Documents/Projects/PHP/EcollegeMe/vendor/laravel/framework/src/Illuminate/Database/Query/Processors/Processor.php:32
 /home/soheil/Documents/Projects/PHP/EcollegeMe/vendor/laravel/framework/src/Illuminate/Database/Query/Builder.php:2653
 /home/soheil/Documents/Projects/PHP/EcollegeMe/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Builder.php:1347
 /home/soheil/Documents/Projects/PHP/EcollegeMe/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php:835
 /home/soheil/Documents/Projects/PHP/EcollegeMe/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php:800
 /home/soheil/Documents/Projects/PHP/EcollegeMe/vendor/laravel/framework/src/Illuminate/Database/Eloquent/Model.php:663
 /home/soheil/Documents/Projects/PHP/EcollegeMe/vendor/laravel/framework/src/Illuminate/Database/Eloquent/FactoryBuilder.php:206
 /home/soheil/Documents/Projects/PHP/EcollegeMe/vendor/laravel/framework/src/Illuminate/Support/Collection.php:419
 /home/soheil/Documents/Projects/PHP/EcollegeMe/vendor/laravel/framework/src/Illuminate/Database/Eloquent/FactoryBuilder.php:207
 /home/soheil/Documents/Projects/PHP/EcollegeMe/vendor/laravel/framework/src/Illuminate/Database/Eloquent/FactoryBuilder.php:181
 /home/soheil/Documents/Projects/PHP/EcollegeMe/tests/Unit/ExampleTest.php:18

 Caused by
 PDOException: could not find driver



Aucun commentaire:

Enregistrer un commentaire