0
我正在PhpUnit中进行功能测试,以测试只有一个字段和两个按钮的简单模式窗口功能(我尝试过各种方法,因此代码可能不干净,米粘贴只是为了显示的想法):PhpUnit窗体不提交,没有错误
$form = $crawler
// find all buttons with the text "Pridėti"
->filter('button:contains("Pridėti")')
->eq(0)
->form()// select the first button in the list
;
$form['appbundle_classinfo[name]'] = '5a';
$crawler = $client->submit($form);
//It doesn't even save to database
$container = self::$kernel->getContainer();
$em = $container->get('doctrine')->getManager();
$classinfo = $em->getRepository('AppBundle:ClassInfo');
//Echoes modal window
echo $client->getResponse()->getContent() ;die;
我也试图的var_dump形式,它示出了值被添加到形式: 串(25)“appbundle_classinfo [名称]” [“值” :protected] => string(2)“5a”
所以表单没有提交。你能帮我找出原因吗?
您是否检查过API? 'form()'返回一个数组吗? –