Fahad Khan
Fahad Khan

Reputation: 1635

Caused by PDOException: SQLSTATE[42000] - php unit test in Laravel

I am new to laravel and php unit testing. I am trying to run a very basic test in laravel and getting the error below while running phpunit through command line:

Caused by PDOException: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'after impressions, clicks int not null, clicks_change float(4, 2) not null' at line 1

class ExampleTest extends TestCase {

    /**
     * A basic functional test example.
     *
     * @return void
     */
    public function testStats()
    {
        $result = true;
        $this->assertEquals(true, $result);
    }
}

Upvotes: 1

Views: 1114

Answers (1)

User123456
User123456

Reputation: 2738

Please check the query you have written. Or comment out DB related part from your phpunit.xml to run the tests without no db interaction

    <!--<env name="DB_CONNECTION" value="mysql"/>-->
    <!--<env name="DB_DATABASE" value="event_test_db"/>-->

Upvotes: 1

Related Questions