【问题标题】:I am trying to unit test a Silex application but Silex\WebTestCase namespace cannot be found我正在尝试对 Silex 应用程序进行单元测试,但找不到 Silex\WebTestCase 命名空间
【发布时间】:2012-09-17 14:04:36
【问题描述】:

我安装了 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/

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

【问题讨论】:

    标签: symfony phpunit silex


    【解决方案1】:

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

    【讨论】:

    • 那是票。谢谢!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-09-12
    • 1970-01-01
    • 2015-08-31
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多