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();