我正在为我的 Symfony2 项目中的一些服务编写一些单元测试。我需要通过服务容器访问服务,我正在使用这种方法:
class DummyTest extends \PHPUnit_Framework_TestCase
{
protected static $kernel;
protected static $container;
public static function setUpBeforeClass()
{
self::$kernel = new \AppKernel('test', true);
self::$kernel->boot();
self::$container = self::$kernel->getContainer();
}
//test cases
}
当$kernel->boot()被调用时,我得到以下错误:'MongoCursor' not found in Doctrine/Bundle/MongoDBBundle/DependencyInjection/Configuration.php。我查看了 Configuration.php 并没有提到MongoCursor。这是Bundle的版本问题吗?
环境: Symfony2.1.6和DoctrineMongoDBundle 的 2.0.1 版本。