public function ConflictTestCase::testComplexTroublesCase in Conflict 7
Test case for complex errors.
Emulates that title field has conflict; body field is outdated and custom field_text is not modified and not outdated.
File
- ./
conflict.test, line 361 - Tests for conflict.module.
Class
Code
public function testComplexTroublesCase() {
$this
->createFieldWithInstance('text');
$orig_title = $this
->randomName();
$orig_body = $this
->randomString();
$orig_text = $this
->randomString();
$their_title = $this
->randomName();
$their_body = $this
->randomString();
// Create the node to work with.
$node = $this
->drupalCreateNode(array(
'title' => $this
->randomName(),
'body' => array(
LANGUAGE_NONE => array(
array(
'value' => $orig_body,
'summary' => '',
),
),
),
'field_text' => array(
LANGUAGE_NONE => array(
array(
'value' => $orig_text,
),
),
),
));
// Load the edit page up.
$this
->drupalGet("node/{$node->nid}/edit");
// Before submitting the form, make changes to the node from somewhere else.
$conflict = clone $node;
$conflict->title = $their_title;
$conflict->body['und'][0]['value'] = $their_body;
$conflict->field_text['und'][0]['value'] = $orig_text;
node_save($conflict);
// Fudge the timestamps in the database.
db_query('UPDATE {node} SET changed = changed + 100 WHERE nid = :nid', array(
':nid' => $conflict->nid,
));
db_query('UPDATE {node_revision} SET timestamp = timestamp + 100 WHERE nid = :nid', array(
':nid' => $conflict->nid,
));
// Attempt to make changes.
$edit['title'] = $orig_title;
$edit['body[und][0][value]'] = $orig_body;
$edit['field_text[und][0][value]'] = $orig_text;
$this
->drupalPost(NULL, $edit, t('Save'));
$this
->assertNoText('The content on this page has either been modified by another user, or you have already submitted modifications using this form. As a result, your changes cannot be saved.');
$this
->assertText(t('The Title field was changed by another user while you were editing it. Save again to overwrite it.'));
$this
->assertText('The Body field was changed by another user. Please verify the updated value.');
$this
->assertNoText('The field_text field was changed by another user. Please verify the updated value.');
$this
->assertFieldByXPath('//*[@id="edit-title" and contains(@class, "error")]', $orig_title, 'Title field was highlighted with error and contains conflicted data.');
$this
->assertFieldByXPath('//*[@id="edit-body-und-0-value" and contains(@class, "error")]', $their_body, 'Body field was highlighted with error and contains conflicted data.');
$this
->assertNoFieldByXPath('//*[@id="edit-field_text-und-0-value" and contains(@class, "error")]', $orig_text, 'Custom field was not highlighted with error and contains conflicted data.');
}