我在这里遵循教程:
http://symfony.com/doc/current/testing.html
运行此行时出现ServiceNotFoundException:
static::createClient();
错误来自
的第35行Symfony\Bundle\FrameworkBundle\Test\WebTestCase.php
是
$client = static::$kernal->getContainer()->get('test.client');
所以我猜测缺少一个名为test.client的服务。我该如何提供该服务?还是其他东西坏了?
答案 0 :(得分:0)
如果扩展WebTestCase类,您应该能够使用此代码获取客户端:
$client = static::createClient([]);
如果您无法以任何方式获取内核,我过去会创建以下方式:
$appKernel = new AppKernel('test', true);
$appKernel->boot();
$container = $appKernel->getContainer();