protected function TextimageTestCase::createTextimageNode in Textimage 7.3
Create a node.
Parameters
string $field_name: Name of the field formatted by Textimage.
string $field_value: Value of the field formatted by Textimage.
string $type: The type of node to create.
3 calls to TextimageTestCase::createTextimageNode()
- TextimageFieldFormatterTest::testTextimageFieldFormatter in tests/
textimage.test - Test Textimage formatter on node display.
- TextimageFieldFormatterTest::testTextimageMultiValueFieldFormatter in tests/
textimage.test - Test Textimage formatter on multi-value text fields.
- TextimageTest::testTextimage in tests/
textimage.test - Test functionality of the module.
File
- tests/
textimage.test, line 114 - Textimage - web test case script.
Class
- TextimageTestCase
- This class provides methods for testing Textimage.
Code
protected function createTextimageNode($field_name, $field_value, $type) {
if (!is_array($field_value)) {
$field_value = array(
$field_value,
);
}
$edit = array(
'title' => $field_value[0],
'body[' . LANGUAGE_NONE . '][0][value]' => $field_value[0],
);
for ($i = 0; $i < count($field_value); $i++) {
$index = $field_name . '[' . LANGUAGE_NONE . '][' . $i . '][value]';
$edit[$index] = $field_value[$i];
}
$this
->drupalPost('node/add/' . $type, $edit, t('Save'));
// Retrieve ID of the newly created node from the current URL.
$matches = array();
preg_match('/node\\/([0-9]+)/', $this
->getUrl(), $matches);
return isset($matches[1]) ? $matches[1] : FALSE;
}