我使用"liip/functional-test-bundle": "~1.8",
and"symfony/symfony": "~3.4",
和我的功能测试,我想在会话中设置一些数据,但是在使用相同的键设置数据之后,我有 null。Mytest 类扩展自extends WebTestCase
这就是我在测试方法中设置数据的方式
$session = $this->container->get('session');
$session->set('test', 2);
$this->getClient()->request(
Request::METHOD_GET,
$routing
);
config_test.yml
framework:
test: ~
session:
storage_id: session.storage.mock_file
name: "MOCKSESSID"
profiler:
collect: false
并在行动中
public function getEntityAction()
{
$test = $this->get('session')->get('test');
variable $test
equal null 如何在功能测试的会话中设置一些数据?
调试时,请求前
session = {Symfony\Component\HttpFoundation\Session\Session} [5]
storage = {Symfony\Component\HttpFoundation\Session\Storage\MockFileSessionStorage} [8]
savePath = "/tmp"
id = "d5d7233a843594e94c42b6a0e5a14a86c2518fb5f0a6478732841547b3e93fd6"
name = "MOCKSESSID"
started = true
closed = false
data = {array} [3]
_sf2_attributes = {array} [1]
test = 2
并在行动中
$y = {Symfony\Component\HttpFoundation\Session\Session} [5]
storage ={Symfony\Component\HttpFoundation\Session\Storage\MockFileSessionStorage} [8]
savePath = "/home/ivan/hosts/fix/var/cache/test/sessions"
id = "5ade2581b9764"
name = "MOCKSESSID"
started = true
closed = false
data = {array} [3]
_sf2_attributes = {array} [1]
_security_main = "authuser data"
我不明白为什么 id 和 savePath 不同?