gpt4 book ai didi

来自代码的 Phpunit 测试给出异常 : Serialization of 'Closure' is not allowed - Laravel

转载 作者:行者123 更新时间:2023-12-01 10:37:02 24 4
gpt4 key购买 nike

我的 route 有这段代码(只是为了让它工作)。

Route::get('/', function () {
$phpunit = new PHPUnit_TextUI_TestRunner;
try {
$test_results = $phpunit->dorun($phpunit->getTest('/var/www/cms/tests/', '', 'Test.php'));
dd($test_results);
} catch (PHPUnit_Framework_Exception $e) {
print $e->getMessage() . "\n";
die ("Unit tests failed.");
}
});

可以在此处找到从代码运行测试的代码示例: Can you run PHPUnit tests from a script?

但是当我运行它时,我收到了错误:Exception: Serialization of 'Closure' is not allowed

我不知道是什么导致了这个错误。

最佳答案

https://phpunit.de/manual/current/en/appendixes.annotations.html#appendixes.annotations.backupGlobals

You can turn off this, in config, example:

<?xml version="1.0" encoding="UTF-8" ?>
<phpunit bootstrap="application/tests/bootstrap.php" backupGlobals="false">
<testsuites>
<testsuite name="TestSuite">
<directory>application/tests</directory>
</testsuite>
</testsuites>
</phpunit>

关于来自代码的 Phpunit 测试给出异常 : Serialization of 'Closure' is not allowed - Laravel,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33477923/

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