protected function BotchaBaseWebTestCase::getFormBuildIdFromForm in BOTCHA Spam Prevention 7.3
Same name and namespace in other branches
- 6 botcha.test \BotchaBaseWebTestCase::getFormBuildIdFromForm()
- 6.2 botcha.test \BotchaBaseWebTestCase::getFormBuildIdFromForm()
- 6.3 tests/botcha.simpletest.test \BotchaBaseWebTestCase::getFormBuildIdFromForm()
- 7 botcha.test \BotchaBaseWebTestCase::getFormBuildIdFromForm()
- 7.2 botcha.test \BotchaBaseWebTestCase::getFormBuildIdFromForm()
Get the form_build_id from the current form in the browser.
1 call to BotchaBaseWebTestCase::getFormBuildIdFromForm()
- BotchaNoResubmitTestCase::setFormValues in tests/
botcha.simpletest.test - Helper function to generate a default form values array for any form.
File
- tests/
botcha.simpletest.test, line 191 - Simpletest-tests for BOTCHA module.
Class
- BotchaBaseWebTestCase
- Base class for BOTCHA tests.
Code
protected function getFormBuildIdFromForm($form = NULL) {
// Form a xpath query string.
$xpath = '//';
if (!empty($form)) {
// Specially to transform user_login to user-login.
// @todo getFormBuildIdFromForm ?Is there a better way to do it?
$form_filtered = str_replace('_', '-', $form);
// If form parameter is set we are looking for forms like it. It is useful
// when we have multiple forms on one page.
$xpath .= "form[contains(@id, '{$form_filtered}')]/div/";
}
$xpath .= "input[@name='form_build_id']/@value";
// Force conversion to string.
//$form_build_id = (string) current($this->xpath("//input[@name='form_build_id']/@value"));
$form_build_id = (string) current($this
->xpath($xpath));
return $form_build_id;
}