function DrupalTestCase::drupalPost in SimpleTest 6
Do a post request on a drupal page. It will be done as usual post request with SimpleBrowser By $reporting you specify if this request does assertions or not Warning: empty ("") returns will cause fails with $reporting
Parameters
string $path: Location of the post form. Either a Drupal path or an absolute path or NULL to post to the current page.
array $edit: Field data in an assocative array. Changes the current input fields (where possible) to the values indicated. A checkbox can be set to TRUE to be checked and FALSE to be unchecked.
string $submit: Untranslated value, id or name of the submit button.
59 calls to DrupalTestCase::drupalPost()
- ActionsContentTest::testActionsContent in tests/
content_actions.test - Various tests, all in one function to assure they happen in the right order.
- AddTopicToForum::testAddTopicToContainer in tests/
forum_module.test - AddTopicToForum::testAddTopicToForum in tests/
forum_module.test - AddTopicToForum::testMoveTopicToForum in tests/
forum_module.test - AddTopicToForum::testMoveTopicWithCopyToForum in tests/
forum_module.test
File
- ./
drupal_test_case.php, line 196
Class
- DrupalTestCase
- Test case for typical Drupal tests. Extends WebTestCase for comfortable browser usage but also implements all UnitTestCase methods, I wish WebTestCase would do this.
Code
function drupalPost($path, $edit = [], $submit) {
if (isset($path)) {
$ret = $this
->drupalGet($path);
$this
->assertTrue($ret, t(' [browser] GET path "@path"', array(
'@path' => $path,
)));
}
foreach ($edit as $field_name => $field_value) {
$ret = $this->_browser
->setFieldByName($field_name, $field_value) || $this->_browser
->setFieldById("edit-{$field_name}", $field_value);
$this
->assertTrue($ret, " [browser] Setting {$field_name}=\"{$field_value}\"");
}
$ret = $this->_browser
->clickSubmit(t($submit)) || $this->_browser
->clickSubmitById($submit) || $this->_browser
->clickSubmitByName($submit) || $this->_browser
->clickImageByName($submit);
$this
->assertTrue($ret, ' [browser] POST by click on ' . t($submit));
$this->_content = $this->_browser
->getContent();
}