gpt4 book ai didi

php - 由 PDOException : SQLSTATE[42000] - php unit test in Laravel 引起

转载 作者:行者123 更新时间:2023-11-30 22:47:16 25 4
gpt4 key购买 nike

我是 laravel 和 php 单元测试的新手。我正在尝试在 laravel 中运行一个非常基本的测试,并在通过命令行运行 phpunit 时出现以下错误:

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

最佳答案

请检查您所写的查询。或者从 phpunit.xml 中注释掉与数据库相关的部分,以在没有数据库交互的情况下运行测试

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

关于php - 由 PDOException : SQLSTATE[42000] - php unit test in Laravel 引起,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29250227/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com