Symfony 内存中的数据库-重新迁移。无法登录
我使用fosuserbundle进行身份验证 测试期间的数据库设置为在内存中:Symfony 内存中的数据库-重新迁移。无法登录,symfony,testing,functional-testing,Symfony,Testing,Functional Testing,我使用fosuserbundle进行身份验证 测试期间的数据库设置为在内存中: #config_test.yml doctrine: dbal: driver: pdo_sqlite path: :memory: memory: true orm: auto_generate_proxy_classes: true auto_mapping: true 测试文件看起来就是这样,直到我解决这个问题
#config_test.yml
doctrine:
dbal:
driver: pdo_sqlite
path: :memory:
memory: true
orm:
auto_generate_proxy_classes: true
auto_mapping: true
测试文件看起来就是这样,直到我解决这个问题:
当我运行测试时,我得到302重定向到登录,这是不应该发生的。
这有什么不对吗
当我将配置更改为使用development mysql connection时—它工作正常—响应没有重定向,主体是正确的。好的,我设法找到了发生这种情况的原因 我深入研究了客户机类及其doRequest方法
protected function doRequest($request)
{
// avoid shutting down the Kernel if no request has been performed yet
// WebTestCase::createClient() boots the Kernel but do not handle a request
if ($this->hasPerformedRequest) {
$this->kernel->shutdown();
} else {
$this->hasPerformedRequest = true;
}
if ($this->profiler) {
$this->profiler = false;
$this->kernel->boot();
$this->kernel->getContainer()->get('profiler')->enable();
}
return parent::doRequest($request);
}
所以内核会关闭每个请求,并从内存中删除数据库。这是我99%的猜测
除了使用其他客户端库,我什么都做不了