gpt4 book ai didi

symfony - 我正在尝试对 Silex 应用程序进行单元测试,但找不到 Silex\WebTestCase 命名空间

转载 作者:行者123 更新时间:2023-12-04 23:59:15 26 4
gpt4 key购买 nike

我安装了 phpunit 3.6.12 和 Silex。在我的应用程序的根目录中,我有包含简单测试文件 BlogFunctionTest.php 的测试目录

<?

use Silex\WebTestCase;

// BLOG: Front end test
class BlogFunctionalTest extends Silex\WebTestCase
{
public function testIndex()
{
$this->assertGreaterThan(0, 1);
}
}

?>

当我从命令行运行 phpunit 时出现错误
PHP Fatal error:  Class 'Silex\WebTestCase' not found in {path}/BlogFunctionTest.php line 7

它指的是我尝试扩展 WebTestCase 的那一行。如果我更换,也会发生同样的情况
use Silex\WebTestCase;


use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;

Silex 相对于我的测试文件安装在
../vendor/silex/

非常感谢任何提示,谢谢!

最佳答案

您必须在 phpunit.xml.dist 中定义一个 bootstrap ,它指向您的 silex 应用程序的 bootstrap ,就像在这里完成的一样 https://github.com/joshuamorse/Silex-Boilerplate/blob/master/phpunit.xml.dist

关于symfony - 我正在尝试对 Silex 应用程序进行单元测试,但找不到 Silex\WebTestCase 命名空间,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12593386/

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