【发布时间】:2014-05-18 00:57:54
【问题描述】:
如果我在表单中的select 输入中发送错误值,我想测试我的应用程序的行为。
这是我的 HTML 表单:
<form (...)>
(...)
<select name="select_input">
<option value="1">text</option>
</select>
</select>
在我的测试中,使用爬虫获取表单并尝试“选择”不正确的值:
$form['select_input'] = 9999999;
$client->submit($form);
/* EDIT */
/*I am expecting the user to not be redirected to the user page,
and the server to respond with the same form, containing an error message */
$this->assertFalse($client->getResponse()->isRedirect('/success_page'));
$this->assertEquals(1, $client->getCrawler()->filter('input.error'));
但在控制台中,我收到了消息:
InvalidArgumentException: Input "user_profile[voteProfile]" cannot take "9999999" as a value (possible values: 1)
如何选择不正确的值来测试答案?真实服务器可能会发送不正确的值。
【问题讨论】:
-
你有没有解决这个问题???如果你是怎么做的???这几天一直困扰着我。 -谢谢
-
我添加了一个简单的答案,感谢提醒我的问题:-)