symfony 2 phpunit-如何取消选中表单字段中的复选框 [英] symfony 2 phpunit - how to untick checkbox in form field

查看:67
本文介绍了symfony 2 phpunit-如何取消选中表单字段中的复选框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这应该很简单,但是我找不到任何答案. 我正在将Symfony 2与phpunit一起使用来测试我的代码. 在运行测试时,让phpunit选中一个复选框很容易:

This should be an easy one but I can't find the answer anywhere. I'm using Symfony 2 with phpunit to test my code. Its easy enough to get phpunit to tick a checkbox while running tests:

$form['mycompanyname_companybundle_editsomethingtype[locked]']->tick();

但是如何让它取消选中"复选框?

But how do I get it to 'untick' a checkbox?

推荐答案

您可以使用

You can use Symfony\Component\DomCrawler\Field\ChoiceFormField::untick() for that. In your case it would be

$form['mycompanyname_companybundle_editsomethingtype[locked]']->untick();

这篇关于symfony 2 phpunit-如何取消选中表单字段中的复选框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆