1

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);
    }
}
6
  • 1
    Where is the query that you are are trying to do assertion ? Commented Mar 25, 2015 at 8:01
  • There is not any, I need to test apis, but I am assuming assertEquals to be success first. I think I am missing something very basic.
    – Fahad Khan
    Commented Mar 25, 2015 at 8:02
  • Anything I am doing inside testStats() giving the same error. @AbhikChakraborty
    – Fahad Khan
    Commented Mar 25, 2015 at 8:13
  • The error states its a mysql error perhaps see if you are calling a class constuctor which is casing the issue. Commented Mar 25, 2015 at 8:20
  • I guess the error is caused by TestCase::setUp(). Maybe it is making an application and somewhere there a query is executing. Have you set app/database configs correctly? Commented Mar 25, 2015 at 15:04

1 Answer 1

1

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.