我不明白为什么这个简单的例子不能与Codeception和Phpbrowser一起使用:
验收测试:
public function tryToTest(AcceptanceTester $I)
{
$I->setCookie('test', 1);
$I->amOnPage('/test.php');
$I->dontSeeCookie('test');
}
test.php的
<?php
var_dump($_COOKIE);
if (isset($_COOKIE['test'])){
unset($_COOKIE['test']);
setcookie('test', '', 1, '/');
echo 'delete cookie';
}
var_dump($_COOKIE);
我在控制台中得到的结果:
Try to test
Test tests/acceptance/Membre/osefCest.php:tryToTest
Step Don't see cookie "test"
Fail Failed asserting that Symfony\Component\BrowserKit\Cookie Object &0000000040bdf1ba000000010c93ce0d (
'name' => 'test'
'value' => 1
'expires' => null
'path' => '/'
'domain' => ''
'secure' => false
'httponly' => true
'rawValue' => '1'
) is null.
输出Codeception:
array(1) {
["test"]=>
string(1) "1"
}
delete cookie
array(0) {
}
在脚本中似乎删除了cookie,但Codeception中的测试说明相反。 这是正常的吗?如何删除cookie并在Codeception中检查它?
谢谢!